Sat, 09 Nov 2013 15:24:38 +0100
8027142: Invokedynamic instructions don't get line number table entries
Summary: When emitting invokedynamic instruction, write pendingStatPos, if set, into the LineNumberTable. Invokedynamic itself does not set the pendingStatPos.
Reviewed-by: jjg, jrose, ksrini, vromero
1.1 --- a/src/share/classes/com/sun/tools/javac/jvm/Code.java Fri Nov 08 17:39:33 2013 -0800 1.2 +++ b/src/share/classes/com/sun/tools/javac/jvm/Code.java Sat Nov 09 15:24:38 2013 +0100 1.3 @@ -483,17 +483,8 @@ 1.4 /** Emit an invokedynamic instruction. 1.5 */ 1.6 public void emitInvokedynamic(int desc, Type mtype) { 1.7 - // N.B. this format is under consideration by the JSR 292 EG 1.8 int argsize = width(mtype.getParameterTypes()); 1.9 - int prevPos = pendingStatPos; 1.10 - try { 1.11 - //disable line number generation (we could have used 'emit1', that 1.12 - //bypasses stackmap generation - which is needed for indy calls) 1.13 - pendingStatPos = Position.NOPOS; 1.14 - emitop(invokedynamic); 1.15 - } finally { 1.16 - pendingStatPos = prevPos; 1.17 - } 1.18 + emitop(invokedynamic); 1.19 if (!alive) return; 1.20 emit2(desc); 1.21 emit2(0);
2.1 --- a/test/tools/javac/T8019486/WrongLNTForLambdaTest.java Fri Nov 08 17:39:33 2013 -0800 2.2 +++ b/test/tools/javac/T8019486/WrongLNTForLambdaTest.java Sat Nov 09 15:24:38 2013 +0100 2.3 @@ -25,7 +25,7 @@ 2.4 2.5 /* 2.6 * @test 2.7 - * @bug 8019486 8026861 2.8 + * @bug 8019486 8026861 8027142 2.9 * @summary javac, generates erroneous LVT for a test case with lambda code 2.10 * @library /tools/javac/lib 2.11 * @build ToolBox 2.12 @@ -68,7 +68,14 @@ 2.13 /* 22 */ " Runnable r4 = super :: notify;\n" + 2.14 /* 23 */ " }\n" + 2.15 /* 24 */ " private void foo() {}\n" + 2.16 - /* 25 */ "}"; 2.17 + /* 25 */ " void assignLambda() {\n" + 2.18 + /* 26 */ " Runnable r = () -> { };\n" + 2.19 + /* 27 */ " }\n" + 2.20 + /* 28 */ " void callLambda(int i, Runnable r) {\n" + 2.21 + /* 29 */ " callLambda(0,\n" + 2.22 + /* 30 */ " () -> { });\n" + 2.23 + /* 31 */ " }\n" + 2.24 + /* 32 */ "}"; 2.25 2.26 static final int[][] simpleLambdaExpectedLNT = { 2.27 // {line-number, start-pc}, 2.28 @@ -102,6 +109,18 @@ 2.29 {22, 0}, //number -> number / 1 2.30 }; 2.31 2.32 + static final int[][] assignmentExpectedLNT = { 2.33 + // {line-number, start-pc}, 2.34 + {26, 0}, //number -> number / 1 2.35 + {27, 6}, //number -> number / 1 2.36 + }; 2.37 + 2.38 + static final int[][] callExpectedLNT = { 2.39 + // {line-number, start-pc}, 2.40 + {29, 0}, //number -> number / 1 2.41 + {31, 10}, //number -> number / 1 2.42 + }; 2.43 + 2.44 public static void main(String[] args) throws Exception { 2.45 new WrongLNTForLambdaTest().run(); 2.46 } 2.47 @@ -120,6 +139,10 @@ 2.48 "Foo.class").toUri()), "$deserializeLambda$", deserializeExpectedLNT); 2.49 checkClassFile(new File(Paths.get(System.getProperty("user.dir"), 2.50 "Foo.class").toUri()), "lambda$MR$variablesInLambdas$notify$8bc4f5bd$1", lambdaBridgeExpectedLNT); 2.51 + checkClassFile(new File(Paths.get(System.getProperty("user.dir"), 2.52 + "Foo.class").toUri()), "assignLambda", assignmentExpectedLNT); 2.53 + checkClassFile(new File(Paths.get(System.getProperty("user.dir"), 2.54 + "Foo.class").toUri()), "callLambda", callExpectedLNT); 2.55 } 2.56 2.57 void compileTestClass() throws Exception {
3.1 --- a/test/tools/javac/lambda/TestInvokeDynamic.java Fri Nov 08 17:39:33 2013 -0800 3.2 +++ b/test/tools/javac/lambda/TestInvokeDynamic.java Sat Nov 09 15:24:38 2013 +0100 3.3 @@ -356,7 +356,7 @@ 3.4 if (lnt == null) { 3.5 throw new Error("No LineNumberTable attribute"); 3.6 } 3.7 - if (lnt.line_number_table_length != 2) { 3.8 + if (lnt.line_number_table_length != 3) { 3.9 throw new Error("Wrong number of entries in LineNumberTable"); 3.10 } 3.11 } catch (Exception e) {