Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JavacCompiler ignores exceptions in annotation processors #106

Closed
danberindei opened this issue Oct 7, 2020 · 1 comment
Closed

JavacCompiler ignores exceptions in annotation processors #106

danberindei opened this issue Oct 7, 2020 · 1 comment

Comments

@danberindei
Copy link

While trying out Error Prone, the compilation failed because one of our other annotation processors required an extra jar on the classpath. JavacCompiler.parseModernStream ignores annotation processor exceptions, making it very hard to figure out what went wrong.

This is the forked Javac's output:

/home/dan/Work/infinispan/commons/all/src/main/java/org/infinispan/commons/dataconversion/MediaType.java:20: warning: [deprecation] Externalizer in org.infinispan.commons.marshall has been deprecated
import org.infinispan.commons.marshall.Externalizer;
                                      ^
/home/dan/Work/infinispan/commons/all/src/main/java/org/infinispan/commons/dataconversion/MediaType.java:22: warning: [deprecation] SerializeWith in org.infinispan.commons.marshall has been deprecated
import org.infinispan.commons.marshall.SerializeWith;
                                      ^
/home/dan/Work/infinispan/commons/all/src/main/java/org/infinispan/commons/tx/XidImpl.java:13: warning: [deprecation] AdvancedExternalizer in org.infinispan.commons.marshall has been deprecated
import org.infinispan.commons.marshall.AdvancedExternalizer;
                                      ^
/home/dan/Work/infinispan/commons/all/src/main/java/org/infinispan/commons/dataconversion/MarshallerEncoder.java:7: warning: [deprecation] StreamingMarshaller in org.infinispan.commons.marshall has been deprecated
import org.infinispan.commons.marshall.StreamingMarshaller;
                                      ^
/home/dan/Work/infinispan/commons/all/src/main/java/org/infinispan/commons/util/ImmutableListCopy.java:15: warning: [deprecation] AdvancedExternalizer in org.infinispan.commons.marshall has been deprecated
import org.infinispan.commons.marshall.AdvancedExternalizer;
                                      ^
Note: Writing META-INF/services/reactor.blockhound.integration.BlockHoundIntegration
5 warnings


An annotation processor threw an uncaught exception.
Consult the following stack trace for details.
java.lang.NoClassDefFoundError: javax/annotation/Generated
	at org.infinispan.protostream.annotations.impl.processor.AutoProtoSchemaBuilderAnnotationProcessor.addGeneratedClassHeader(AutoProtoSchemaBuilderAnnotationProcessor.java:565)
	at org.infinispan.protostream.annotations.impl.processor.MarshallerSourceCodeGenerator.generateMessageMarshaller(MarshallerSourceCodeGenerator.java:156)
	at org.infinispan.protostream.annotations.impl.processor.MarshallerSourceCodeGenerator.generateMarshaller(MarshallerSourceCodeGenerator.java:56)
	at org.infinispan.protostream.annotations.impl.BaseProtoSchemaGenerator.generateMarshallers(BaseProtoSchemaGenerator.java:204)
	at org.infinispan.protostream.annotations.impl.BaseProtoSchemaGenerator.generateAndRegister(BaseProtoSchemaGenerator.java:175)
	at org.infinispan.protostream.annotations.impl.processor.AutoProtoSchemaBuilderAnnotationProcessor.processClass(AutoProtoSchemaBuilderAnnotationProcessor.java:321)
	at org.infinispan.protostream.annotations.impl.processor.AutoProtoSchemaBuilderAnnotationProcessor.processElement(AutoProtoSchemaBuilderAnnotationProcessor.java:252)
	at org.infinispan.protostream.annotations.impl.processor.AutoProtoSchemaBuilderAnnotationProcessor.process(AutoProtoSchemaBuilderAnnotationProcessor.java:179)
	at jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor(JavacProcessingEnvironment.java:1026)
	at jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnvironment.discoverAndRunProcs(JavacProcessingEnvironment.java:941)
	at jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnvironment$Round.run(JavacProcessingEnvironment.java:1270)
	at jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:1384)
	at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:1263)
	at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:935)
	at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:316)
	at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:176)
	at jdk.compiler/com.sun.tools.javac.Main.compile(Main.java:57)
	at jdk.compiler/com.sun.tools.javac.Main.main(Main.java:43)
Caused by: java.lang.ClassNotFoundException: javax.annotation.Generated
	at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:435)
	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:589)
	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
	... 18 more

And this is the parsed list of messages:

messages = {java.util.ArrayList}  size = 5
 0 = {org.codehaus.plexus.compiler.CompilerMessage} "/home/dan/Work/infinispan/commons/all/src/main/java/org/infinispan/commons/dataconversion/MediaType.java:[20,38] [deprecation] Externalizer in org.infinispan.commons.marshall has been deprecated"
 1 = {org.codehaus.plexus.compiler.CompilerMessage} "/home/dan/Work/infinispan/commons/all/src/main/java/org/infinispan/commons/dataconversion/MediaType.java:[22,38] [deprecation] SerializeWith in org.infinispan.commons.marshall has been deprecated"
 2 = {org.codehaus.plexus.compiler.CompilerMessage} "/home/dan/Work/infinispan/commons/all/src/main/java/org/infinispan/commons/tx/XidImpl.java:[13,38] [deprecation] AdvancedExternalizer in org.infinispan.commons.marshall has been deprecated"
 3 = {org.codehaus.plexus.compiler.CompilerMessage} "/home/dan/Work/infinispan/commons/all/src/main/java/org/infinispan/commons/dataconversion/MarshallerEncoder.java:[7,38] [deprecation] StreamingMarshaller in org.infinispan.commons.marshall has been deprecated"
 4 = {org.codehaus.plexus.compiler.CompilerMessage} "/home/dan/Work/infinispan/commons/all/src/main/java/org/infinispan/commons/util/ImmutableListCopy.java:[15,38] [deprecation] AdvancedExternalizer in org.infinispan.commons.marshall has been deprecated"
@famod
Copy link
Contributor

famod commented Jul 30, 2021

I think I've just hit the same problem: hibernate-jpamodelgen 5.5.5 fails with StackOverflowError, but nothing to see (except "cannot find symbol" etc.) with <forceJavacCompilerUse>true</forceJavacCompilerUse> for maven-compiler-plugin.
Very dodgy...

mthmulders added a commit to infosupport/plexus-compiler that referenced this issue Nov 29, 2021
mthmulders added a commit to infosupport/plexus-compiler that referenced this issue Feb 8, 2022
mthmulders added a commit to infosupport/plexus-compiler that referenced this issue Feb 8, 2022
@olamy olamy closed this as completed in 0a4563f Feb 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants