Possible LVT regression with labelled block statements
Vicente-Arturo Romero-Zaldivar
vicente.romero at oracle.com
Fri Nov 14 03:22:26 UTC 2014
Hi Liam,
Thanks a lot for the report and the reduced test case. I have created
bug: https://bugs.openjdk.java.net/browse/JDK-8064857 to track this issue.
Thanks,
Vicente
On 11/13/2014 07:09 PM, Liam Miller-Cushon wrote:
> I found a possible LVT bug in javac8 that affects labelled break
> statements. It causes incorrect zero-length LVT entries to be emitted
> for locals that have non-zero live ranges.
>
> Here's a repro:
>
> ===
> class Test {
> int m(boolean flag) {
> int myInt;
> label:
> {
> if (flag) {
> myInt = 1;
> } else {
> break label;
> }
>
> return myInt;
> }
> return -1;
> }
> }
> ===
>
> With javac8, the code compiles to:
>
> ===
> int m(boolean);
> descriptor: (Z)I
> flags:
> Code:
> stack=1, locals=3, args_size=2
> 0: iload_1
> 1: ifeq 8
> 4: iconst_1
> 5: istore_2
> 6: iload_2
> 7: ireturn
> 8: iconst_m1
> 9: ireturn
> LineNumberTable:
> line 6: 0
> line 7: 4
> line 12: 6
> line 14: 8
> LocalVariableTable:
> Start Length Slot Name Signature
> 6 0 2 myInt I
> 0 10 0 this LTest;
> 0 10 1 flag Z
> ===
>
> My understanding is that the zero-length LVT entry for 'myInt' is
> incorrect. With earlier versions of javac (and also ecj) the entry's
> length is 2.
>
> The behaviour started occurring after the change that
> fixed JDK-8012868 [1][2], so this affects javac8 and 9. It reproduces
> with the latest version of javac9 (I tested @c286272a81dd).
>
> The issue was originally discovered because it affects joda time,
> specifically the local variable 'expectSeparators' in
> DateTimeFormatterBuilder [3].
>
> [1] http://hg.openjdk.java.net/jdk9/dev/langtools/rev/4932bb04c4b8
> [2] https://bugs.openjdk.java.net/browse/JDK-8012868
> [3]
> https://github.com/JodaOrg/joda-time/blob/1379098f681f0d4d6f0a3403ab6727dc3437b6df/src/main/java/org/joda/time/format/DateTimeFormatterBuilder.java#L2132
>
> Thanks,
> Liam
More information about the compiler-dev
mailing list