The following test program crashes the VM.
----
import java.lang.invoke.*;
import java.lang.reflect.*;
public class Test {
public Test obj;
public String str;
public static void main(String[] args) throws Throwable {
MethodHandles.Lookup l = MethodHandles.publicLookup();
Field field = Test.class.getField("str");
MethodHandle mh = l.unreflectSetter(field);
MethodHandle filter = l.unreflectGetter(Test.class.getField("obj"));
mh = MethodHandles.filterArguments(mh, 0, filter);
mh.invokeExact(new Test(), "hello");
}
}
---
The test crashes with the problematic frame "Unsafe_setObject". Without the filterArguments, if 'null' is directly passed to invokeExact as first argument, then we get WrongTypeException because null is inferred as Void type. But, when filterArguments and the filter returns null value, then the VM crashes.