InterfaceAdapter and java.lang.Object methods

UNCONFIRMED
Unassigned

Status

--
enhancement
UNCONFIRMED
11 years ago
11 years ago

People

(Reporter: mozilla.bugs, Unassigned)

Tracking

Details

Attachments

(1 attachment)

(Reporter)

Description

11 years ago
User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; fr; rv:1.8.1.7) Gecko/20070914 Firefox/2.0.0.7
Build Identifier: 1_7R1pre

When passing a function as an interface a proxy is created which not only delegates interface methods calls to the function but also calls to methods defined in java.lang.Object.
It follows that those proxies can't be used in a HashMap or a HashSet (hashCode and equals going through the js function).

(Calls can be discriminated by using arguments[arguments.length - 1] which contains the method name but it's awkward and seems to violate the constraint that all methods must have the same signatures.)


Reproducible: Always

Steps to Reproduce:
package bug;
public class Foo {
  Set d = new HashSet();
  public add(Callable c) {
    s.add(c);
  }
}
-------------
var f = new Packages.bug.Foo();
f.add(new function() { return true; });
Actual Results:  
Exception while trying to convert true into an int (hashCode return type).

Expected Results:  
The proxy being added to the set.
(Reporter)

Comment 1

11 years ago
Created attachment 283331 [details] [diff] [review]
Proposed patch.

Delegate only interfaces methods to the js function, use identity for "equals", delegate other methods to the target (java) object.
(Reporter)

Updated

11 years ago
Version: other → 1.7R1
(Reporter)

Updated

11 years ago
Severity: normal → enhancement
You need to log in before you can comment on or make changes to this bug.