@Test public void check_field_setter() throws Throwable { CallSite property = MethodInvocationSupport.bootstrap( lookup(), "property", methodType(Object.class, Object.class, Object.class), 0); FieldAccessors receiver = new FieldAccessors(); receiver.property = "undefined"; property.dynamicInvoker().invokeWithArguments(receiver, "foo"); assertThat((String) receiver.property, is("foo")); }
@Test public void check_field_getter() throws Throwable { CallSite property = MethodInvocationSupport.bootstrap( lookup(), "property", methodType(Object.class, Object.class), 0); FieldAccessors receiver = new FieldAccessors(); receiver.property = "foo"; Object result = property.dynamicInvoker().invokeWithArguments(receiver); assertThat(result, notNullValue()); assertThat(result, instanceOf(String.class)); assertThat((String) result, is("foo")); }