java-platform-module-system

How to access to resources in external resource folder in Java 9 modular project [duplicate]

江枫思渺然 提交于 2020-08-06 05:01:01
问题 This question already has answers here : Accessing resource files from external modules (2 answers) How to work with resources in Java 9 modules (1 answer) Java 9 Module system Resources files location (2 answers) Closed 2 years ago . When I have the following code that attempts accessing to a resource: foo/Main.java package foo; import java.io.*; public class Main{ public static void main(String... args) throws IOException{ try(BufferedReader in = new BufferedReader(new InputStreamReader(

Is it possible to access package scoped methods by reflection in Java 9 with Jigsaw?

谁说我不能喝 提交于 2020-08-04 23:19:32
问题 I have the following code to retrieve the default URLStreamHandlers for http and https which works in Java 8 by accessing the static package scoped method URL.getURLStreamHandler() : private URLStreamHandler getURLStreamHandler(String protocol) { try { Method method = URL.class.getDeclaredMethod("getURLStreamHandler", String.class); method.setAccessible(true); return (URLStreamHandler) method.invoke(null, protocol); } catch (Exception e) { logger.warning("could not access URL