Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Mozilla Rhino: Defining Java Methods of an overloaded Class as global JavaScript function

94 views
Skip to first unread message

Nico Krebs

unread,
Jul 26, 2012, 1:49:45 PM7/26/12
to
Hey Igor,

i'm having trouble with the following:

if have two JAVA classes A and B while B extends A and overloads a method of A:

class A{a(){return "a"}}
class B extends A{ a(){return "B"}}

now i'd like to be able to execute "a()" in javaScript on Rhino.

usually, on non-overloaded java methods i would do the following when initializing the rhino engine:

scope.defineFunctionProperties("a", new B().getClass(), ScriptableObject.DONTENUM);

but when i'm doing this, i get the following exception:

Method "a" occurs multiple times in class "B".

i also tried to use a different name in class B and i got this exception:

TypeError: Method "a" called on incompatible object.

I would be really happy about any suggestions :)

greetz,
nico
0 new messages