How to extend a Java interface or class with overloaded methods using Nashorn?
A. Sundararajan
sundararajan.athijegannathan at oracle.com
Mon Feb 23 16:10:52 UTC 2015
Hi Christopher,
http://mail.openjdk.java.net/pipermail/nashorn-dev/2015-February/004178.html
Somehow missed responding to this email. Yes, you can implement
interface with overloaded methods. You can use arguments inside the
implementing function to differentiate.
var Foo = Java.type('bar.Foo');
var instance = new Foo {
bar: function(){
print(arguments.length);
for (i in arguments) print(arguments[i]);
}
};
instance.bar();
instance.bar(223);
instance.bar("hello");
Hope this helps,
-Sundar
More information about the nashorn-dev
mailing list