GeezerVison is showing github.com — [java] Fix #6932: Handle conflicting inner class visibility modifiers by Scrates1 · Pull Request #6933 · pmd/pmd
Conversation
Describe the PR
ClassStub#setModifiers combines access flags from the class header (ClassInfo) and one or more InnerClasses entries. The normalization added by #5310 assumed that the class header was parsed before the non-public InnerClasses entry.
PMD's ASM symbols are loaded lazily, so the opposite order is also possible. If the enclosing class is parsed first, a nested class may receive private before its own public class header is parsed. With bytecode observed after Android R8 processing, the nested class also contains a contradictory public self-entry. The old merge accumulated these values into public private; JavaResolvers later treats that state as unreachable and throws an AssertionError.
This PR makes the merge independent of class parsing order:
- Track the source-level visibility from
InnerClasses separately, including package-private (0).
- Do not let a later class header overwrite visibility that already came from
InnerClasses.
- Replace visibility bits instead of OR-ing mutually exclusive values.
- If duplicate
InnerClasses entries disagree, retain the most restrictive visibility. This preserves the non-public precedence established by [java] Fix #5283 - inner class has public private modifiers #5310 and avoids resolving members as more accessible than their metadata allows.
The regression test generates the conflicting inner-class bytecode with ASM, then simulates the enclosing class being parsed first. It contains no third-party binary fixture.
Verification
- Before the fix, the regression fails with
expected: <2> but was: <3> (private vs public private).
mvn -pl pmd-java -am "-Dtest=ClassStubTest" "-Dsurefire.failIfNoSpecifiedTests=false" test — 9 tests passed.
mvn -pl pmd-java -am verify — BUILD SUCCESS for all 7 reactor modules, including the complete pmd-core and pmd-java test suites and quality checks.
Related issues
Ready?
- Added unit tests for fixed bug/feature
- Passing all unit tests
- Complete build
./mvnw clean verify passes (checked automatically by github actions)
- Added (in-code) documentation (if needed)
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
Documentation Preview
Compared to main:
This changeset changes 8 violations,
introduces 0 new violations, 0 new errors and 0 new configuration errors,
removes 0 violations, 0 errors and 0 configuration errors.
There are 0 changed duplications, 0 new duplications and 0 removed duplications.
There are 0 changed CPD errors, 0 new CPD errors and 0 removed CPD errors.
Regression Tester Report
(comment created at 2026-08-14 14:00:26+00:00 for 4276368)
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
adangel
changed the title
[java] Fix conflicting inner class visibility modifiers
[java] Fix #6932: Handle conflicting inner class visibility modifiers
Aug 14, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Reviewers
adangel
adangel approved these changes
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
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.