Repository navigation
Fix JDK 11 anonymous class bug and unify anonymous class handling - #1909
Merged
wmdietl merged 5 commits intoAug 4, 2026
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a Nullness Checker regression test that targets a JDK 11-specific issue where an annotated anonymous class (new @Nullable Object() {}) is not recognized as anonymous, leading to extra (unexpected) diagnostics.
Changes:
- Add a new Nullness test case covering type-use annotation on an anonymous class creation.
- Expect only the intended
nullness.on.new.objecterror so that JDK 11’s extra diagnostics cause the test to fail (until the framework fix is added).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
wmdietl
approved these changes
Aug 4, 2026
wmdietl
left a comment
Member
There was a problem hiding this comment.
Thanks! I went through this with Antigravity and cleaned up all anonymous class code.
wmdietl
enabled auto-merge (squash)
August 4, 2026 16:05
aosen-xiong
added a commit
to aosen-xiong/checker-framework
that referenced
this pull request
Aug 4, 2026
Replace TypesUtils.isAnonymous(TreeUtils.typeOf(...)) with TreeUtils.isAnonymousClass(ClassTree) in MutabilityNoInitVisitor and MutabilityValidator, following the API unification in eisop#1909 which fixes a JDK 11 anonymous class detection bug.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Found in #1013.
This PR adds a Nullness Checker test that exposes a JDK 11-specific anonymous-class detection bug.
For:
JDK 11 incorrectly reports two additional declaration.inconsistent.with.extends.clause
errors:
@Nullable cannot extend @NonNull@UnknownInitialization cannot extend @InitializedThe problem is that TypesUtils.isAnonymous(TreeUtils.typeOf(classTree)) does not recognize
this annotated anonymous class on JDK 11. Newer JDKs do not produce these diagnostics.
This test-only commit is expected to fail the JDK 11 CI job, confirming the regression
before adding the framework fix.