JVM's `Type` reported inaccessible after migrating to 2.11.0
- Dominant language
- Java
- Stars
- 7.2k
- Forks
- 820
- Avg merge
- 5h 9m
- Merged PRs (30d)
- 50
Description
I'm writing a custom check by extending `CheckReturnValue` and overriding the `specializedMatcher()` method, so that some unchecked values are allowed.
Here is the bug pattern code:
```java
@AutoService(BugChecker.class)
@BugPattern(
name = "HandleMethodResult",
altNames = {"CheckReturnValue", "ResultOfMethodCallIgnored", "ReturnValueIgnored"},
summary = HandleMethodResult.SUMMARY,
severity = ERROR,
linkType = NONE
)
public final class HandleMethodResult extends CheckReturnValue {
// ...
@Override
public Matcher specializedMatcher() {
var checkReturnValue = super.specializedMatcher();
var notBuilderSetter = not(builderSetter());
return allOf(checkReturnValue, notBuilderSetter);
}
private static Matcher builderSetter() {
return MethodMatchers
.instanceMethod()
.onDescendantOf(Message.Builder.class.getName())
.withNameMatching(ACCESSOR_PREFIX);
}
}
```
With version `2.10.0`, this works just fine. However, with version `2.11.0`, a compilation error occurs at the `onDescendantOf(..)` call:
> class file for com.sun.tools.javac.code.Type not found
I presume, this is related to the fact that `onDescendantOf(..)` has an overload with the `com.sun.tools.javac.code.Type` in the parameter.
I cannot add `--add-exports` flags as the doc suggests, since, it seems, Gradle automatically adds the `--release` flag to the compiler invocation. I don't know if it would help or not.
Is there a reason why this error might occur after the change of the ErrorProne version? If the reason is known, is there a work-around?
I use Gradle 7.3.3, Gradle plugin 2.0.2, and Java 11.
Contributor guide
Assessment
This issue has not been assessed yet.