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

Jan Lahoda jlahoda at openjdk.org
Mon Sep 4 07:20:57 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

This pull request has now been integrated.

Changeset: adfc1d6c
Author:    Jan Lahoda <jlahoda at openjdk.org>
URL:       https://git.openjdk.org/jdk/commit/adfc1d6cd29181c729030d4cbafc8ecf349abab9
Stats:     51 lines in 2 files changed: 51 ins; 0 del; 0 mod

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

Reviewed-by: vromero

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

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


More information about the compiler-dev mailing list