Register a custom type converter (is it possible)?
Paulo Lopes
pmlopes at gmail.com
Mon Jun 20 12:13:55 UTC 2016
Hi,
I've been reading the documentation, wiki and the examples from Nashorn and
have a question that I cannot find a yes/no answer to. Say for example that
I've an application that leverages on Nashorn for JavaScript execution but
its core is in Java. In my Java code I've a interface like:
interface Foo {
void doSomething(Bar bar);
}
Now from Nashorn I'd like to invoke the method "doSomething" like:
foo.doSomethin({key: 'value'});
As expected this won't work since Nashorn does not know how to cast from
"JSObject" to "Bar" however I'd like to register somewhere/somehow (this is
what I don't know) a helper class/method/something where I could do this. I
also do not want to bring Nashorn API/types to Java to I'm not looking for
something like:
class Bar implements JSObject { ... }
Is this possible? and it is possible with JDK8?
Thanks!
Paulo
More information about the nashorn-dev
mailing list