RFR: 7194212: NPE in Flow.visitIdent

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

RFR: 7194212: NPE in Flow.visitIdent

Jan Lahoda-3
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
Reply | Threaded
Open this post in threaded view
|

Re: RFR: 7194212: NPE in Flow.visitIdent

Vicente Romero-3
On Thu, 19 Nov 2020 18:24:00 GMT, Jan Lahoda <[hidden email]> wrote:

> 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.

looks sensible

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

Marked as reviewed by vromero (Reviewer).

PR: https://git.openjdk.java.net/jdk/pull/1326
Reply | Threaded
Open this post in threaded view
|

Withdrawn: 7194212: NPE in Flow.visitIdent

duke
In reply to this post by Jan Lahoda-3
On Thu, 19 Nov 2020 18:24:00 GMT, Jan Lahoda <[hidden email]> wrote:

> 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.

This pull request has been closed without being integrated.

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

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