Closed Bug 49325 Opened 24 years ago Closed 24 years ago

JavaAdapter method lookup does not follow prototype chain

Categories

(Rhino Graveyard :: Core, defect, P3)

defect

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: rade, Assigned: norrisboyd)

References

Details

Attachments

(2 files)

Define a simple Java interface as follows:

public interface Foo {
    public int bar(int x);
}

and then run the following Javascript program:

var foo = {}
foo.__proto__.bar = function(x) { return x; }
foo.bar(10);	//=> 10
var f = new JavaAdapter(Packages.Foo,foo);
f.bar(10);	//=> 0

The invocation of "bar" on "f" returns 0 instead of 10. That is because 
JavaAdapters do not follow the prototype chain on attribute/method lookup.

btw, we get "0" because of another problem - a failed method lookup results in 
"undefined" being returned, which gets converted to 0 by the JavaAdapter.
I believe my changes to your patch handle the case where the function isn't 
defined more rigorously. (Curse my initial laziness to not fix the TODO.)

What do you think?
Status: NEW → ASSIGNED
Norris, your fix looks good to me.
Depends on: 49350
Cool. Thanks for all your help with these. You're fast with the patches!

I'll run regression tests on this change tonight and check it in tomorrow if all 
goes well.
Sorry--a little slow on this.

Checking in now.
Status: ASSIGNED → RESOLVED
Closed: 24 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: