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] AssertionError when outer class is parsed before inner class with conflicting visibility · Issue #6932 · pmd/pmd

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

New issue
Copy link
New issue
Copy link
Closed
#6933
Closed
[java] AssertionError when outer class is parsed before inner class with conflicting visibility#6932
#6933
Copy link
Labels
a:bugPMD crashes or fails to analyse a file.
Milestone
7.27.0

Description

@Scrates1
Scrates1
opened on Aug 5, 2026
Issue body actions

Affected version

  • PMD 7.24.0
  • Current main / 7.27.0-SNAPSHOT at 8c0a935

Description

When PMD loads an Android dependency processed by R8, ClassStub can merge contradictory visibility flags for the same nested class into public private. A later symbol-table accessibility check treats this combination as unreachable and throws an AssertionError, aborting analysis of the source file.

This is related to #5283 and #5310, but exercises the opposite lazy-loading order. The fix in #5310 removes public when a non-public InnerClasses entry is merged after the class header. It does not handle the outer class being parsed first.

In the failing order, calls for one ClassStub are equivalent to:

inner.setModifiers(Opcodes.ACC_PRIVATE, false);                  // outer InnerClasses entry
inner.setModifiers(Opcodes.ACC_PUBLIC | Opcodes.ACC_SUPER, true); // inner ClassInfo
inner.setModifiers(Opcodes.ACC_PUBLIC, false);                   // inner self-entry

The result is 3 (public private) instead of 2 (private).

Minimal bytecode shape

The issue can be reproduced without the original dependency by generating two classes with ASM:

  • Outer.class: public class; its InnerClasses entry declares Outer$Inner private.
  • Outer$Inner.class: public class header; its own InnerClasses entry declares itself public.
  • Resolve/parse Outer before Outer$Inner.

This models the inconsistent but parseable metadata observed in an R8-processed Android AAR. No source-level Java declaration can express the contradictory metadata.

Exception

java.lang.AssertionError: This should be unreachable: private field of an interface? ... modifiers: public private static
    at net.sourceforge.pmd.util.AssertionUtil.shouldNotReachHere(AssertionUtil.java:243)
    at net.sourceforge.pmd.lang.java.symbols.table.internal.JavaResolvers.isAccessible(JavaResolvers.java:479)
    at net.sourceforge.pmd.lang.java.symbols.table.internal.JavaResolvers.processDeclarations(JavaResolvers.java:432)
    at net.sourceforge.pmd.lang.java.symbols.table.internal.JavaResolvers.walkSelf(JavaResolvers.java:409)

Expected behavior

Merging class-header and InnerClasses access flags should be independent of lazy class parsing order and should never retain more than one visibility flag. Consistent with #5310, the non-public InnerClasses visibility should take precedence over ACC_PUBLIC.

pmd.error_recovery=true limits the impact by reporting a processing error and skipping the affected source file, but it is not a complete fix because all PMD rules are then skipped for that file.

Activity

  1. adangel
    added
    a:bugPMD crashes or fails to analyse a file.
    on Aug 14, 2026
  2. adangel commented on Aug 14, 2026

    @adangel
    adangel
    on Aug 14, 2026
    Member
    More actions

    See also

    • https://www.guardsquare.com/manual/configuration/usage#allowaccessmodification
    • https://stackoverflow.com/questions/59681793/r8-changes-protected-methods-of-abstract-class-to-public-without-allowacces
    • https://issuetracker.google.com/issues/147447502
    • https://issuetracker.google.com/issues/144300603

    It seems, the default settings for R8 is, to potentially broaden the access modifiers, resulting in this weird bytecode.

    It might actually be a bug in R8, as there are two contradictory definitions of the inner class...

    Anyway, I agree, that PMD should be able to deal with that.

  3. adangel
    added a commit that references this issue on Aug 14, 2026

    [doc] Update release notes (pmd#6932, pmd#6933)

    4276368
  4. adangel
    added this to the 7.27.0 milestone on Aug 14, 2026
  5. adangel
    closed this as completedin #6933on Aug 14, 2026
  6. UncleOwen
    added a commit that references this issue on Aug 14, 2026

    [java] Fix pmd#6932: Handle conflicting inner class visibility modifi…

    This issue will close once commit 54c793f is merged into the 'main' branch.
    54c793f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    a:bugPMD crashes or fails to analyse a file.

    Type

    No type

    Projects

    No projects

      Milestone

      • 7.27.0

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      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.