RFR: 8292625: jshell crash on "var a = a" [v2]

Jan Lahoda jlahoda at openjdk.org
Mon Nov 21 14:29:09 UTC 2022


On Mon, 21 Nov 2022 14:09:55 GMT, Bo Zhang <duke at openjdk.org> wrote:

>> This commit adds the missing `type` assignment after attributing a variable's initial value. In some cases, this issue causes an NPE.
>> 
>> This issue has existed for a long time, but the NPE was swallowed until https://github.com/openjdk/jdk/commit/433394203dce55db95caefcb57bac9ec114ebc47 stopped swallowing such exceptions.
>
> Bo Zhang has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Remove unnecessary space

Good catch, but I would personally prefer if `attribExpr` would set the type (as it does under normal circumstances), presumably here?

https://github.com/openjdk/jdk/blob/5c3345404d850cf01d9629b48015f1783a32bfc0/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java#L4651

Also, might be nice to have a (core javac) test that would not rely on JShell, if possible.

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

PR: https://git.openjdk.org/jdk/pull/11263


More information about the compiler-dev mailing list