Closed Bug 108374 Opened 24 years ago Closed 14 years ago

Poor API for wrapping/unwrapping Java/JavaScript objects

Categories

(Core Graveyard :: Java: Live Connect, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED INCOMPLETE

People

(Reporter: tjw, Unassigned)

Details

Attachments

(1 file)

jsjava.h declares two functions: JSJ_ConvertJavaObjectToJSValue JSJ_ConvertJSValueToJavaObject Despite the mirror nature of the names of these functions, these functions are not mirrors. The first is a wrapper for jsj_ConvertJavaObjectToJSValue which CREATES a new JSValue to wrap the Java object. The second takes an existing JS wrapper and unwraps it to expose the Java object is is wrapping. There is currently NO function to take a JS object and CREATE a wrapper Java object (i.e., there is no public wrapper for the private jsj_ConvertJSValueToJavaObject function). Likewise, there is no function for exposing the wrapped Java object in a JSValue. These need implemented so that (for example) one can fully implement the Netscape plugin API which requires that you be able to create a Java peer to a plugin and set the 'window' field of the netscape.plugin.Plugin instance to a netscape.javascript.JSObject that wraps the Window containing the plugin. There are probably other reasons that these should be exposed. So, my recommendation would be this: Get rid of the old public function names and instead create new functions with names that state what the functions actually do and provide the full compliment of functions: JSJ_CreateJavaWrapperForJSValue JSJ_GetJSValueFromJavaWrapper JSJ_CreateJSWrapperForJavaObject JSJ_GetJavaObjectFromJSWrapper I'll be working on a patch and will submit it when ready. Feel free to supply comments on this general approach, though.
Status: UNCONFIRMED → NEW
Ever confirmed: true
Ok, so there are some issues with preserving object identity that may make it worthwhile to have 'convert' API in addition to just wrap/unwrap API. Still, there needs to be more public API in this area.
OK, so keeping the same functions is fine (and necessary for preserving object identity, it looks like). I've updated the comments in jsjava.h to better indicate what the functions should do and updated JSJ_ConvertJSValueToJavaObject() to actually create a netscape.javascript.JSObject wrapper for a JavaScript value if no such wrapper already exists. Patch to be attached next.
Attached patch Suggested patchSplinter Review
Reassigning to Patrick for consideration of this patch -
Assignee: rogerl → beard
-> default assignee for old netscape assigned bugs.
Assignee: beard → live-connect
Product: Core → Core Graveyard
Firefox code moved from custom Liveconnect code to the NPAPI/NPRuntime bridge a while back. Mass-closing the bugs in the liveconnect component which are likely invalid. If you believe that this bug is still relevant to modern versions of Firefox, please reopen it and move it the "Core" product, component "Plug-Ins".
Status: NEW → RESOLVED
Closed: 14 years ago
Resolution: --- → INCOMPLETE
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: