Thu, 26 Mar 2015 11:34:50 +0100
8054220: Debugger doesn't show variables *outside* lambda
8058227: Debugger has no access to outer variables inside Lambda
Summary: Put local variables captured by lambda into the lambda method's LocalVariableTable.
Reviewed-by: mcimadamore, rfield
1 /*
2 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
24 /**
25 * @test
26 * @bug 8044748
27 * @summary JVM cannot access constructor though ::new reference although can call it directly
28 */
30 public class MethodRefNewInnerBootstrap {
32 interface Constructor {
33 public MyTest execute(int i);
34 }
36 public class MyTest {
37 public MyTest(int i) { System.out.println("Constructor executed " + i); }
38 }
40 public Constructor getConstructor() {
41 return MyTest::new;
42 }
44 public static void main(String argv[]) {
45 new MethodRefNewInnerBootstrap().call();
46 }
48 public void call() {
49 MyTest mt = new MyTest(0);
51 Constructor c1 = MyTest::new;
52 c1.execute(1);
54 Constructor c2 = getConstructor();
55 c2.execute(2);
57 Constructor c3 = new Constructor() {
58 public MyTest execute(int i) {
59 return new MyTest(3);
60 }
61 };
62 c3.execute(3);
64 Constructor c4 = new Constructor() {
65 public MyTest execute(int i) {
66 Constructor c = MyTest::new;
67 return c.execute(i);
68 }
69 };
70 c4.execute(4);
71 }
72 }