57 58 assertThrows(ClassCastException.class, 59 () -> MethodHandles.insertArguments(DVT_MH, 0, new ValueCapable())); 60 61 assertThrows(NullPointerException.class, 62 () -> MethodHandles.insertArguments(DVT_MH, 0, new Object[] { null })); 63 } 64 65 @Test 66 void testInsertArgumentVCC() throws Throwable { 67 assertEquals(MethodHandles.insertArguments(VCC_MH, 0, ARG).invokeWithArguments(), ARG); 68 69 assertThrows(ClassCastException.class, 70 () -> MethodHandles.insertArguments(VCC_MH, 0, new ValueCapable())); 71 72 { 73 MethodHandle mh = MethodHandles.insertArguments(VCC_MH, 0, new Object[]{null}); 74 assertThrows(NullPointerException.class, () -> mh.invokeWithArguments()); 75 } 76 } 77 } | 57 58 assertThrows(ClassCastException.class, 59 () -> MethodHandles.insertArguments(DVT_MH, 0, new ValueCapable())); 60 61 assertThrows(NullPointerException.class, 62 () -> MethodHandles.insertArguments(DVT_MH, 0, new Object[] { null })); 63 } 64 65 @Test 66 void testInsertArgumentVCC() throws Throwable { 67 assertEquals(MethodHandles.insertArguments(VCC_MH, 0, ARG).invokeWithArguments(), ARG); 68 69 assertThrows(ClassCastException.class, 70 () -> MethodHandles.insertArguments(VCC_MH, 0, new ValueCapable())); 71 72 { 73 MethodHandle mh = MethodHandles.insertArguments(VCC_MH, 0, new Object[]{null}); 74 assertThrows(NullPointerException.class, () -> mh.invokeWithArguments()); 75 } 76 } 77 78 @Test 79 void testConstantDVT() throws Throwable { 80 assertEquals(MethodHandles.constant(DVT, ARG).invokeWithArguments(), ARG); 81 82 assertThrows(ClassCastException.class, 83 () -> MethodHandles.constant(DVT, new Object())); 84 85 assertThrows(NullPointerException.class, 86 () -> MethodHandles.constant(DVT, null)); 87 } 88 } |