author | jbachorik |
Tue, 21 Jan 2014 13:04:55 +0100 | |
changeset 22353 | d09e3ff5fd63 |
parent 20841 | 2b188911d712 |
child 35388 | a33a232cf7b7 |
permissions | -rw-r--r-- |
20841
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
1 |
/* |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
2 |
* Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
4 |
* |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
8 |
* |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
13 |
* accompanied this code). |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
14 |
* |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
18 |
* |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
21 |
* questions. |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
22 |
*/ |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
23 |
|
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
24 |
/* @test |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
25 |
* @bug 8022066 |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
26 |
* @summary smoke test for method handle constants |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
27 |
* @build indify.Indify |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
28 |
* @compile MethodHandleConstants.java |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
29 |
* @run main/othervm |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
30 |
* indify.Indify |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
31 |
* --verify-specifier-count=0 |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
32 |
* --expand-properties --classpath ${test.classes} |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
33 |
* --java test.java.lang.invoke.MethodHandleConstants --check-output |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
34 |
* @run main/othervm |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
35 |
* indify.Indify |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
36 |
* --expand-properties --classpath ${test.classes} |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
37 |
* --java test.java.lang.invoke.MethodHandleConstants --security-manager |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
38 |
*/ |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
39 |
|
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
40 |
package test.java.lang.invoke; |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
41 |
|
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
42 |
import java.util.*; |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
43 |
import java.io.*; |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
44 |
import java.lang.invoke.*; |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
45 |
import java.security.*; |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
46 |
|
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
47 |
import static java.lang.invoke.MethodHandles.*; |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
48 |
import static java.lang.invoke.MethodType.*; |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
49 |
|
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
50 |
public class MethodHandleConstants { |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
51 |
public static void main(String... av) throws Throwable { |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
52 |
if (av.length > 0 && av[0].equals("--check-output")) openBuf(); |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
53 |
if (av.length > 0 && av[0].equals("--security-manager")) setSM(); |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
54 |
System.out.println("Obtaining method handle constants:"); |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
55 |
testCase(MH_String_replace_C2(), String.class, "replace", String.class, String.class, char.class, char.class); |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
56 |
testCase(MH_MethodHandle_invokeExact_SC2(), MethodHandle.class, "invokeExact", String.class, MethodHandle.class, String.class, char.class, char.class); |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
57 |
testCase(MH_MethodHandle_invoke_SC2(), MethodHandle.class, "invoke", String.class, MethodHandle.class, String.class, char.class, char.class); |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
58 |
testCase(MH_Class_forName_S(), Class.class, "forName", Class.class, String.class); |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
59 |
testCase(MH_Class_forName_SbCL(), Class.class, "forName", Class.class, String.class, boolean.class, ClassLoader.class); |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
60 |
System.out.println("Done."); |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
61 |
closeBuf(); |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
62 |
} |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
63 |
|
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
64 |
private static void testCase(MethodHandle mh, Class<?> defc, String name, Class<?> rtype, Class<?>... ptypes) throws Throwable { |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
65 |
System.out.println(mh); |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
66 |
// we include defc, because we assume it is a non-static MH: |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
67 |
MethodType mt = methodType(rtype, ptypes); |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
68 |
assertEquals(mh.type(), mt); |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
69 |
// FIXME: Use revealDirect to find out more |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
70 |
} |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
71 |
private static void assertEquals(Object exp, Object act) { |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
72 |
if (exp == act || (exp != null && exp.equals(act))) return; |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
73 |
throw new AssertionError("not equal: "+exp+", "+act); |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
74 |
} |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
75 |
|
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
76 |
private static void setSM() { |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
77 |
Policy.setPolicy(new TestPolicy()); |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
78 |
System.setSecurityManager(new SecurityManager()); |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
79 |
} |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
80 |
|
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
81 |
private static PrintStream oldOut; |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
82 |
private static ByteArrayOutputStream buf; |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
83 |
private static void openBuf() { |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
84 |
oldOut = System.out; |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
85 |
buf = new ByteArrayOutputStream(); |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
86 |
System.setOut(new PrintStream(buf)); |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
87 |
} |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
88 |
private static void closeBuf() { |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
89 |
if (buf == null) return; |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
90 |
System.out.flush(); |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
91 |
System.setOut(oldOut); |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
92 |
String[] haveLines = new String(buf.toByteArray()).split("[\n\r]+"); |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
93 |
for (String line : haveLines) System.out.println(line); |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
94 |
Iterator<String> iter = Arrays.asList(haveLines).iterator(); |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
95 |
for (String want : EXPECT_OUTPUT) { |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
96 |
String have = iter.hasNext() ? iter.next() : "[EOF]"; |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
97 |
if (want.equals(have)) continue; |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
98 |
System.err.println("want line: "+want); |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
99 |
System.err.println("have line: "+have); |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
100 |
throw new AssertionError("unexpected output: "+have); |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
101 |
} |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
102 |
if (iter.hasNext()) |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
103 |
throw new AssertionError("unexpected output: "+iter.next()); |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
104 |
} |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
105 |
private static final String[] EXPECT_OUTPUT = { |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
106 |
"Obtaining method handle constants:", |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
107 |
"MethodHandle(String,char,char)String", |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
108 |
"MethodHandle(MethodHandle,String,char,char)String", |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
109 |
"MethodHandle(MethodHandle,String,char,char)String", |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
110 |
"MethodHandle(String)Class", |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
111 |
"MethodHandle(String,boolean,ClassLoader)Class", |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
112 |
"Done." |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
113 |
}; |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
114 |
|
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
115 |
// String.replace(String, char, char) |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
116 |
private static MethodType MT_String_replace_C2() { |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
117 |
shouldNotCallThis(); |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
118 |
return methodType(String.class, char.class, char.class); |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
119 |
} |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
120 |
private static MethodHandle MH_String_replace_C2() throws ReflectiveOperationException { |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
121 |
shouldNotCallThis(); |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
122 |
return lookup().findVirtual(String.class, "replace", MT_String_replace_C2()); |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
123 |
} |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
124 |
|
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
125 |
// MethodHandle.invokeExact(...) |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
126 |
private static MethodType MT_MethodHandle_invokeExact_SC2() { |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
127 |
shouldNotCallThis(); |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
128 |
return methodType(String.class, String.class, char.class, char.class); |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
129 |
} |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
130 |
private static MethodHandle MH_MethodHandle_invokeExact_SC2() throws ReflectiveOperationException { |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
131 |
shouldNotCallThis(); |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
132 |
return lookup().findVirtual(MethodHandle.class, "invokeExact", MT_MethodHandle_invokeExact_SC2()); |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
133 |
} |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
134 |
|
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
135 |
// MethodHandle.invoke(...) |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
136 |
private static MethodType MT_MethodHandle_invoke_SC2() { |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
137 |
shouldNotCallThis(); |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
138 |
return methodType(String.class, String.class, char.class, char.class); |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
139 |
} |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
140 |
private static MethodHandle MH_MethodHandle_invoke_SC2() throws ReflectiveOperationException { |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
141 |
shouldNotCallThis(); |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
142 |
return lookup().findVirtual(MethodHandle.class, "invoke", MT_MethodHandle_invoke_SC2()); |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
143 |
} |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
144 |
|
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
145 |
// Class.forName(String) |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
146 |
private static MethodType MT_Class_forName_S() { |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
147 |
shouldNotCallThis(); |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
148 |
return methodType(Class.class, String.class); |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
149 |
} |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
150 |
private static MethodHandle MH_Class_forName_S() throws ReflectiveOperationException { |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
151 |
shouldNotCallThis(); |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
152 |
return lookup().findStatic(Class.class, "forName", MT_Class_forName_S()); |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
153 |
} |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
154 |
|
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
155 |
// Class.forName(String, boolean, ClassLoader) |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
156 |
private static MethodType MT_Class_forName_SbCL() { |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
157 |
shouldNotCallThis(); |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
158 |
return methodType(Class.class, String.class, boolean.class, ClassLoader.class); |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
159 |
} |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
160 |
private static MethodHandle MH_Class_forName_SbCL() throws ReflectiveOperationException { |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
161 |
shouldNotCallThis(); |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
162 |
return lookup().findStatic(Class.class, "forName", MT_Class_forName_SbCL()); |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
163 |
} |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
164 |
|
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
165 |
private static void shouldNotCallThis() { |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
166 |
// if this gets called, the transformation has not taken place |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
167 |
if (System.getProperty("MethodHandleConstants.allow-untransformed") != null) return; |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
168 |
throw new AssertionError("this code should be statically transformed away by Indify"); |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
169 |
} |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
170 |
|
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
171 |
static class TestPolicy extends Policy { |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
172 |
final PermissionCollection permissions = new Permissions(); |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
173 |
TestPolicy() { |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
174 |
permissions.add(new java.io.FilePermission("<<ALL FILES>>", "read")); |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
175 |
} |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
176 |
public PermissionCollection getPermissions(ProtectionDomain domain) { |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
177 |
return permissions; |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
178 |
} |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
179 |
|
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
180 |
public PermissionCollection getPermissions(CodeSource codesource) { |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
181 |
return permissions; |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
182 |
} |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
183 |
|
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
184 |
public boolean implies(ProtectionDomain domain, Permission perm) { |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
185 |
return permissions.implies(perm); |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
186 |
} |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
187 |
} |
2b188911d712
8022066: Evaluation of method reference to signature polymorphic method crashes VM
twisti
parents:
diff
changeset
|
188 |
} |