JS function as Java interface via reflect.Proxy

RESOLVED FIXED

Status

Rhino
Compiler
--
enhancement
RESOLVED FIXED
13 years ago
13 years ago

People

(Reporter: Igor Bukanov, Assigned: Igor Bukanov)

Tracking

Details

Attachments

(1 attachment)

(Assignee)

Description

13 years ago
Currently the automatic conversion of JavaScript function to Java interface is
implemented through generation of Java class implementing the interface. This is
similar to JavaAdapter code. In general it works nicely but still there are
limitations:

1. It requires the permission to create a class loader which may not be granted
to the application or applet.

2. The class loader requires that its parent loader must have access to both
Rhino classes and the interface in question. It may not be possible with loading
interfaces dynamically.

3. On some JVMs it causes memory leak.

All this problems can be addressed using java.lang.reflect.Proxy which is
available since JDK 1.3. Thus I suggest to use it for function->interface
conversion. 

It would have another benefit of making feature available with smalljs.jar as
the code would no longer depend on class generation library.

Ideally it would be nice to use java.lang.reflect.Proxy for JavaAdapter as well
when it needs to implement only interfaces without subclassing Java classes, but
that is for separated bug.
(Assignee)

Comment 1

13 years ago
Created attachment 194160 [details] [diff] [review]
Implementation

Not to introduce dependency on JDK 1.3-only feature in Rhino core I factored
out that through JVMBridge
(Assignee)

Comment 2

13 years ago
I committed the implementation.
(Assignee)

Updated

13 years ago
Status: NEW → RESOLVED
Last Resolved: 13 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.