It seems to me that all the command line options of the VM before jigsaw doesn't use space as a separator, but with the new option like --module-path or --add-modules, you have to put a space after, so it doesn't work well with the -J option used to take option from tools like javac to feed them to the VM, because the space in the middle of the VM option is interpreted as a space between the options of the tool.
regards, Rémi ----- Mail original ----- > De: "Claes Redestad" <claes.redes...@oracle.com> > À: jigsaw-dev@openjdk.java.net, eir...@gmail.com > Envoyé: Dimanche 20 Novembre 2016 23:23:26 > Objet: Re: javac --add-modules java.xml.bind for annotation processor? > Hi Eirik, > > compiling com.example.processor.ProcessorUsingJavaXmlBind standalone > seems to work fine with --add-modules java.xml.bind - instead it > appears as if maven-compiler-plugin doesn't preserve argument order, so > you need to use the joined argument form in your pom.xml: > > <arg>--add-modules=java.xml.bind</arg> > > I tried this on your minified example, and seems to work. Thanks! > > /Claes > > On 2016-11-20 22:57, Eirik Bjørsnøs wrote: >> Hi there! >> >> I'm giving Java 9 and Jigsaw a spin on a moderately complex project. >> (Interestingly, the project is itself a module system, so we do stuff like >> annotation processing and dynamic reloading of class loader graphs and >> services) >> >> I'm experienced enough with advanced Java to have shot myself in the foot >> with a java.lang.ClassNotFoundException: java.lang.ClassNotFoundException >> :-) However, I've only recently been looking into Jigsaw in concrete terms. >> So please be kind when I expose my ignorance :-) >> >> Initially, I just want to see if I can get the project to compile on Java 9. >> >> So I'm using --add-modules to javac here and there to add modules not >> available to the unnamed module by default. (Not making any proper modules >> yet, that will be the next step). >> >> This seems to be working fine, except for one of our annotation processors, >> which happens to use JAXBContext from java.xml.bind. >> >> I added --add-modules to javac (via Maven configuration), but my annotation >> processor still can't load JAXBContext and fails with this message: >> >> $ java -version >> java version "9-ea" >> Java(TM) SE Runtime Environment (build 9-ea+144) >> Java HotSpot(TM) 64-Bit Server VM (build 9-ea+144, mixed mode) >> >> $ mvn clean install -e >> >> This fails with: >> >> Caused by: java.lang.NoClassDefFoundError: javax/xml/bind/JAXBContext >> at >> com.example.processor.ProcessorUsingJavaXmlBind.process(ProcessorUsingJavaXmlBind.java:24) >> at >> jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor(JavacProcessingEnvironment.java:959) >> at >> jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnvironment.discoverAndRunProcs(JavacProcessingEnvironment.java:875) >> at >> jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnvironment.access$2100(JavacProcessingEnvironment.java:106) >> at >> jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnvironment$Round.run(JavacProcessingEnvironment.java:1182) >> at >> jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:1290) >> at >> jdk.compiler/com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:1260) >> at >> jdk.compiler/com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:939) >> at >> jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl$1.call(JavacTaskImpl.java:106) >> at >> jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl$1.call(JavacTaskImpl.java:100) >> at >> jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.handleExceptions(JavacTaskImpl.java:137) >> ... 28 more >> >> I've confirmed that this reproduces using only javac: >> >> $ cd example-module >> >> $ javac -d target/classes -classpath >> target/classes:$HOME/.m2/repository/com/example/annotation-processor/1.0-SNAPSHOT/annotation-processor-1.0-SNAPSHOT.jar: >> -sourcepath src/main/java/ -target 1.9 -source 1.9 --add-modules >> java.xml.bind src/main/java/com/example/module/SomeClass.java >> >> java.xml? true >> java.xml.bind? false >> >> >> An annotation processor threw an uncaught exception. >> Consult the following stack trace for details. >> java.lang.NoClassDefFoundError: javax/xml/bind/JAXBContext >> at >> com.example.processor.ProcessorUsingJavaXmlBind.process(ProcessorUsingJavaXmlBind.java:24) >> at >> jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor(JavacProcessingEnvironment.java:959) >> >> >> I've reduced this to a minimal-ish test case, available on Github: >> >> https://github.com/eirbjo/java-xml-bind-processor >> >> Here's the annotation processor: >> >> https://github.com/eirbjo/java-xml-bind-processor/blob/master/annotation-processor/src/main/java/com/example/processor/ProcessorUsingJavaXmlBind.java >> >> The class under compilation and the annotation: >> >> https://github.com/eirbjo/java-xml-bind-processor/blob/master/example-module/src/main/java/com/example/module/SomeClass.java >> https://github.com/eirbjo/java-xml-bind-processor/blob/master/example-module/src/main/java/com/example/module/SomeAnnotation.java >> >> >> Any clues? >> >> Cheers, >> Eirik.