- Notifications
You must be signed in to change notification settings - Fork 62
Description
I first thought that I am dealing with a problem in Maven Compiler Plugin, so I created MCOMPILER-566 earlier today. Copying the information from there to here:
When analysing MCOMPILER-424, at some point I wanted to know what happens if I set fork=true or forceJavacCompilerUse=true. The result was bad: No matter if I compile with mvn -e -X or verbose=true, I only see a CompilationFailureException: Compilation failure. There seems to be no way to actually see the underlying root cause. I have to compile in process via Plexus JavaxToolsCompiler to see the AnnotationTypeMismatchException from this comment.
It is not helpful to know that compilation failed, but not why.
Intermediate result: I added some debug statements into org.codehaus.plexus.compiler.javac.JavacCompiler::compileOutOfProcess:
returnCode = CommandLineUtils.executeCommandLine(cli, out, out); System.out.println("### plexus javac return code: " + returnCode); System.out.println("### plexus javac output:\n" + out.getOutput()); messages = parseModernStream(returnCode, new BufferedReader(new StringReader(out.getOutput()))); System.out.println("### plexus javac messages: " + messages);The Maven console log when running with the latest Maven Compiler and latest Plexus Compiler (sorry for interspersed German messages due to locale auto detection):
[INFO] Compiling 1 source file with javac [forked debug release 17] to target\classes ### plexus javac return code: 3 ### plexus javac output: Processor ran! [org.example.MyFirstAnnotation] [errorRaised=false, rootElements=[org.example.AnnotatedClass], processingOver=false] Warnung: No SupportedSourceVersion annotation found on org.example.Processor, returning RELEASE_6. Warnung: Unterst�tzte Quellversion "RELEASE_6" von Annotationsprozessor "org.example.Processor" kleiner als -source "17" 2 Warnungen Ein Annotationsprozessor hat eine nicht abgefangene Ausnahme ausgel�st. Details finden Sie im folgenden Stacktrace. java.lang.annotation.AnnotationTypeMismatchException: Incorrectly typed data found for annotation element public abstract org.example.MySecondAnnotation org.example.MyFirstAnnotation.secondAnnotation() (Found data of type org.example.MySecondAnnotation) at jdk.compiler/com.sun.tools.javac.model.AnnotationProxyMaker$ValueVisitor$1AnnotationTypeMismatchExceptionProxy.generateException(AnnotationProxyMaker.java:271) at java.base/sun.reflect.annotation.AnnotationInvocationHandler.invoke(AnnotationInvocationHandler.java:89) at jdk.proxy3/jdk.proxy3.$Proxy3.secondAnnotation(Unknown Source) at org.example.Processor.process(Processor.java:23) at jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor(JavacProcessingEnvironment.java:1021) at jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnvironment.discoverAndRunProcs(JavacProcessingEnvironment.java:937) at jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnvironment$Round.run(JavacProcessingEnvironment.java:1265) at jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:1380) at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:1271) at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:948) at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:319) at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:178) at jdk.compiler/com.sun.tools.javac.Main.compile(Main.java:64) at jdk.compiler/com.sun.tools.javac.Main.main(Main.java:50) As you can see, Plexus JavacCompiler gets all the output from javac, but then somehow discards it while parsing it in JavacCompiler::parseModernStream. I have not debugged into that part yet, but it looks like a Plexus Compiler Javac bug.
BTW, this...
Ein Annotationsprozessor hat eine nicht abgefangene Ausnahme ausgelöst. Details finden Sie im folgenden Stacktrace. translates to:
An annotation processor threw an uncaught exception. Consult the following stack trace for details.