JDK-6695751 : Plugin2 returns sun.plugin2.liveconnect.JavaNameSpace instead of the correct JavaClass specified
  • Type: Enhancement
  • Component: deploy
  • Sub-Component: plugin
  • Affected Version: 6u10
  • Priority: P3
  • Status: Closed
  • Resolution: Won't Fix
  • OS: windows
  • CPU: x86
  • Submitted: 2008-04-29
  • Updated: 2010-04-04
  • Resolved: 2008-12-27
Related Reports
Relates :  
Description
test.html:
<html>
<body>
<script language="javascript" type="text/javascript">

function FuncAxel() {
var jarURL = new java.net.URL('http://javaweb.sfbay/~dp144265/miscs/test.jar');
var urlArray = java.lang.reflect.Array.newInstance(java.net.URL, 1);
urlArray[0] = jarURL;
alert("Hello: " + urlArray[0].toString());
}
</script>
<button onclick="FuncAxel()">Axel's testcase</button>
</body>
</html>

-- 
Load the above test.html on FF3 and run with new plugin.
Click on "Axel's testcase". Will see the following exception in Java Console:

java.lang.IllegalArgumentException: No method found matching name newInstance
and arguments [sun.plugin2.liveconnect.JavaNameSpace, java.lang.Integer]
        at sun.plugin2.liveconnect.JavaClass$MemberBundle.invoke(Unknown
Source)
        at sun.plugin2.liveconnect.JavaClass.invoke(Unknown Source)
        at
sun.plugin2.main.client.LiveConnectSupport$PerAppletInfo$JavaNameSpaceProxy.invoke(Unknown
Source)
        at
sun.plugin2.main.client.LiveConnectSupport$PerAppletInfo$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at
sun.plugin2.main.client.LiveConnectSupport$PerAppletInfo.doObjectOp(Unknown
Source)
        at
sun.plugin2.main.client.LiveConnectSupport$PerAppletInfo$LiveConnectWorker.run(Unknown
Source)
        at java.lang.Thread.run(Unknown Source)

This testcase works fine with OJI Plugin and FF3.
NPRuntime plugin returns sun.plugin2.liveconnect.JavaNameSpace
JavaClass for the 'java.net.URL' argument for the following JS line:

var urlArray = java.lang.reflect.Array.newInstance(java.net.URL, 1);

and causes the above exception.

Tested with 6u10 nightly build dated April/27.

(This CR references Bugzilla: https://bugzilla.mozilla.org/show_bug.cgi?id=424067)

Comments
EVALUATION This is a portion of the old LiveConnect syntax which is very undesirable to inherit in the new Java Plug-In as it causes confusion between calling static methods against a Java class and referring to that Java class's java.lang.Class object. We have been encouraging writers of Firefox extensions using Java to migrate to new syntax like java.lang.Class.forName("java.net.URL"), which is also compatible with the previous LiveConnect implementation. With other fixes such as 6745455, Firefox extensions using Java are now known to work with the new Java Plug-In. Closing as "Will Not Fix".
27-12-2008

EVALUATION At this point this is an RFE. When designing the new Java/JavaScript bridge we were unaware of the syntax added in JavaScript 1.4 which allows Java class references to be created by simply naming the class. This is described on http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Guide:LiveConnect_Overview:JavaScript_to_Java_Communication#Package_and_Class_References . At this point it is unclear whether it is a good idea to add this functionality as it diverges from the Java syntax.
29-04-2008