author | hannesw |
Tue, 22 Mar 2016 14:23:16 +0100 | |
changeset 36690 | 06b714373aa4 |
parent 32337 | c9d3ab9f601c |
child 36526 | 3b41f1c69604 |
permissions | -rw-r--r-- |
21496
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
1 |
/* |
30730
d3ce7619db2c
8076543: Add @modules as needed to the langtools tests
akulyakh
parents:
26100
diff
changeset
|
2 |
* Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved. |
21496
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
4 |
* |
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
32337 | 7 |
* published by the Free Software Foundation. |
21496
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
8 |
* |
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
13 |
* accompanied this code). |
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
14 |
* |
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
18 |
* |
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
21 |
* questions. |
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
22 |
*/ |
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
23 |
|
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
24 |
/* |
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
25 |
* @test |
21711
1118b43b5111
8027142: Invokedynamic instructions don't get line number table entries
jlahoda
parents:
21496
diff
changeset
|
26 |
* @bug 8019486 8026861 8027142 |
21496
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
27 |
* @summary javac, generates erroneous LVT for a test case with lambda code |
26100 | 28 |
* @library /tools/lib |
30846 | 29 |
* @modules jdk.jdeps/com.sun.tools.classfile |
30730
d3ce7619db2c
8076543: Add @modules as needed to the langtools tests
akulyakh
parents:
26100
diff
changeset
|
30 |
* jdk.compiler/com.sun.tools.javac.api |
d3ce7619db2c
8076543: Add @modules as needed to the langtools tests
akulyakh
parents:
26100
diff
changeset
|
31 |
* jdk.compiler/com.sun.tools.javac.file |
d3ce7619db2c
8076543: Add @modules as needed to the langtools tests
akulyakh
parents:
26100
diff
changeset
|
32 |
* jdk.compiler/com.sun.tools.javac.main |
d3ce7619db2c
8076543: Add @modules as needed to the langtools tests
akulyakh
parents:
26100
diff
changeset
|
33 |
* jdk.compiler/com.sun.tools.javac.util |
21496
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
34 |
* @build ToolBox |
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
35 |
* @run main WrongLNTForLambdaTest |
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
36 |
*/ |
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
37 |
|
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
38 |
import java.io.File; |
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
39 |
import java.nio.file.Paths; |
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
40 |
|
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
41 |
import com.sun.tools.classfile.ClassFile; |
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
42 |
import com.sun.tools.classfile.Code_attribute; |
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
43 |
import com.sun.tools.classfile.LineNumberTable_attribute; |
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
44 |
import com.sun.tools.classfile.Method; |
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
45 |
import com.sun.tools.javac.util.Assert; |
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
46 |
|
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
47 |
public class WrongLNTForLambdaTest { |
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
48 |
|
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
49 |
static final String testSource = |
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
50 |
/* 01 */ "import java.util.List;\n" + |
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
51 |
/* 02 */ "import java.util.Arrays;\n" + |
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
52 |
/* 03 */ "import java.util.stream.Collectors;\n" + |
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
53 |
/* 04 */ "\n" + |
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
54 |
/* 05 */ "public class Foo {\n" + |
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
55 |
/* 06 */ " void bar(int value) {\n" + |
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
56 |
/* 07 */ " final List<Integer> numbers = Arrays.asList(1, 2, 3);\n" + |
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
57 |
/* 08 */ " final List<Integer> numbersPlusOne = \n" + |
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
58 |
/* 09 */ " numbers.stream().map(number -> number / 1).collect(Collectors.toList());\n" + |
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
59 |
/* 10 */ " }\n" + |
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
60 |
/* 11 */ " void variablesInLambdas(int value) {\n" + |
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
61 |
/* 12 */ " Runnable r1 = () -> {\n" + |
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
62 |
/* 13 */ " int i = value;\n" + |
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
63 |
/* 14 */ " class FooBar<T extends CharSequence> {\n" + |
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
64 |
/* 15 */ " public void run() {\n" + |
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
65 |
/* 16 */ " T t = null;\n" + |
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
66 |
/* 17 */ " }\n" + |
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
67 |
/* 18 */ " }\n" + |
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
68 |
/* 19 */ " };\n" + |
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
69 |
/* 20 */ " Runnable r2 = () -> System.err.println(1);\n" + |
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
70 |
/* 21 */ " Runnable r3 = (Runnable & java.io.Serializable) this::foo;\n" + |
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
71 |
/* 22 */ " Runnable r4 = super :: notify;\n" + |
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
72 |
/* 23 */ " }\n" + |
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
73 |
/* 24 */ " private void foo() {}\n" + |
21711
1118b43b5111
8027142: Invokedynamic instructions don't get line number table entries
jlahoda
parents:
21496
diff
changeset
|
74 |
/* 25 */ " void assignLambda() {\n" + |
1118b43b5111
8027142: Invokedynamic instructions don't get line number table entries
jlahoda
parents:
21496
diff
changeset
|
75 |
/* 26 */ " Runnable r = () -> { };\n" + |
1118b43b5111
8027142: Invokedynamic instructions don't get line number table entries
jlahoda
parents:
21496
diff
changeset
|
76 |
/* 27 */ " }\n" + |
1118b43b5111
8027142: Invokedynamic instructions don't get line number table entries
jlahoda
parents:
21496
diff
changeset
|
77 |
/* 28 */ " void callLambda(int i, Runnable r) {\n" + |
1118b43b5111
8027142: Invokedynamic instructions don't get line number table entries
jlahoda
parents:
21496
diff
changeset
|
78 |
/* 29 */ " callLambda(0,\n" + |
1118b43b5111
8027142: Invokedynamic instructions don't get line number table entries
jlahoda
parents:
21496
diff
changeset
|
79 |
/* 30 */ " () -> { });\n" + |
1118b43b5111
8027142: Invokedynamic instructions don't get line number table entries
jlahoda
parents:
21496
diff
changeset
|
80 |
/* 31 */ " }\n" + |
1118b43b5111
8027142: Invokedynamic instructions don't get line number table entries
jlahoda
parents:
21496
diff
changeset
|
81 |
/* 32 */ "}"; |
21496
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
82 |
|
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
83 |
static final int[][] simpleLambdaExpectedLNT = { |
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
84 |
// {line-number, start-pc}, |
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
85 |
{9, 0}, //number -> number / 1 |
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
86 |
}; |
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
87 |
|
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
88 |
static final int[][] lambdaWithVarsExpectedLNT = { |
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
89 |
// {line-number, start-pc}, |
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
90 |
{13, 0}, //number -> number / 1 |
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
91 |
{19, 2}, //number -> number / 1 |
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
92 |
}; |
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
93 |
|
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
94 |
static final int[][] insideLambdaWithVarsExpectedLNT = { |
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
95 |
// {line-number, start-pc}, |
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
96 |
{16, 0}, //number -> number / 1 |
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
97 |
{17, 2}, //number -> number / 1 |
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
98 |
}; |
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
99 |
|
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
100 |
static final int[][] lambdaVoid2VoidExpectedLNT = { |
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
101 |
// {line-number, start-pc}, |
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
102 |
{20, 0}, //number -> number / 1 |
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
103 |
}; |
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
104 |
|
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
105 |
static final int[][] deserializeExpectedLNT = { |
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
106 |
// {line-number, start-pc}, |
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
107 |
{05, 0}, //number -> number / 1 |
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
108 |
}; |
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
109 |
|
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
110 |
static final int[][] lambdaBridgeExpectedLNT = { |
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
111 |
// {line-number, start-pc}, |
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
112 |
{22, 0}, //number -> number / 1 |
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
113 |
}; |
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
114 |
|
21711
1118b43b5111
8027142: Invokedynamic instructions don't get line number table entries
jlahoda
parents:
21496
diff
changeset
|
115 |
static final int[][] assignmentExpectedLNT = { |
1118b43b5111
8027142: Invokedynamic instructions don't get line number table entries
jlahoda
parents:
21496
diff
changeset
|
116 |
// {line-number, start-pc}, |
1118b43b5111
8027142: Invokedynamic instructions don't get line number table entries
jlahoda
parents:
21496
diff
changeset
|
117 |
{26, 0}, //number -> number / 1 |
1118b43b5111
8027142: Invokedynamic instructions don't get line number table entries
jlahoda
parents:
21496
diff
changeset
|
118 |
{27, 6}, //number -> number / 1 |
1118b43b5111
8027142: Invokedynamic instructions don't get line number table entries
jlahoda
parents:
21496
diff
changeset
|
119 |
}; |
1118b43b5111
8027142: Invokedynamic instructions don't get line number table entries
jlahoda
parents:
21496
diff
changeset
|
120 |
|
1118b43b5111
8027142: Invokedynamic instructions don't get line number table entries
jlahoda
parents:
21496
diff
changeset
|
121 |
static final int[][] callExpectedLNT = { |
1118b43b5111
8027142: Invokedynamic instructions don't get line number table entries
jlahoda
parents:
21496
diff
changeset
|
122 |
// {line-number, start-pc}, |
1118b43b5111
8027142: Invokedynamic instructions don't get line number table entries
jlahoda
parents:
21496
diff
changeset
|
123 |
{29, 0}, //number -> number / 1 |
1118b43b5111
8027142: Invokedynamic instructions don't get line number table entries
jlahoda
parents:
21496
diff
changeset
|
124 |
{31, 10}, //number -> number / 1 |
1118b43b5111
8027142: Invokedynamic instructions don't get line number table entries
jlahoda
parents:
21496
diff
changeset
|
125 |
}; |
1118b43b5111
8027142: Invokedynamic instructions don't get line number table entries
jlahoda
parents:
21496
diff
changeset
|
126 |
|
21496
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
127 |
public static void main(String[] args) throws Exception { |
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
128 |
new WrongLNTForLambdaTest().run(); |
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
129 |
} |
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
130 |
|
26100 | 131 |
ToolBox tb = new ToolBox(); |
132 |
||
21496
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
133 |
void run() throws Exception { |
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
134 |
compileTestClass(); |
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
135 |
checkClassFile(new File(Paths.get(System.getProperty("user.dir"), |
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
136 |
"Foo.class").toUri()), "lambda$bar$0", simpleLambdaExpectedLNT); |
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
137 |
checkClassFile(new File(Paths.get(System.getProperty("user.dir"), |
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
138 |
"Foo.class").toUri()), "lambda$variablesInLambdas$1", lambdaWithVarsExpectedLNT); |
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
139 |
checkClassFile(new File(Paths.get(System.getProperty("user.dir"), |
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
140 |
"Foo$1FooBar.class").toUri()), "run", insideLambdaWithVarsExpectedLNT); |
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
141 |
checkClassFile(new File(Paths.get(System.getProperty("user.dir"), |
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
142 |
"Foo.class").toUri()), "lambda$variablesInLambdas$2", lambdaVoid2VoidExpectedLNT); |
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
143 |
checkClassFile(new File(Paths.get(System.getProperty("user.dir"), |
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
144 |
"Foo.class").toUri()), "$deserializeLambda$", deserializeExpectedLNT); |
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
145 |
checkClassFile(new File(Paths.get(System.getProperty("user.dir"), |
25281
0babd05cbcd3
8037404: javac NPE or VerifyError for code with constructor reference of inner class
rfield
parents:
21711
diff
changeset
|
146 |
"Foo.class").toUri()), "lambda$variablesInLambdas$3", lambdaBridgeExpectedLNT); |
21711
1118b43b5111
8027142: Invokedynamic instructions don't get line number table entries
jlahoda
parents:
21496
diff
changeset
|
147 |
checkClassFile(new File(Paths.get(System.getProperty("user.dir"), |
1118b43b5111
8027142: Invokedynamic instructions don't get line number table entries
jlahoda
parents:
21496
diff
changeset
|
148 |
"Foo.class").toUri()), "assignLambda", assignmentExpectedLNT); |
1118b43b5111
8027142: Invokedynamic instructions don't get line number table entries
jlahoda
parents:
21496
diff
changeset
|
149 |
checkClassFile(new File(Paths.get(System.getProperty("user.dir"), |
1118b43b5111
8027142: Invokedynamic instructions don't get line number table entries
jlahoda
parents:
21496
diff
changeset
|
150 |
"Foo.class").toUri()), "callLambda", callExpectedLNT); |
21496
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
151 |
} |
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
152 |
|
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
153 |
void compileTestClass() throws Exception { |
26100 | 154 |
tb.new JavacTask() |
155 |
.sources(testSource) |
|
156 |
.run(); |
|
21496
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
157 |
} |
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
158 |
|
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
159 |
void checkClassFile(final File cfile, String methodToFind, int[][] expectedLNT) throws Exception { |
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
160 |
ClassFile classFile = ClassFile.read(cfile); |
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
161 |
boolean methodFound = false; |
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
162 |
for (Method method : classFile.methods) { |
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
163 |
if (method.getName(classFile.constant_pool).equals(methodToFind)) { |
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
164 |
methodFound = true; |
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
165 |
Code_attribute code = (Code_attribute) method.attributes.get("Code"); |
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
166 |
LineNumberTable_attribute lnt = |
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
167 |
(LineNumberTable_attribute) code.attributes.get("LineNumberTable"); |
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
168 |
Assert.check(lnt.line_number_table_length == expectedLNT.length, |
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
169 |
"The LineNumberTable found has a length different to the expected one"); |
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
170 |
int i = 0; |
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
171 |
for (LineNumberTable_attribute.Entry entry: lnt.line_number_table) { |
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
172 |
Assert.check(entry.line_number == expectedLNT[i][0] && |
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
173 |
entry.start_pc == expectedLNT[i][1], |
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
174 |
"LNT entry at pos " + i + " differ from expected." + |
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
175 |
"Found " + entry.line_number + ":" + entry.start_pc + |
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
176 |
". Expected " + expectedLNT[i][0] + ":" + expectedLNT[i][1]); |
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
177 |
i++; |
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
178 |
} |
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
179 |
} |
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
180 |
} |
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
181 |
Assert.check(methodFound, "The seek method was not found"); |
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
182 |
} |
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
183 |
|
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
184 |
void error(String msg) { |
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
185 |
throw new AssertionError(msg); |
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
186 |
} |
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
187 |
|
2eb1bb11add1
8026861: Wrong LineNumberTable for variable declarations in lambdas
jlahoda
parents:
diff
changeset
|
188 |
} |