Repository navigation
Description
Affected version
- PMD 7.24.0
- Current
main/ 7.27.0-SNAPSHOT at8c0a935
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-entryThe 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; itsInnerClassesentry declaresOuter$Innerprivate.Outer$Inner.class: public class header; its ownInnerClassesentry declares itself public.- Resolve/parse
OuterbeforeOuter$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
adangel commentedon Aug 14, 2026
See also
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.
[doc] Update release notes (pmd#6932, pmd#6933)
[java] Fix pmd#6932: Handle conflicting inner class visibility modifi…