jigsaw

Java 9 webstart JNLP Service produces IllegalAccess

假装没事ソ 提交于 2019-12-06 13:57:54
问题 The following code (to retrieve the base URL of a Java Web Start client application via the JNLP API) worked in Java 8 but failed when executed in (modularized) Java 9 runtime: Class<?> mclass = Class.forName("javax.jnlp.ServiceManager"); Method lookup = mclass.getMethod("lookup", new Class[]{String.class}); Object basicSvc = lookup.invoke(null, new Object[{"javax.jnlp.BasicService"}); Class<?> sclass = basicSvc.getClass(); Method getCodeBase = sclass.getMethod("getCodeBase", (Class[])null);

Can one Java module export a package whose name is a subpackage of a package from another module? [duplicate]

…衆ロ難τιáo~ 提交于 2019-12-06 11:10:33
This question already has an answer here : Java 9 sub-packages split across modules (1 answer) Closed 10 months ago . So I know that, in Java 9 modules (Project Jigsaw), split packages are not allowed. That is, the following modules couldn't both export a package with the same name and also be used at the same time at run time: Module 1 module com.example.foo { exports com.example.foo; } Module 2 module com.example.foo { exports com.example.foo; } Not allowed (or, at least, they can't run at the same time). But what isn't clear to me is how subpackages come in to play. If one module exports

“Essential” (Jigsawed) Java 9 JRE without modularized code

匆匆过客 提交于 2019-12-06 05:57:36
问题 We have a Java application that does not use AWT/Swing/JavaFX and works fine with a private bundled JRE 8. JRE 9 is significantly larger than JRE 8 but we want to let the users try our application with JRE 9. We don't yet want to modularize our code or the jars (to keep compatibility with Java 8). How to create an "essential" (= stripped down to the minimal required parts), private JRE 9 that could be bundled with that Java application? 回答1: It is possible to create custom runtime-images of

Can I provide runtime compiler access when running with JRE in Java 9+?

牧云@^-^@ 提交于 2019-12-06 03:34:29
问题 I'm migrating an application to Java 10. Our application normally runs with the JRE, but we allow users to compile bits of their own custom code by bundling tools.jar and using reflection to load a JavacTool instance on demand. Our method looks like: public static JavaCompiler getJavaCompiler() { String toolJarName = "tools.jar"; File file = getResourceForClass("tools.jar"); try { file = file.getCanonicalFile(); } catch (IOException ignore) { } if (!file.exists()) throw new RuntimeException(

Java9 packager with jlink compress tags

南楼画角 提交于 2019-12-06 02:43:02
问题 when we create jlink runtime images we can use tags such as '--strip-debug', '--compress', '2', '--no-header-files', '--no-man-pages' , creating a distribution folder around 45mb. If we want to use javapackager, for example to create an .DMG file, how can we do a similar compression? since these tags are not avaiable for javapackager. Without them the final bundle is around 100mb, losing a lot the java9 modularization advantages, so my question is if it is possible to use javapackager with

Java9 Multi-Module Maven Project Test Dependencies

一个人想着一个人 提交于 2019-12-05 22:27:13
问题 I have a multi-module maven project with three modules core , utils and test-utils Core has the following dependencies definition <dependency> <groupId>my.project</groupId> <artifactId>utils</artifactId> </dependency> <dependency> <groupId>my.project</groupId> <artifactId>test-utils</artifactId> <scope>test</scope> </dependency> I have added Java 9 module-info.java definitions for all three modules and core 's looks like this: module my.project.core { requires my.project.utils; } However I

Exporting a package from system module is not allowed with --release

二次信任 提交于 2019-12-05 18:00:11
问题 I have the following program: module-info.java module a { } Main.java public class Main { public static void main(String[] args) { System.out.println(sun.nio.ByteBuffered.class); } } This program successfully compiles with the --add-exports option: > javac --add-exports java.base/sun.nio=a module-info.java Main.java However, when I add the --release argument, it fails: > javac --add-exports java.base/sun.nio=a --release 9 module-info.java Main.java error: exporting a package from system

Java 11: Implementation of JAXB-API has not been found on module path or classpath

筅森魡賤 提交于 2019-12-05 17:10:43
I have a little project which does throw an exception when i let it run. The problem is here (TestObject.java): final JAXBContext jaxbContext = JAXBContext.newInstance(...); I really do not understand why this throws the exception. I also created a test which works like a charm (TestTest.java). Please forgive me the names, but this is just a small test application to get this working with java 11. I followed this: javax.xml.bind.JAXBException Implementation of JAXB-API has not been found on module path or classpath and added compile('javax.xml.bind:jaxb-api:2.3.0') compile('javax.activation

Patching java.base results in java.lang.LinkageError

北慕城南 提交于 2019-12-05 12:44:09
I am trying to do the same thing in Java 11 that could be done with -Xbootclasspath/p:path in pre java 9. As a simple example I modified one of the valueOf methods of java.lang.Integer and compiled the project with: javac --module-source-path=src/java.base --patch-module java.base=src/java.base -d mods $(find src -name '*.java') I then ran a simple sample using: java --patch-module java.base=<pathToMyModifiedJavaBaseClasses> -p lib -m my.moduleA/my.moduleA.Main That worked an I'm seeing the modifications displayed (a simple print out I did from valueOf ). When I try, however, to do the same

module java.base does not read module java.desktop

﹥>﹥吖頭↗ 提交于 2019-12-05 11:05:48
When I run this test (using jmockit and TestNG, not sure if that's relevant): public class Test { @Test public void test(@Mocked ProcessBuilder pb) throws IOException { new Expectations() {{ pb.start(); result = null; }}; assertNull(m()); } public static Process m() throws IOException { return new ProcessBuilder("").start(); } } I get this exception: java.lang.IllegalAccessError: class java.lang.ProcessBuilder (in module java.base) cannot access class javax.print.PrintException (in module java.desktop) because module java.base does not read module java.desktop at java.base/java.lang