Return type binding
Alex Soto
asotobu at gmail.com
Tue Sep 9 13:28:17 UTC 2014
Hi,
currently I am developing an application with Java that may use Nashorn to
communicate with a Javascript (Opal rendered) javascript files. I would
like to know if it is possible to create a proxy interface against return
type.
Today I have seen this example:
function Person(firstName, lastName) {
this.firstName = firstName;
this.lastName = lastName;
this.getFullName = function() {
return this.firstName + " " + this.lastName;
}
}
static void fun4(ScriptObjectMirror person) {
System.out.println("Full Name is: " + person.callMember("getFullName"));
}
I would like to know if you can bind ScriptObjectMirror to an interface (in
this case Person interface) so instead of callMember you can call directly
the interface.
So basically I could do in java:
Person p = .convert(engine, person, Person.class)
For example in JRuby world you can do it.
Thank you so much for your help,
Alex.
--
+----------------------------------------------------------+
Alex Soto Bueno - Computer Engineer
www.lordofthejars.com
+----------------------------------------------------------+
More information about the nashorn-dev
mailing list