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

Fix ImmutablesBuilderMissingInitialization on Java 15 when immutables isn't on the classpath #1507

Merged
merged 3 commits into from
Oct 13, 2020

Conversation

jackwickham
Copy link
Contributor

@jackwickham jackwickham commented Oct 13, 2020

Before this PR

The ImmutablesBuilderMissingInitialization check consistently fails with java 15 (but not <=14) if the immutables annotation jar isn't available on the classpath, such as in tests.

After this PR

==COMMIT_MSG==
Fix ImmutablesBuilderMissingInitialization in java15
==COMMIT_MSG==

This fixes the issue because it now accesses the attributes directly from the AST rather than trying to reflectively instantiate the annotation to access the attributes. I'm not sure why this is java 15 specific...

@changelog-app
Copy link

changelog-app bot commented Oct 13, 2020

Generate changelog in changelog/@unreleased

Type

  • Feature
  • Improvement
  • Fix
  • Break
  • Deprecation
  • Manual task
  • Migration

Description

Fix ImmutablesBuilderMissingInitialization in java15

Check the box to generate changelog(s)

  • Generate changelog entry

@policy-bot policy-bot bot requested a review from dansanduleac October 13, 2020 10:13
@fawind
Copy link
Contributor

fawind commented Oct 13, 2020

Curious why this only fails on java 15. Do you have a stacktrace you can share here?

@jackwickham
Copy link
Contributor Author

jackwickham commented Oct 13, 2020

The stack trace that shows up in circle is

An exception has occurred in the compiler (15). Please file a bug against the Java compiler via the Java bug reporting page (http://bugreport.java.com) after checking the Bug Database (http://bugs.java.com) for duplicates. Include your program, the following diagnostic, and the parameters passed to the Java compiler in your report. Thank you.
java.lang.NoSuchMethodError: 'java.lang.Object com.sun.tools.javac.code.Symbol$CompletionFailure.getDetailValue()'
	at com.google.errorprone.ErrorProneAnalyzer.finished(ErrorProneAnalyzer.java:171)
	at jdk.compiler/com.sun.tools.javac.api.MultiTaskListener.finished(MultiTaskListener.java:132)
	at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.flow(JavaCompiler.java:1421)
	at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.flow(JavaCompiler.java:1368)
	at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:960)
	at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.lambda$doCall$0(JavacTaskImpl.java:104)
	at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.handleExceptions(JavacTaskImpl.java:147)
	at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.doCall(JavacTaskImpl.java:100)
	at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:94)
	at org.gradle.internal.compiler.java.IncrementalCompileTask.call(IncrementalCompileTask.java:74)
	at org.gradle.api.internal.tasks.compile.AnnotationProcessingCompileTask.call(AnnotationProcessingCompileTask.java:94)
	at org.gradle.api.internal.tasks.compile.ResourceCleaningCompilationTask.call(ResourceCleaningCompilationTask.java:57)

but that's actually an exception while handling the other exception (I've not figured that one out but it happens in all JDKs under the right conditions and is either a JDK or Errorprone issue).

The actual root cause exception is a Symbol.CompletionException with message class file for org.immutables.value.Generated not found - I don't have a stack trace for it, but it's coming from com.sun.tools.javac.code.Symbol when trying to instantiate the annotation, in theory because that annotation isn't available at runtime.

Copy link
Contributor

@fawind fawind left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for providing the context. I'm also not sure why this is j15 specific but happy to get the fix out!

@jackwickham jackwickham merged commit f9a2458 into develop Oct 13, 2020
@svc-autorelease
Copy link
Collaborator

Released 3.40.1

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

Successfully merging this pull request may close these issues.

3 participants