@Test public void testCompose3() throws Throwable { MethodHandle fUV2R = methodHandle(TestMethodHandleUtil.class, "fUV2R", U.class, V.class); MethodHandle fS2U = methodHandle(TestMethodHandleUtil.class, "fS2U", S1.class, S2.class); MethodHandle fT2V = methodHandle(TestMethodHandleUtil.class, "fT2V", T1.class, T2.class); MethodHandle composed = compose(fUV2R, fS2U, fT2V); assertEquals((R) composed.invokeExact(new S1(2), new S2(3), new T1(5), new T2(7)), new R(210)); }
public static U fS2U(S1 s1, S2 s2) { return new U(s1.getValue() * s2.getValue()); }
public static R fUS2R(U u, S1 s1, S2 s2) { return new R(u.getValue() * s1.getValue() * s2.getValue()); }
public static U fS2U(S1 s1, S2 s2) { return new U(s1.getValue() * s2.getValue()); }
public static R fUS2R(U u, S1 s1, S2 s2) { return new R(u.getValue() * s1.getValue() * s2.getValue()); }
@Test public void testCompose2() throws Throwable { MethodHandle fUS2R = methodHandle(TestMethodHandleUtil.class, "fUS2R", U.class, S1.class, S2.class); MethodHandle fT2U = methodHandle(TestMethodHandleUtil.class, "fT2U", T1.class, T2.class); MethodHandle composed = compose(fUS2R, fT2U); assertEquals((R) composed.invokeExact(new T1(2), new T2(3), new S1(5), new S2(7)), new R(210)); }
@Test public void testCompose2() throws Throwable { MethodHandle fUS2R = methodHandle(TestMethodHandleUtil.class, "fUS2R", U.class, S1.class, S2.class); MethodHandle fT2U = methodHandle(TestMethodHandleUtil.class, "fT2U", T1.class, T2.class); MethodHandle composed = compose(fUS2R, fT2U); assertEquals((R) composed.invokeExact(new T1(2), new T2(3), new S1(5), new S2(7)), new R(210)); }
@Test public void testCompose3() throws Throwable { MethodHandle fUV2R = methodHandle(TestMethodHandleUtil.class, "fUV2R", U.class, V.class); MethodHandle fS2U = methodHandle(TestMethodHandleUtil.class, "fS2U", S1.class, S2.class); MethodHandle fT2V = methodHandle(TestMethodHandleUtil.class, "fT2V", T1.class, T2.class); MethodHandle composed = compose(fUV2R, fS2U, fT2V); assertEquals((R) composed.invokeExact(new S1(2), new S2(3), new T1(5), new T2(7)), new R(210)); }