25 * @test |
25 * @test |
26 * @bug 8144168 8148432 |
26 * @bug 8144168 8148432 |
27 * @summary No type annotations generated for nested lambdas |
27 * @summary No type annotations generated for nested lambdas |
28 * @library /tools/lib |
28 * @library /tools/lib |
29 * @modules jdk.compiler/com.sun.tools.javac.api |
29 * @modules jdk.compiler/com.sun.tools.javac.api |
30 * jdk.compiler/com.sun.tools.javac.file |
|
31 * jdk.compiler/com.sun.tools.javac.main |
30 * jdk.compiler/com.sun.tools.javac.main |
32 * jdk.jdeps/com.sun.tools.javap |
31 * jdk.jdeps/com.sun.tools.javap |
33 * @build ToolBox |
32 * @build toolbox.ToolBox toolbox.JavapTask |
34 * @run compile -g NestedLambdasCastedTest.java |
33 * @run compile -g NestedLambdasCastedTest.java |
35 * @run main NestedLambdasCastedTest |
34 * @run main NestedLambdasCastedTest |
36 */ |
35 */ |
37 |
36 |
38 import java.nio.file.Path; |
37 import java.nio.file.Path; |
39 import java.nio.file.Paths; |
38 import java.nio.file.Paths; |
40 import java.lang.annotation.ElementType; |
39 import java.lang.annotation.ElementType; |
41 import java.lang.annotation.Target; |
40 import java.lang.annotation.Target; |
42 |
41 |
|
42 import toolbox.JavapTask; |
|
43 import toolbox.Task; |
|
44 import toolbox.ToolBox; |
|
45 |
43 public class NestedLambdasCastedTest { |
46 public class NestedLambdasCastedTest { |
44 |
47 |
45 // Expected output can't be directly encoded into NestedLambdasCastedTest !!! |
48 // Expected output can't be directly encoded into NestedLambdasCastedTest !!! |
46 static class ExpectedOutputHolder { |
49 static class ExpectedOutputHolder { |
47 public String [] outputs = { |
50 public String[] outputs = { |
48 "public static strictfp void main(java.lang.String[])", |
51 "public static strictfp void main(java.lang.String[])", |
49 "private static strictfp void lambda$main$3();", |
52 "private static strictfp void lambda$main$3();", |
50 "private static strictfp void lambda$main$2();", |
53 "private static strictfp void lambda$main$2();", |
51 "private static strictfp void lambda$main$1();", |
54 "private static strictfp void lambda$main$1();", |
52 "private static strictfp void lambda$main$0();", |
55 "private static strictfp void lambda$main$0();", |
53 "0: #63(#64=s#65): CAST, offset=5, type_index=0", |
56 "0: #62(#63=s#64): CAST, offset=5, type_index=0", |
54 "0: #63(#64=s#70): CAST, offset=5, type_index=0", |
57 "0: #62(#63=s#69): CAST, offset=5, type_index=0", |
55 "0: #63(#64=s#73): CAST, offset=5, type_index=0", |
58 "0: #62(#63=s#72): CAST, offset=5, type_index=0", |
56 "0: #63(#64=s#76): CAST, offset=5, type_index=0" |
59 "0: #62(#63=s#75): CAST, offset=5, type_index=0" |
57 }; |
60 }; |
58 } |
61 } |
59 |
62 |
60 @Target(ElementType.TYPE_USE) |
63 @Target(ElementType.TYPE_USE) |
61 public @interface TA { |
64 public @interface TA { |
71 }; |
74 }; |
72 }; |
75 }; |
73 }; |
76 }; |
74 ToolBox tb = new ToolBox(); |
77 ToolBox tb = new ToolBox(); |
75 Path classPath = Paths.get(ToolBox.testClasses, "NestedLambdasCastedTest.class"); |
78 Path classPath = Paths.get(ToolBox.testClasses, "NestedLambdasCastedTest.class"); |
76 String javapOut = tb.new JavapTask() |
79 String javapOut = new JavapTask(tb) |
77 .options("-v", "-p") |
80 .options("-v", "-p") |
78 .classes(classPath.toString()) |
81 .classes(classPath.toString()) |
79 .run() |
82 .run() |
80 .getOutput(ToolBox.OutputKind.DIRECT); |
83 .getOutput(Task.OutputKind.DIRECT); |
81 ExpectedOutputHolder holder = new ExpectedOutputHolder(); |
84 ExpectedOutputHolder holder = new ExpectedOutputHolder(); |
82 for (String s : holder.outputs) { |
85 for (String s : holder.outputs) { |
83 if (!javapOut.contains(s)) |
86 if (!javapOut.contains(s)) |
84 throw new AssertionError("Expected type annotation on LOCAL_VARIABLE missing"); |
87 throw new AssertionError("Expected type annotation on LOCAL_VARIABLE missing"); |
85 } |
88 } |