From:  Nico Krebs <nicokrebs.dev@googlemail.com>
Date:  27 Jul 2012 01:49:45 Hong Kong Time
Newsgroup:  news.mozilla.org/netscape.public.mozilla.jseng
Subject:  

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

NNTP-Posting-Host:  95.168.147.22

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