RFR: 8313323: javac -g on a java file which uses unnamed variable leads to ClassFormatError when launching that class

Vicente Romero vromero at openjdk.org
Fri Sep 1 17:38:38 UTC 2023


On Mon, 31 Jul 2023 06:52:43 GMT, Jan Lahoda <jlahoda at openjdk.org> wrote:

> When unnamed (`_`) variables are present, and javac emits the `LocalVariableTable` (and potentially the `LocalVariableTypeTable`), it includes the unnamed variable in the table. As the variable does not have a name, the table contains an empty name, which is not allowed by the spec, see [1], [2], [3].
> 
> The proposed solution is to simply not include the unnamed variables in these tables, by not adding them to the internal `Code.varBuffer`.
> 
> [1] https://docs.oracle.com/javase/specs/jvms/se20/html/jvms-4.html#jvms-4.2.2
> [2] https://docs.oracle.com/javase/specs/jvms/se20/html/jvms-4.html#jvms-4.7.13
> [3] https://docs.oracle.com/javase/specs/jvms/se20/html/jvms-4.html#jvms-4.7.14

looks good

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

Marked as reviewed by vromero (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/15083#pullrequestreview-1607394800


More information about the compiler-dev mailing list