Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/jdk17u
Path: blob/master/test/jdk/java/lang/constant/MethodHandleDescTest.java
66644 views
1
/*
2
* Copyright (c) 2018, 2019, 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
*/
23
24
import java.lang.invoke.MethodHandle;
25
import java.lang.invoke.MethodHandleInfo;
26
import java.lang.invoke.MethodHandles;
27
import java.lang.invoke.MethodType;
28
import java.lang.invoke.WrongMethodTypeException;
29
import java.lang.constant.ClassDesc;
30
import java.lang.constant.ConstantDescs;
31
import java.lang.constant.DirectMethodHandleDesc;
32
import java.lang.constant.MethodHandleDesc;
33
import java.lang.reflect.Field;
34
import java.lang.reflect.Modifier;
35
import java.lang.constant.MethodTypeDesc;
36
import java.util.ArrayList;
37
import java.util.List;
38
import java.util.function.Supplier;
39
40
import org.testng.annotations.Test;
41
42
import static java.lang.constant.ConstantDescs.CD_Void;
43
import static java.lang.constant.ConstantDescs.CD_boolean;
44
import static java.lang.constant.DirectMethodHandleDesc.*;
45
import static java.lang.constant.DirectMethodHandleDesc.Kind.GETTER;
46
import static java.lang.constant.DirectMethodHandleDesc.Kind.SETTER;
47
import static java.lang.constant.DirectMethodHandleDesc.Kind.STATIC_GETTER;
48
import static java.lang.constant.DirectMethodHandleDesc.Kind.STATIC_SETTER;
49
import static java.lang.constant.DirectMethodHandleDesc.Kind.VIRTUAL;
50
import static java.lang.constant.ConstantDescs.CD_Integer;
51
import static java.lang.constant.ConstantDescs.CD_List;
52
import static java.lang.constant.ConstantDescs.CD_Object;
53
import static java.lang.constant.ConstantDescs.CD_String;
54
import static java.lang.constant.ConstantDescs.CD_int;
55
import static java.lang.constant.ConstantDescs.CD_void;
56
import static java.lang.invoke.MethodHandleInfo.*;
57
import static org.testng.Assert.assertEquals;
58
import static org.testng.Assert.assertNotEquals;
59
import static org.testng.Assert.assertNotSame;
60
import static org.testng.Assert.assertSame;
61
import static org.testng.Assert.assertTrue;
62
import static org.testng.Assert.fail;
63
64
/**
65
* @test
66
* @compile MethodHandleDescTest.java
67
* @run testng MethodHandleDescTest
68
* @summary unit tests for java.lang.constant.MethodHandleDesc
69
*/
70
@Test
71
public class MethodHandleDescTest extends SymbolicDescTest {
72
private static ClassDesc helperHolderClass = ClassDesc.of("TestHelpers");
73
private static ClassDesc testClass = helperHolderClass.nested("TestClass");
74
private static ClassDesc testInterface = helperHolderClass.nested("TestInterface");
75
private static ClassDesc testSuperclass = helperHolderClass.nested("TestSuperclass");
76
77
78
private static void assertMHEquals(MethodHandle a, MethodHandle b) {
79
MethodHandleInfo ia = LOOKUP.revealDirect(a);
80
MethodHandleInfo ib = LOOKUP.revealDirect(b);
81
assertEquals(ia.getDeclaringClass(), ib.getDeclaringClass());
82
assertEquals(ia.getName(), ib.getName());
83
assertEquals(ia.getMethodType(), ib.getMethodType());
84
assertEquals(ia.getReferenceKind(), ib.getReferenceKind());
85
}
86
87
private void testMethodHandleDesc(MethodHandleDesc r) throws ReflectiveOperationException {
88
if (r instanceof DirectMethodHandleDesc) {
89
testSymbolicDesc(r);
90
91
DirectMethodHandleDesc rr = (DirectMethodHandleDesc) r;
92
assertEquals(r, MethodHandleDesc.of(rr.kind(), rr.owner(), rr.methodName(), rr.lookupDescriptor()));
93
assertEquals(r.invocationType().resolveConstantDesc(LOOKUP), ((MethodHandle) r.resolveConstantDesc(LOOKUP)).type());
94
}
95
else {
96
testSymbolicDescForwardOnly(r);
97
}
98
}
99
100
private String lookupDescriptor(DirectMethodHandleDesc rr) {
101
switch (rr.kind()) {
102
case VIRTUAL:
103
case SPECIAL:
104
case INTERFACE_VIRTUAL:
105
case INTERFACE_SPECIAL:
106
return rr.invocationType().dropParameterTypes(0, 1).descriptorString();
107
case CONSTRUCTOR:
108
return rr.invocationType().changeReturnType(CD_void).descriptorString();
109
default:
110
return rr.invocationType().descriptorString();
111
}
112
}
113
114
private void testMethodHandleDesc(MethodHandleDesc r, MethodHandle mh) throws ReflectiveOperationException {
115
testMethodHandleDesc(r);
116
117
assertMHEquals(((MethodHandle) r.resolveConstantDesc(LOOKUP)), mh);
118
assertEquals(mh.describeConstable().orElseThrow(), r);
119
120
// compare extractable properties: refKind, owner, name, type
121
MethodHandleInfo mhi = LOOKUP.revealDirect(mh);
122
DirectMethodHandleDesc rr = (DirectMethodHandleDesc) r;
123
assertEquals(mhi.getDeclaringClass().descriptorString(), rr.owner().descriptorString());
124
assertEquals(mhi.getName(), rr.methodName());
125
assertEquals(mhi.getReferenceKind(), rr.kind().refKind);
126
MethodType type = mhi.getMethodType();
127
assertEquals(type.toMethodDescriptorString(), lookupDescriptor(rr));
128
}
129
130
public void testSimpleMHs() throws ReflectiveOperationException {
131
MethodHandle MH_String_isEmpty = LOOKUP.findVirtual(String.class, "isEmpty", MethodType.fromMethodDescriptorString("()Z", null));
132
testMethodHandleDesc(MethodHandleDesc.of(Kind.VIRTUAL, CD_String, "isEmpty", "()Z"), MH_String_isEmpty);
133
testMethodHandleDesc(MethodHandleDesc.ofMethod(Kind.VIRTUAL, CD_String, "isEmpty", MethodTypeDesc.of(CD_boolean)), MH_String_isEmpty);
134
135
MethodHandle MH_List_isEmpty = LOOKUP.findVirtual(List.class, "isEmpty", MethodType.fromMethodDescriptorString("()Z", null));
136
testMethodHandleDesc(MethodHandleDesc.of(Kind.INTERFACE_VIRTUAL, CD_List, "isEmpty", "()Z"), MH_List_isEmpty);
137
testMethodHandleDesc(MethodHandleDesc.ofMethod(Kind.INTERFACE_VIRTUAL, CD_List, "isEmpty", MethodTypeDesc.of(CD_boolean)), MH_List_isEmpty);
138
139
MethodHandle MH_String_format = LOOKUP.findStatic(String.class, "format", MethodType.methodType(String.class, String.class, Object[].class));
140
testMethodHandleDesc(MethodHandleDesc.of(Kind.STATIC, CD_String, "format", MethodType.methodType(String.class, String.class, Object[].class).descriptorString()),
141
MH_String_format);
142
testMethodHandleDesc(MethodHandleDesc.ofMethod(Kind.STATIC, CD_String, "format", MethodTypeDesc.of(CD_String, CD_String, CD_Object.arrayType())),
143
MH_String_format);
144
145
MethodHandle MH_ArrayList_new = LOOKUP.findConstructor(ArrayList.class, MethodType.methodType(void.class));
146
testMethodHandleDesc(MethodHandleDesc.ofMethod(Kind.CONSTRUCTOR, ClassDesc.of("java.util.ArrayList"), "<init>", MethodTypeDesc.of(CD_void)),
147
MH_ArrayList_new);
148
testMethodHandleDesc(MethodHandleDesc.ofConstructor(ClassDesc.of("java.util.ArrayList")), MH_ArrayList_new);
149
150
// bad constructor non void return type
151
try {
152
MethodHandleDesc.of(Kind.CONSTRUCTOR, ClassDesc.of("java.util.ArrayList"), "<init>", "()I");
153
fail("should have failed: non void return type for constructor");
154
} catch (IllegalArgumentException ex) {
155
// good
156
}
157
158
// null list of parameters
159
try {
160
MethodHandleDesc.ofConstructor(ClassDesc.of("java.util.ArrayList", null));
161
fail("should have failed: null list of parameters");
162
} catch (NullPointerException ex) {
163
// good
164
}
165
166
// null elements in list of parameters
167
try {
168
ClassDesc[] paramList = new ClassDesc[1];
169
paramList[0] = null;
170
MethodHandleDesc.ofConstructor(ClassDesc.of("java.util.ArrayList"), paramList);
171
fail("should have failed: null content in list of parameters");
172
} catch (NullPointerException ex) {
173
// good
174
}
175
}
176
177
public void testAsType() throws Throwable {
178
MethodHandleDesc mhr = MethodHandleDesc.ofMethod(Kind.STATIC, ClassDesc.of("java.lang.Integer"), "valueOf",
179
MethodTypeDesc.of(CD_Integer, CD_int));
180
MethodHandleDesc takesInteger = mhr.asType(MethodTypeDesc.of(CD_Integer, CD_Integer));
181
testMethodHandleDesc(takesInteger);
182
MethodHandle mh1 = (MethodHandle) takesInteger.resolveConstantDesc(LOOKUP);
183
assertEquals((Integer) 3, (Integer) mh1.invokeExact((Integer) 3));
184
assertEquals(takesInteger.toString(), "MethodHandleDesc[STATIC/Integer::valueOf(int)Integer].asType(Integer)Integer");
185
186
try {
187
Integer i = (Integer) mh1.invokeExact(3);
188
fail("Expected WMTE");
189
}
190
catch (WrongMethodTypeException ignored) { }
191
192
MethodHandleDesc takesInt = takesInteger.asType(MethodTypeDesc.of(CD_Integer, CD_int));
193
testMethodHandleDesc(takesInt);
194
MethodHandle mh2 = (MethodHandle) takesInt.resolveConstantDesc(LOOKUP);
195
assertEquals((Integer) 3, (Integer) mh2.invokeExact(3));
196
197
try {
198
Integer i = (Integer) mh2.invokeExact((Integer) 3);
199
fail("Expected WMTE");
200
}
201
catch (WrongMethodTypeException ignored) { }
202
203
// Short circuit optimization
204
MethodHandleDesc same = mhr.asType(mhr.invocationType());
205
assertSame(mhr, same);
206
207
try {
208
mhr.asType(null);
209
fail("Expected NPE");
210
} catch (NullPointerException ex) {
211
// good
212
}
213
214
// @@@ Test varargs adaptation
215
// @@@ Test bad adaptations and assert runtime error on resolution
216
// @@@ Test intrinsification of adapted MH
217
}
218
219
public void testMethodHandleDesc() throws Throwable {
220
MethodHandleDesc ctorDesc = MethodHandleDesc.of(Kind.CONSTRUCTOR, testClass, "<ignored!>", "()V");
221
MethodHandleDesc staticMethodDesc = MethodHandleDesc.of(Kind.STATIC, testClass, "sm", "(I)I");
222
MethodHandleDesc staticIMethodDesc = MethodHandleDesc.of(Kind.INTERFACE_STATIC, testInterface, "sm", "(I)I");
223
MethodHandleDesc instanceMethodDesc = MethodHandleDesc.of(Kind.VIRTUAL, testClass, "m", "(I)I");
224
MethodHandleDesc instanceIMethodDesc = MethodHandleDesc.of(Kind.INTERFACE_VIRTUAL, testInterface, "m", "(I)I");
225
MethodHandleDesc superMethodDesc = MethodHandleDesc.of(Kind.SPECIAL, testSuperclass, "m", "(I)I");
226
MethodHandleDesc superIMethodDesc = MethodHandleDesc.of(Kind.INTERFACE_SPECIAL, testInterface, "m", "(I)I");
227
MethodHandleDesc privateMethodDesc = MethodHandleDesc.of(Kind.SPECIAL, testClass, "pm", "(I)I");
228
MethodHandleDesc privateIMethodDesc = MethodHandleDesc.of(Kind.INTERFACE_SPECIAL, testInterface, "pm", "(I)I");
229
MethodHandleDesc privateStaticMethodDesc = MethodHandleDesc.of(Kind.STATIC, testClass, "psm", "(I)I");
230
MethodHandleDesc privateStaticIMethodDesc = MethodHandleDesc.of(Kind.INTERFACE_STATIC, testInterface, "psm", "(I)I");
231
232
assertEquals(ctorDesc.invocationType(), MethodTypeDesc.of(testClass));
233
assertEquals(((DirectMethodHandleDesc) ctorDesc).lookupDescriptor(), "()V");
234
235
assertEquals(staticMethodDesc.invocationType().descriptorString(), "(I)I");
236
assertEquals(((DirectMethodHandleDesc) staticMethodDesc).lookupDescriptor(), "(I)I");
237
238
assertEquals(instanceMethodDesc.invocationType().descriptorString(), "(" + testClass.descriptorString() + "I)I");
239
assertEquals(((DirectMethodHandleDesc) instanceMethodDesc).lookupDescriptor(), "(I)I");
240
241
for (MethodHandleDesc r : List.of(ctorDesc, staticMethodDesc, staticIMethodDesc, instanceMethodDesc, instanceIMethodDesc))
242
testMethodHandleDesc(r);
243
244
TestHelpers.TestClass instance = (TestHelpers.TestClass) ((MethodHandle)ctorDesc.resolveConstantDesc(LOOKUP)).invokeExact();
245
TestHelpers.TestClass instance2 = (TestHelpers.TestClass) ((MethodHandle)ctorDesc.resolveConstantDesc(TestHelpers.TestClass.LOOKUP)).invokeExact();
246
TestHelpers.TestInterface instanceI = instance;
247
248
assertNotSame(instance, instance2);
249
250
assertEquals(5, (int) ((MethodHandle)staticMethodDesc.resolveConstantDesc(LOOKUP)).invokeExact(5));
251
assertEquals(5, (int) ((MethodHandle)staticMethodDesc.resolveConstantDesc(TestHelpers.TestClass.LOOKUP)).invokeExact(5));
252
assertEquals(0, (int) ((MethodHandle)staticIMethodDesc.resolveConstantDesc(LOOKUP)).invokeExact(5));
253
assertEquals(0, (int) ((MethodHandle)staticIMethodDesc.resolveConstantDesc(TestHelpers.TestClass.LOOKUP)).invokeExact(5));
254
255
assertEquals(5, (int) ((MethodHandle)instanceMethodDesc.resolveConstantDesc(LOOKUP)).invokeExact(instance, 5));
256
assertEquals(5, (int) ((MethodHandle)instanceMethodDesc.resolveConstantDesc(TestHelpers.TestClass.LOOKUP)).invokeExact(instance, 5));
257
assertEquals(5, (int) ((MethodHandle)instanceIMethodDesc.resolveConstantDesc(LOOKUP)).invokeExact(instanceI, 5));
258
assertEquals(5, (int) ((MethodHandle)instanceIMethodDesc.resolveConstantDesc(TestHelpers.TestClass.LOOKUP)).invokeExact(instanceI, 5));
259
260
try { superMethodDesc.resolveConstantDesc(LOOKUP); fail(); }
261
catch (IllegalAccessException e) { /* expected */ }
262
assertEquals(-1, (int) ((MethodHandle)superMethodDesc.resolveConstantDesc(TestHelpers.TestClass.LOOKUP)).invokeExact(instance, 5));
263
264
try { superIMethodDesc.resolveConstantDesc(LOOKUP); fail(); }
265
catch (IllegalAccessException e) { /* expected */ }
266
assertEquals(0, (int) ((MethodHandle)superIMethodDesc.resolveConstantDesc(TestHelpers.TestClass.LOOKUP)).invokeExact(instance, 5));
267
268
try { privateMethodDesc.resolveConstantDesc(LOOKUP); fail(); }
269
catch (IllegalAccessException e) { /* expected */ }
270
assertEquals(5, (int) ((MethodHandle)privateMethodDesc.resolveConstantDesc(TestHelpers.TestClass.LOOKUP)).invokeExact(instance, 5));
271
272
try { privateIMethodDesc.resolveConstantDesc(LOOKUP); fail(); }
273
catch (IllegalAccessException e) { /* expected */ }
274
assertEquals(0, (int) ((MethodHandle)privateIMethodDesc.resolveConstantDesc(TestHelpers.TestInterface.LOOKUP)).invokeExact(instanceI, 5));
275
assertEquals(0, (int) ((MethodHandle)privateIMethodDesc.resolveConstantDesc(TestHelpers.TestClass.LOOKUP)).invoke(instanceI, 5));
276
277
try { privateStaticMethodDesc.resolveConstantDesc(LOOKUP); fail(); }
278
catch (IllegalAccessException e) { /* expected */ }
279
assertEquals(5, (int) ((MethodHandle)privateStaticMethodDesc.resolveConstantDesc(TestHelpers.TestClass.LOOKUP)).invokeExact(5));
280
281
try { privateStaticIMethodDesc.resolveConstantDesc(LOOKUP); fail(); }
282
catch (IllegalAccessException e) { /* expected */ }
283
assertEquals(0, (int) ((MethodHandle)privateStaticIMethodDesc.resolveConstantDesc(TestHelpers.TestInterface.LOOKUP)).invokeExact(5));
284
assertEquals(0, (int) ((MethodHandle)privateStaticIMethodDesc.resolveConstantDesc(TestHelpers.TestClass.LOOKUP)).invokeExact(5));
285
286
MethodHandleDesc staticSetterDesc = MethodHandleDesc.ofField(STATIC_SETTER, testClass, "sf", CD_int);
287
MethodHandleDesc staticGetterDesc = MethodHandleDesc.ofField(STATIC_GETTER, testClass, "sf", CD_int);
288
MethodHandleDesc staticGetterIDesc = MethodHandleDesc.ofField(STATIC_GETTER, testInterface, "sf", CD_int);
289
MethodHandleDesc setterDesc = MethodHandleDesc.ofField(SETTER, testClass, "f", CD_int);
290
MethodHandleDesc getterDesc = MethodHandleDesc.ofField(GETTER, testClass, "f", CD_int);
291
292
for (MethodHandleDesc r : List.of(staticSetterDesc, staticGetterDesc, staticGetterIDesc, setterDesc, getterDesc))
293
testMethodHandleDesc(r);
294
295
((MethodHandle)staticSetterDesc.resolveConstantDesc(LOOKUP)).invokeExact(6); assertEquals(TestHelpers.TestClass.sf, 6);
296
assertEquals(6, (int) ((MethodHandle)staticGetterDesc.resolveConstantDesc(LOOKUP)).invokeExact());
297
assertEquals(6, (int) ((MethodHandle)staticGetterDesc.resolveConstantDesc(TestHelpers.TestClass.LOOKUP)).invokeExact());
298
((MethodHandle)staticSetterDesc.resolveConstantDesc(TestHelpers.TestClass.LOOKUP)).invokeExact(7); assertEquals(TestHelpers.TestClass.sf, 7);
299
assertEquals(7, (int) ((MethodHandle)staticGetterDesc.resolveConstantDesc(LOOKUP)).invokeExact());
300
assertEquals(7, (int) ((MethodHandle)staticGetterDesc.resolveConstantDesc(TestHelpers.TestClass.LOOKUP)).invokeExact());
301
302
assertEquals(3, (int) ((MethodHandle)staticGetterIDesc.resolveConstantDesc(LOOKUP)).invokeExact());
303
assertEquals(3, (int) ((MethodHandle)staticGetterIDesc.resolveConstantDesc(TestHelpers.TestClass.LOOKUP)).invokeExact());
304
305
((MethodHandle)setterDesc.resolveConstantDesc(LOOKUP)).invokeExact(instance, 6); assertEquals(instance.f, 6);
306
assertEquals(6, (int) ((MethodHandle)getterDesc.resolveConstantDesc(LOOKUP)).invokeExact(instance));
307
assertEquals(6, (int) ((MethodHandle)getterDesc.resolveConstantDesc(TestHelpers.TestClass.LOOKUP)).invokeExact(instance));
308
((MethodHandle)setterDesc.resolveConstantDesc(TestHelpers.TestClass.LOOKUP)).invokeExact(instance, 7); assertEquals(instance.f, 7);
309
assertEquals(7, (int) ((MethodHandle)getterDesc.resolveConstantDesc(LOOKUP)).invokeExact(instance));
310
assertEquals(7, (int) ((MethodHandle)getterDesc.resolveConstantDesc(TestHelpers.TestClass.LOOKUP)).invokeExact(instance));
311
}
312
313
private void assertBadArgs(Supplier<MethodHandleDesc> supplier, String s) {
314
try {
315
MethodHandleDesc r = supplier.get();
316
fail("Expected failure for " + s);
317
}
318
catch (IllegalArgumentException e) {
319
// succeed
320
}
321
}
322
323
public void testBadFieldMHs() {
324
List<String> badGetterDescs = List.of("()V", "(Ljava/lang/Object;)V", "(I)I", "(Ljava/lang/Object;I)I");
325
List<String> badStaticGetterDescs = List.of("()V", "(Ljava/lang/Object;)I", "(I)I", "(Ljava/lang/Object;I)I");
326
List<String> badSetterDescs = List.of("()V", "(I)V", "(Ljava/lang/Object;)V", "(Ljava/lang/Object;I)I", "(Ljava/lang/Object;II)V");
327
List<String> badStaticSetterDescs = List.of("()V", "(II)V", "()I");
328
329
badGetterDescs.forEach(s -> assertBadArgs(() -> MethodHandleDesc.of(GETTER, helperHolderClass, "x", s), s));
330
badSetterDescs.forEach(s -> assertBadArgs(() -> MethodHandleDesc.of(SETTER, helperHolderClass, "x", s), s));
331
badStaticGetterDescs.forEach(s -> assertBadArgs(() -> MethodHandleDesc.of(STATIC_GETTER, helperHolderClass, "x", s), s));
332
badStaticSetterDescs.forEach(s -> assertBadArgs(() -> MethodHandleDesc.of(STATIC_SETTER, helperHolderClass, "x", s), s));
333
}
334
335
@Test(expectedExceptions = IllegalArgumentException.class)
336
public void testBadOwners() {
337
MethodHandleDesc.ofMethod(VIRTUAL, ClassDesc.ofDescriptor("I"), "x", MethodTypeDesc.ofDescriptor("()I"));
338
}
339
340
public void testSymbolicDescsConstants() throws ReflectiveOperationException {
341
int tested = 0;
342
Field[] fields = ConstantDescs.class.getDeclaredFields();
343
for (Field f : fields) {
344
try {
345
if (f.getType().equals(DirectMethodHandleDesc.class)
346
&& ((f.getModifiers() & Modifier.STATIC) != 0)
347
&& ((f.getModifiers() & Modifier.PUBLIC) != 0)) {
348
MethodHandleDesc r = (MethodHandleDesc) f.get(null);
349
MethodHandle m = (MethodHandle)r.resolveConstantDesc(MethodHandles.lookup());
350
testMethodHandleDesc(r, m);
351
++tested;
352
}
353
}
354
catch (Throwable e) {
355
fail("Error testing field " + f.getName(), e);
356
}
357
}
358
359
assertTrue(tested > 0);
360
}
361
362
public void testKind() {
363
for (Kind k : Kind.values()) {
364
assertEquals(Kind.valueOf(k.refKind), Kind.valueOf(k.refKind, k.refKind == MethodHandleInfo.REF_invokeInterface));
365
assertEquals(Kind.valueOf(k.refKind, k.isInterface), k);
366
}
367
// let's now verify those cases for which the value of the isInterface parameter is ignored
368
int[] isInterfaceIgnored = new int[] {
369
REF_getField,
370
REF_getStatic,
371
REF_putField,
372
REF_putStatic,
373
REF_newInvokeSpecial,
374
REF_invokeInterface
375
};
376
for (int refKind : isInterfaceIgnored) {
377
assertEquals(Kind.valueOf(refKind, false), Kind.valueOf(refKind, true));
378
}
379
380
// some explicit tests for REF_invokeStatic and REF_invokeSpecial
381
assertNotEquals(Kind.valueOf(REF_invokeStatic, false), Kind.valueOf(REF_invokeStatic, true));
382
assertNotEquals(Kind.valueOf(REF_invokeSpecial, false), Kind.valueOf(REF_invokeSpecial, true));
383
assertEquals(Kind.valueOf(REF_invokeStatic, false), Kind.STATIC);
384
assertEquals(Kind.valueOf(REF_invokeStatic, true), Kind.INTERFACE_STATIC);
385
assertEquals(Kind.valueOf(REF_invokeSpecial, false), Kind.SPECIAL);
386
assertEquals(Kind.valueOf(REF_invokeSpecial, true), Kind.INTERFACE_SPECIAL);
387
}
388
}
389
390