Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Javac Compiler Bug...
Potential bug in JavaC. Surely the line should be:
annotationProcessingOccurred = c.annotationProcessingOccurred == true;
and do a comparison instead of multi-assignment ( and only assign it if annotationProcessingOccurred is current false, as I don't think we want to reassign a true setting to false here).
Open JDK 6:
http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/6-b14/com/sun/tools/javac/main/JavaCompiler.java#JavaCompiler
995 JavaCompiler c = procEnvImpl.doProcessing(context, roots, classSymbols, pckSymbols);
996 if (c != this)
997 annotationProcessingOccurred = c.annotationProcessingOccurred = true;
998 return c;
Open JDK 7
http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/7-b147/com/sun/tools/javac/main/JavaCompiler.java?av=f
1106 JavaCompiler c = procEnvImpl.doProcessing(context, roots, classSymbols, pckSymbols);
1107 if (c != this)
1108 annotationProcessingOccurred = c.annotationProcessingOccurred = true;
1109 // doProcessing will have handled deferred diagnostics
1110 Assert.check(c.log.deferDiagnostics == false
1111 && c.log.deferredDiagnostics.size() == 0);
1112 return c;'

rspilker commented Jun 8, 2012

If what you state is correct the line should either be
annotationProcessingOccurred = c.annotationProcessingOccurred;
or
annotationProcessingOccurred |= c.annotationProcessingOccurred;

Owner

talios commented Jun 8, 2012

The later is my current guess after thinking about it more, of course - I don't know WHY you'd have multiple instances of a javaCompiler so this might not actually be a problem. I have an odd thought that when annotation processing occurs, another javaCompiler instance is possibly created to compile any generated sources, which would mean the code here is probably correct - but kinda smelly code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment