Search in sources :

Example 31 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 32 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 33 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 34 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)

Example 35 with MethodType

use of java.lang.invoke.MethodType in project jdk8u_jdk by JetBrains.

the class MethodTypeTest method testEquals_MethodType.

/**
     * Test of equals method, of class MethodType.
     */
@Test
public void testEquals_MethodType() {
    System.out.println("equals");
    MethodType that = mt_viS;
    MethodType instance = mt_viS;
    boolean expResult = true;
    boolean result = instance.equals(that);
    assertEquals(expResult, result);
}
Also used : MethodType(java.lang.invoke.MethodType)

Aggregations

MethodType (java.lang.invoke.MethodType)103 MethodHandle (java.lang.invoke.MethodHandle)37 MethodHandles (java.lang.invoke.MethodHandles)6 Test (org.junit.Test)6 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 InitializeInvokerException (cn.moyada.dubbo.faker.core.exception.InitializeInvokerException)1 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