RFR: 8164714: Constructor.newInstance creates instance of inner class with null outer class [v4]

Chen Liang liach at openjdk.org
Fri Mar 21 20:49:13 UTC 2025


On Fri, 21 Mar 2025 12:34:01 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:

>> Chen Liang has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains seven additional commits since the last revision:
>> 
>>  - Better docs
>>  - Merge branch 'master' of https://github.com/openjdk/jdk into fix/enclosing-this-null-check
>>  - Emit null check by flag/release
>>  - Merge branch 'master' of https://github.com/openjdk/jdk into fix/enclosing-this-null-check
>>  - Merge branch 'master' of https://github.com/openjdk/jdk into fix/enclosing-this-null-check
>>  - Fix javap test
>>  - 8164714: Constructor.newInstance creates instance of inner class with null outer class
>
> src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Lower.java line 1820:
> 
>> 1818:                     sourceExp).setType(lhs.erasure(types));
>> 1819:         } else {
>> 1820:             Assert.check(nullCheckOuterThis);
> 
> This code seems repeated twice. Perhaps you could first create the expression (which could be null checked or not) and then use that expression to store in the `this$0` field (if needed).

Thanks for the comment. Done.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/23875#discussion_r2008310912


More information about the compiler-dev mailing list