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

JDK 17: NoSuchMethodError for methods in com.sun.tools.javac.code.Scope that take a com.sun.tools.javac.util.Filter #2330

Closed
cushon opened this issue May 12, 2021 · 0 comments · Fixed by #2337

Comments

@cushon
Copy link
Collaborator

cushon commented May 12, 2021

e.g.

Error:       java.lang.NoSuchMethodError: 'java.lang.Iterable com.sun.tools.javac.code.Scope$WriteableScope.getSymbols(com.sun.tools.javac.util.Filter)'
Error:    	at com.google.errorprone.bugpatterns.threadsafety.ImmutableAnalysis.areFieldsImmutable(ImmutableAnalysis.java:251)
Error:    	at com.google.errorprone.bugpatterns.threadsafety.ImmutableAnalysis.checkForImmutability(ImmutableAnalysis.java:131)
Error:    	at com.google.errorprone.bugpatterns.threadsafety.ImmutableChecker.matchClass(ImmutableChecker.java:225)
Error:    	at com.google.errorprone.scanner.ErrorProneScanner.processMatchers(ErrorProneScanner.java:450)
Error:    	at com.google.errorprone.scanner.ErrorProneScanner.visitClass(ErrorProneScanner.java:548)
Error:    	at com.google.errorprone.scanner.ErrorProneScanner.visitClass(ErrorProneScanner.java:151)
Error:    	at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCClassDecl.accept(JCTree.java:840)
Error:    	at jdk.compiler/com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:86)

openjdk/jdk@657f103 replaces com.sun.tools.javac.util.Filter with Predicate, we may need to wrap the methods in Scope to be compatible with both 17 and previous versions.

I think this affects at least

com/google/errorprone/util/FindIdentifiers
com/google/errorprone/util/ASTHelpers
com/google/errorprone/bugpatterns/ObjectToString
com/google/errorprone/bugpatterns/UnsafeFinalization
com/google/errorprone/bugpatterns/RestrictedApiChecker
com/google/errorprone/bugpatterns/time/PreferJavaTimeOverload
com/google/errorprone/bugpatterns/JavaLangClash
com/google/errorprone/bugpatterns/threadsafety/ImmutableAnalysis
com/google/errorprone/bugpatterns/UnnecessaryMethodReference
copybara-service bot pushed a commit that referenced this issue May 13, 2021
Fixes #2330

PiperOrigin-RevId: 373683703
copybara-service bot pushed a commit that referenced this issue May 14, 2021
Fixes #2330

PiperOrigin-RevId: 373683703
copybara-service bot pushed a commit that referenced this issue Oct 19, 2021
Add a compatibility helper method for `getSymbols(Predicate<Symbol>, LookupKind)`.

**Context:**
In [gradle-baseline](https://github.com/palantir/gradle-baseline#baseline-error-prone-checks), we maintain our own set of error-prone rules and ran into similar JDK 17 compatibility problems as mentioned in #2330.

However for our custom rules, we also need a compatibility helper for `getSymbols(Predicate, LookupKind)`. For now, we work around this by copying parts of the `ErrorProneScope` class (([PR](palantir/gradle-baseline#1936))) but ideally we could reuse the existing helper and wouldn't have to maintain our own fork of this class.

Fixes #2629

COPYBARA_INTEGRATE_REVIEW=#2629 from fawind:fw/get-symbols-lookup-kind e843406
PiperOrigin-RevId: 404111704
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

Successfully merging a pull request may close this issue.

1 participant