use of java.lang.invoke.MethodType in project jdk8u_jdk by JetBrains.
the class MethodTypeTest method testMake_MethodType.
/**
* Test of make method, of class MethodType.
*/
@Test
public void testMake_MethodType() {
System.out.println("make (from rtype, MethodType)");
MethodType expResult = mt_iO2;
MethodType result = MethodType.methodType(int.class, mt_IO2);
assertSame(expResult, result);
}
use of java.lang.invoke.MethodType in project jdk8u_jdk by JetBrains.
the class MethodTypeTest method testMake_3args.
/**
* Test of make method, of class MethodType.
*/
@Test
public void testMake_3args() {
System.out.println("make (from type with varargs)");
MethodType result = MethodType.methodType(rtype, ptypes[0], ptypes[1]);
assertSame(mt_viS, result);
}
use of java.lang.invoke.MethodType in project jdk8u_jdk by JetBrains.
the class MethodTypeTest method testParameterList.
/**
* Test of parameterList method, of class MethodType.
*/
@Test
public void testParameterList() {
System.out.println("parameterList");
MethodType instance = mt_viS;
List<Class<?>> expResult = Arrays.asList(ptypes);
List<Class<?>> result = instance.parameterList();
assertEquals(expResult, result);
}
use of java.lang.invoke.MethodType in project jdk8u_jdk by JetBrains.
the class MethodTypeTest method testGeneric.
@Test
public void testGeneric() {
System.out.println("generic");
MethodType[] instances = { mt_viS, mt_OO2, mt_vv, mt_Ov, mt_iSI, mt_ISi, mt_ISI, mt_iSi };
MethodType[] expResults = { mt_OO2, mt_OO2, mt_Ov, mt_Ov, mt_OO2, mt_OO2, mt_OO2, mt_OO2 };
for (int i = 0; i < instances.length; i++) {
MethodType result = instances[i].generic();
assertSame("#" + i, expResults[i], result);
}
}
use of java.lang.invoke.MethodType in project jdk8u_jdk by JetBrains.
the class MethodTypeTest method testSerialization.
/** Test (de-)serialization. */
@Test
public void testSerialization() throws Throwable {
System.out.println("serialization");
for (MethodType mt : GALLERY) {
testSerializedEquality(mt);
}
testSerializedEquality(GALLERY);
// Make a list of mixed objects:
List<Object> stuff = new ArrayList<>();
// copy #1
Collections.addAll(stuff, GALLERY);
Object[] triples = Arrays.copyOfRange(GALLERY, 0, GALLERY.length / 2);
// copy #3 (partial)
Collections.addAll(stuff, triples);
for (MethodType mt : GALLERY) {
Collections.addAll(stuff, mt.parameterArray());
}
Collections.shuffle(stuff, new Random(292));
// copy #2
Collections.addAll(stuff, GALLERY);
testSerializedEquality(stuff);
}
Aggregations