test/tools/javac/lambda/LocalVariableTable.java

changeset 2734
ba758e1ffa69
parent 0
959103a6100f
equal deleted inserted replaced
2733:7974f6da2d76 2734:ba758e1ffa69
21 * questions. 21 * questions.
22 */ 22 */
23 23
24 /* 24 /*
25 * @test 25 * @test
26 * @bug 8025998 8026749 26 * @bug 8025998 8026749 8054220 8058227
27 * @summary Missing LV table in lambda bodies 27 * @summary Missing LV table in lambda bodies
28 * @compile -g LocalVariableTable.java 28 * @compile -g LocalVariableTable.java
29 * @run main LocalVariableTable 29 * @run main LocalVariableTable
30 */ 30 */
31 31
181 @Expect({ "a", "x" }) 181 @Expect({ "a", "x" })
182 static class Lambda_Args1_Local1 { 182 static class Lambda_Args1_Local1 {
183 Run1 r = (a) -> { int x = a; }; 183 Run1 r = (a) -> { int x = a; };
184 } 184 }
185 185
186 @Expect({ "a", "x" }) 186 @Expect({ "a", "x", "v" })
187 static class Lambda_Args1_Local1_Captured1 { 187 static class Lambda_Args1_Local1_Captured1 {
188 void m() { 188 void m() {
189 int v = 0; 189 int v = 0;
190 Run1 r = (a) -> { int x = a + v; }; 190 Run1 r = (a) -> { int x = a + v; };
191 } 191 }
192 } 192 }
193 193
194 @Expect({ "a1", "a2", "x1", "x2", "this" }) 194 @Expect({ "a1", "a2", "x1", "x2", "this", "v1", "v2" })
195 static class Lambda_Args2_Local2_Captured2_this { 195 static class Lambda_Args2_Local2_Captured2_this {
196 int v; 196 int v;
197 void m() { 197 void m() {
198 int v1 = 0; 198 int v1 = 0;
199 int v2 = 0; 199 int v2 = 0;
202 int x2 = a2 + v2 + v; 202 int x2 = a2 + v2 + v;
203 }; 203 };
204 } 204 }
205 } 205 }
206 206
207 @Expect({ "e" }) 207 @Expect({ "e", "c" })
208 static class Lambda_Try_Catch { 208 static class Lambda_Try_Catch {
209 private static Runnable asUncheckedRunnable(Closeable c) { 209 private static Runnable asUncheckedRunnable(Closeable c) {
210 return () -> { 210 return () -> {
211 try { 211 try {
212 c.close(); 212 c.close();

mercurial