This program (requires jdk.nashorn.test.* classes):
var x = new (Java.type("jdk.nashorn.test.models.PropertyBind"))
var n = "writeOnly";
x[n] = 2
print(x.peekWriteOnly());
throws:
Exception in thread "main" java.lang.invoke.WrongMethodTypeException: expected (Object,int)void but found (Object,int)Object
at java.lang.invoke.Invokers.newWrongMethodTypeException(Invokers.java:294)
at java.lang.invoke.Invokers.checkExactType(Invokers.java:305)
at jdk.nashorn.internal.scripts.Script$Recompilation$2$x$cu1$restOf.:program(x.js:3)
...