GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — [java] Fix #6932: Handle conflicting inner class visibility modifiers by Scrates1 · Pull Request #6933 · pmd/pmd

Conversation

@Scrates1

@Scrates1 Scrates1 commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

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

  • Fix [java] AssertionError when outer class is parsed before inner class with conflicting visibility #6932
  • Follow-up to [java] AssertionError "this should be unreachable" with scala library #5283 and [java] Fix #5283 - inner class has public private modifiers #5310

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.

All reactions
李涵
[java] Fix pmd#6932 conflicting inner class visibility
a73906d
@pmd-actions-helper

pmd-actions-helper Bot commented Aug 5, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

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)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@adangel adangel changed the title [java] Fix conflicting inner class visibility modifiers [java] Fix #6932: Handle conflicting inner class visibility modifiers Aug 14, 2026
adangel added 2 commits August 14, 2026 15:09
@adangel
Merge remote-tracking branch 'origin/main' into pr-6933
691861b
@adangel
[doc] Update release notes (pmd#6932, pmd#6933)
4276368
adangel
adangel approved these changes Aug 14, 2026
View reviewed changes

@adangel adangel left a comment

Copy link
Copy Markdown
Member

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.

Thanks!

I've finally managed to create a reproducer: https://github.com/adangel/scratchpad/tree/pmd-issue-6932-java-inner-class-public-private - and I could verify that this problem is solved.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread pmd-java/src/main/java/net/sourceforge/pmd/lang/java/symbols/internal/asm/ClassStub.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

@adangel adangel added this to the 7.27.0 milestone Aug 14, 2026
@adangel
adangel merged commit 54c793f into pmd:main Aug 14, 2026
13 checks passed

Uh oh!

There was an error while loading. Please reload this page.

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

Reviewers

@adangel adangel adangel approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

7.27.0

Development

Successfully merging this pull request may close these issues.

[java] AssertionError when outer class is parsed before inner class with conflicting visibility

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@Scrates1 @adangel
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.