Closed Bug 306308 Opened 19 years ago Closed 19 years ago

JS function as Java interface via reflect.Proxy

Categories

(Rhino Graveyard :: Compiler, enhancement)

x86
Linux
enhancement
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: igor, Assigned: igor)

Details

Attachments

(1 file)

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.
Attached patch ImplementationSplinter Review
Not to introduce dependency on JDK 1.3-only feature in Rhino core I factored out that through JVMBridge
I committed the implementation.
Status: NEW → RESOLVED
Closed: 19 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: