Search in sources :

Example 26 with MethodType

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);
}
Also used : MethodType(java.lang.invoke.MethodType)

Example 27 with MethodType

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);
}
Also used : MethodType(java.lang.invoke.MethodType)

Example 28 with MethodType

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);
}
Also used : MethodType(java.lang.invoke.MethodType)

Example 29 with MethodType

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);
    }
}
Also used : MethodType(java.lang.invoke.MethodType)

Example 30 with MethodType

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);
}
Also used : MethodType(java.lang.invoke.MethodType)

Aggregations

MethodType (java.lang.invoke.MethodType)102 MethodHandle (java.lang.invoke.MethodHandle)36 Test (org.junit.Test)6 MethodHandles (java.lang.invoke.MethodHandles)5 ArrayList (java.util.ArrayList)4 BytecodeBlock (com.facebook.presto.bytecode.BytecodeBlock)3 ScriptObject (com.github.anba.es6draft.runtime.types.ScriptObject)3 OrdinaryObject (com.github.anba.es6draft.runtime.types.builtins.OrdinaryObject)3 CallSite (java.lang.invoke.CallSite)3 LambdaReceiver_A (LambdaReceiver_anotherpkg.LambdaReceiver_A)2 MethodDefinition (com.facebook.presto.bytecode.MethodDefinition)2 ConnectorSession (com.facebook.presto.spi.ConnectorSession)2 PrestoException (com.facebook.presto.spi.PrestoException)2 Map (java.util.Map)2 Session (com.facebook.presto.Session)1 BytecodeNode (com.facebook.presto.bytecode.BytecodeNode)1 ClassDefinition (com.facebook.presto.bytecode.ClassDefinition)1 Parameter (com.facebook.presto.bytecode.Parameter)1 Scope (com.facebook.presto.bytecode.Scope)1 Variable (com.facebook.presto.bytecode.Variable)1