RFR: 7194212: NPE in Flow.visitIdent

Jan Lahoda jlahoda at openjdk.java.net
Thu Nov 19 18:30:21 UTC 2020


A somewhat corner-case issue, but consider a case where classfiles for:

public class Outer {
    public class Inner { }
}

Are on a classpath while compiling:

public class Outer$Inner extends Outer { }

This leads to a crash in javac (in Flow), because when Outer is completed, its InnerClasses attribute is read, and, based on it, the flags_field of Outer$Inner is (re)set (and it is put as an nested class to Outer, although that is not correct). But the flags_field used to contain UNATTRIBUTED flag. As this flag is cleared, the method bodies for Outer$Inner are never attributed (its default constructor in this case), which ultimately leads to the crash in Flow.

The proposed patch is to ensure the InnerClasses entry is ignored if we are compiling a same-named class from source. The cost is yet another Flag bit.

-------------

Commit messages:
 - Fixing FlagsTest.
 - 7194212: NPE in Flow.visitIdent

Changes: https://git.openjdk.java.net/jdk/pull/1326/files
 Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=1326&range=00
  Issue: https://bugs.openjdk.java.net/browse/JDK-7194212
  Stats: 116 lines in 6 files changed: 110 ins; 1 del; 5 mod
  Patch: https://git.openjdk.java.net/jdk/pull/1326.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/1326/head:pull/1326

PR: https://git.openjdk.java.net/jdk/pull/1326


More information about the compiler-dev mailing list