Search in sources :

Example 91 with MethodType

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

the class MethodHandleConstants method testCase.

private static void testCase(MethodHandle mh, Class<?> defc, String name, Class<?> rtype, Class<?>... ptypes) throws Throwable {
    System.out.println(mh);
    // we include defc, because we assume it is a non-static MH:
    MethodType mt = methodType(rtype, ptypes);
    assertEquals(mh.type(), mt);
// FIXME: Use revealDirect to find out more
}
Also used : MethodType(java.lang.invoke.MethodType)

Example 92 with MethodType

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

the class MethodTypeTest method testHashCode.

/**
     * Test of hashCode method, of class MethodType.
     */
@Test
public void testHashCode() {
    System.out.println("hashCode");
    MethodType instance = mt_viS;
    ArrayList<Class<?>> types = new ArrayList<>();
    types.add(instance.returnType());
    types.addAll(instance.parameterList());
    int expResult = types.hashCode();
    int result = instance.hashCode();
    assertEquals(expResult, result);
}
Also used : MethodType(java.lang.invoke.MethodType)

Example 93 with MethodType

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

the class MethodTypeTest method testToString.

/**
     * Test of toString method, of class MethodType.
     */
@Test
public void testToString() {
    System.out.println("toString");
    MethodType[] instances = { mt_viS, mt_OO2, mt_vv, mt_Ov, mt_iSI, mt_ISi, mt_ISI, mt_iSi };
    //String expResult = "void[int, class java.lang.String]";
    String[] expResults = { "(int,String)void", "(Object,Object)Object", "()void", "()Object", "(String,Integer)int", "(String,int)Integer", "(String,Integer)Integer", "(String,int)int" };
    for (int i = 0; i < instances.length; i++) {
        MethodType instance = instances[i];
        String result = instance.toString();
        System.out.println("#" + i + ":" + result);
        assertEquals("#" + i, expResults[i], result);
    }
}
Also used : MethodType(java.lang.invoke.MethodType)

Example 94 with MethodType

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

the class MethodTypeTest method testReturnType.

/**
     * Test of returnType method, of class MethodType.
     */
@Test
public void testReturnType() {
    System.out.println("returnType");
    MethodType instance = mt_viS;
    Class<?> expResult = void.class;
    Class<?> result = instance.returnType();
    assertSame(expResult, result);
}
Also used : MethodType(java.lang.invoke.MethodType)

Example 95 with MethodType

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

the class MethodTypeTest method testMake_Class_ClassArr.

/**
     * Test of make method, of class MethodType.
     */
@Test
public void testMake_Class_ClassArr() {
    System.out.println("make (from type array)");
    MethodType result = MethodType.methodType(rtype, ptypes);
    assertSame(mt_viS, result);
}
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