105 try {
106 classFile = compile(testFile);
107 } catch (Error err) {
108 System.err.println("fail compile. Source:\n" + srcString);
109 throw err;
110 }
111 }
112 return classFile;
113 }
114
115 static File writeTestFile(String fname, String source) throws IOException {
116 File f = new File(fname);
117 PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(f)));
118 out.println(source);
119 out.close();
120 return f;
121 }
122
123 static File compile(File f) {
124 int rc = com.sun.tools.javac.Main.compile(new String[] {
125 "-source", "1.8", "-g", f.getPath() });
126 if (rc != 0)
127 throw new Error("compilation failed. rc=" + rc);
128 String path = f.getPath();
129 return new File(path.substring(0, path.length() - 5) + ".class");
130 }
131
132 static void debugln(String str) {
133 if(IS_DEBUG)
134 System.out.println(str);
135 }
136
137 enum BSMSpecifier {
138 SPECIFIER1("REF_invokeStatic java/lang/invoke/LambdaMetafactory metaFactory " +
139 "(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;" +
140 "Ljava/lang/invoke/MethodHandle;Ljava/lang/invoke/MethodHandle;Ljava/lang/invoke/MethodType;)" +
141 "Ljava/lang/invoke/CallSite;"),
142 SPECIFIER2("REF_invokeStatic java/lang/invoke/LambdaMetafactory altMetaFactory " +
143 "(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;" +
144 "[Ljava/lang/Object;)Ljava/lang/invoke/CallSite;");
145
|
105 try {
106 classFile = compile(testFile);
107 } catch (Error err) {
108 System.err.println("fail compile. Source:\n" + srcString);
109 throw err;
110 }
111 }
112 return classFile;
113 }
114
115 static File writeTestFile(String fname, String source) throws IOException {
116 File f = new File(fname);
117 PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(f)));
118 out.println(source);
119 out.close();
120 return f;
121 }
122
123 static File compile(File f) {
124 int rc = com.sun.tools.javac.Main.compile(new String[] {
125 "-g", f.getPath() });
126 if (rc != 0)
127 throw new Error("compilation failed. rc=" + rc);
128 String path = f.getPath();
129 return new File(path.substring(0, path.length() - 5) + ".class");
130 }
131
132 static void debugln(String str) {
133 if(IS_DEBUG)
134 System.out.println(str);
135 }
136
137 enum BSMSpecifier {
138 SPECIFIER1("REF_invokeStatic java/lang/invoke/LambdaMetafactory metaFactory " +
139 "(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;" +
140 "Ljava/lang/invoke/MethodHandle;Ljava/lang/invoke/MethodHandle;Ljava/lang/invoke/MethodType;)" +
141 "Ljava/lang/invoke/CallSite;"),
142 SPECIFIER2("REF_invokeStatic java/lang/invoke/LambdaMetafactory altMetaFactory " +
143 "(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;" +
144 "[Ljava/lang/Object;)Ljava/lang/invoke/CallSite;");
145
|