Examples of invokeExact()


Examples of java.lang.invoke.MethodHandle.invokeExact()

      Object result;
      if (useMethodHandles) {
        final Object[] params = castParams(realDest,
            request.getParams(), annotatedMethod.getParams(),
            requestParams);
        result = methodHandle.invokeExact(params);
      } else {
        final Object[] params = castParams(request.getParams(),
            annotatedMethod.getParams(), requestParams);
        result = method.invoke(realDest, params);
      }
View Full Code Here

Examples of java.lang.invoke.MethodHandle.invokeExact()

  private void cancelUsingMH(ScheduledFuture<?> hndl) {
    MethodHandle mh = manager.makeMh();

    try {
      System.out.println("With Method Handle");
      mh.invokeExact(manager, hndl);
    } catch (Throwable e) {
      e.printStackTrace();
    }
  }
View Full Code Here

Examples of java.lang.invoke.MethodHandle.invokeExact()

        return methodHandleFactory.create(instance.getClass(), method);
      }
    };
    MethodHandle methodHandle = cache.fetch(method,newMethodHandleIfNotExists);
    try {
      return (T) methodHandle.invokeExact(instance, args);
    } catch (Throwable e) {
      Throwables.propagateIfPossible(e);
      throw new MethodExecutorException(e);
    }
  }
View Full Code Here

Examples of java.lang.invoke.MethodHandle.invokeExact()

                .from(String.class, new String[]{"arg1", "arg2"}, String.class, String.class)
                .filter("arg.*", filter)
                .invoke(target).handle();

        assertEquals(MethodType.methodType(String.class, String.class, String.class), handle.type());
        assertEquals("foogoodbyebargoodbye", (String)handle.invokeExact("foo", "bar"));
    }

    @Test
    public void testIdentity() throws Throwable {
        MethodHandle handle = SmartBinder
View Full Code Here

Examples of java.lang.invoke.MethodHandle.invokeExact()

                .dropLast()
                .identity()
                .handle();

        assertEquals(MethodType.methodType(String.class, int.class), handle.type());
        assertEquals("15", (String)handle.invokeExact(15));
    }
   
    private static final MethodHandles.Lookup LOOKUP = MethodHandles.lookup();
   
    private static final MethodHandle stringInt = Binder
View Full Code Here

Examples of java.lang.invoke.MethodHandle.invokeExact()

                .from(binder1)
                .insert(1, "world")
                .invoke(target);

        assertEquals(MethodType.methodType(String.class, String.class, Object.class), handle.type());
        assertEquals("Hello, world", (String) handle.invokeExact("Hello, ", new Object()));
    }

    @Test
    public void testInsertPrimitive() throws Throwable {
        Binder b1 = Binder
View Full Code Here

Examples of java.lang.invoke.MethodHandle.invokeExact()

                .from(String.class)
                .insert(0, new Class[]{int.class, long.class}, 1, 1L)
                .invoke(target);

        assertEquals(MethodType.methodType(String.class), handle.type());
        assertEquals("intLong ok", (String) handle.invokeExact());
    }

    @Test
    public void testTo() throws Throwable {
        Binder otherBinder = Binder
View Full Code Here

Examples of java.lang.invoke.MethodHandle.invokeExact()

        assertEquals(MethodType.methodType(String.class, String.class, int.class), thisBinder.type());
        assertEquals(MethodType.methodType(String.class, String.class, String.class), newBinder.type());
       
        MethodHandle target = newBinder.invoke(Subjects.concatHandle());
       
        assertEquals("Hello, world", (String)target.invokeExact());
    }

    @Test
    public void testType() throws Throwable {
        Binder binder = Binder
View Full Code Here

Examples of java.lang.invoke.MethodHandle.invokeExact()

                .from(String.class, String.class)
                .insert(1, "world")
                .invoke(target);

        assertEquals(MethodType.methodType(String.class, String.class), handle.type());
        assertEquals("Hello, world", (String) handle.invokeExact("Hello, "));

        MethodHandle target2 = Subjects.concatCharSequenceHandle();
        MethodHandle handle2 = Binder
                .from(String.class, String.class)
                .insert(1, CharSequence.class, "world")
View Full Code Here

Examples of java.lang.invoke.MethodHandle.invokeExact()

                .append("world")
                .drop(1)
                .invoke(target);

        assertEquals(MethodType.methodType(String.class, String.class, Object.class), handle.type());
        assertEquals("Hello, world", (String) handle.invokeExact("Hello, ", new Object()));

        MethodHandle target2 = Subjects.concatCharSequenceHandle();
        MethodHandle handle2 = Binder
                .from(String.class, String.class, Object.class)
                .append(CharSequence.class, "world")
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.