Closed Bug 424067 Opened 16 years ago Closed 11 years ago

Java in Firefox Extensions error while creating array


(Core Graveyard :: Java: OJI, defect)

Not set


(Not tracked)



(Reporter: deus.ex.makina, Assigned: danielle.pham)


(Keywords: regression)

User-Agent:       Mozilla/5.0 (X11; U; Linux i686 (x86_64); en-US; rv:1.9b5pre) Gecko/2008032000 Minefield/3.0b5pre XPCOMViewer/1.0a1
Build Identifier: Mozilla/5.0 (X11; U; Linux i686 (x86_64); en-US; rv:1.9b5pre) Gecko/2008032000 Minefield/3.0b5pre XPCOMViewer/1.0a1

Can't load a Java class due to is not possible to create[]

Reproducible: Always

Steps to Reproduce:
1. init a javascript shell
2. var u = ['')]
3. var c = new;
Actual Results:  
Unable to convert JavaScript value to Java value of type[]

Tested in firefox:
Mozilla/5.0 (X11; U; Linux i686 (x86_64); en-US; rv:1.9b5pre) Gecko/2008032000 Minefield/3.0b5pre XPCOMViewer/1.0a1
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9b5pre) Gecko/2008031922 Minefield/3.0b5pre

This happens since firefox 3.0b4
Version: unspecified → Trunk
I confirm this bug on 
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9pre) Gecko/2008033113 Minefield/3.0pre

This bug prevents my extension openinfocard "Information Cards for Firefox" from working. In early version of Firefox 3 the extension crashed Firefox3. Now it is not crashing but still not working. Please don't publish a 3.0pre version with this bug!
My extension is here:
Flags: blocking-firefox3?
and which version of java are you using? and which version of firefox/java were you using before?
Component: Extension Compatibility → Java: OJI
Flags: blocking-firefox3?
Product: Firefox → Core
QA Contact: extension.compatibility → java.oji
    File name: npoji610.dll
    Java Plug-in 1.6.0_05 for Netscape Navigator (DLL Helper) java version "1.6.0_05"

------------ java -version -------------
Java(TM) SE Runtime Environment (build 1.6.0_05-b13)
Java HotSpot(TM) Client VM (build 10.0-b19, mixed mode, sharing)


InternalError: Unable to convert JavaScript value file:/C:/Dokumente%20und%20Einstellungen/Nennker.Axel/Anwendungsdaten/Mozilla/Firefox/Profiles/kb7ofbop.default/extensions/%7B211DBAEA-CE99-11DA-8254-96BEC52F3316%7D/components/firefoxClassLoader.jar to Java value of type[]


The java version is not the problem. This works with Firefox 2.0* but fails with the Firefox3 betas. The first betas crashed when the openinfocard extension loads the java component. The current betas don't crash but the java xpcom does not work due to the "InternalError:" above.
Java(TM) Plug-in 1.6.0_05-b13

    File name:
    Java(TM) Plug-in 1.6.0_05

As I said before, the problem started in firefox 3.0b4
java version "1.5.0_15"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_15-b04)
Java HotSpot(TM) Client VM (build 1.5.0_15-b04, mixed mode, sharing)

Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9b4) Gecko/2008030318 Firefox/3.0b4

    File name:
    Java(TM) Plug-in 1.5.0_15

I confirm that error for the above versions.
I found a way to circumvent this bug.

In a javascript script the call "java_method([aElement])" formerly worked but now it fails. It has to be replaced with
var urlArray = java.lang.reflect.Array.newInstance(, 1);
urlArray[0] = aElement; // aElement beeing a

This method works for types other than too.
Assignee: nobody → danielle.pham
Keywords: regression
Have you tried the new NPRuntime-based Java Plug-In in conjunction with the FF 3.0 early access builds?
No. My comments above list all combinations that I tried.
I the meantime I upgraded my java version. So I retested this bug today:

I downloaded the latest mozilla source code from CVS and rebuilt the browser. 

Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9pre) Gecko/2008042910 Minefield/3.0pre

I started the new browser and downloaded xmldap- from the openinfocard project's download area and installed it into the new browser.

Now I opened and clicked the image. This startsed the identity selector, I chose a card and everything worked fine.

I currently use this java version:
$ java -version
java version "1.6.0_06"
Java(TM) SE Runtime Environment (build 1.6.0_06-b02)
Java HotSpot(TM) Client VM (build 10.0-b22, mixed mode, sharing)
I verified that minefield uses the same version (about:plugins).

Next I changed the code of my extension to use the old-not-working javascript contruct.
This not-working code looks like:
    var firefoxClassLoaderURL = 
        new + "components/firefoxClassLoader.jar");
    //var urlArray = java.lang.reflect.Array.newInstance(, 1);
    //urlArray[0] = firefoxClassLoaderURL;
     *  Step 1. Load the bootstraping firefoxClassLoader.jar.
    var bootstrapClassLoader =[firefoxClassLoaderURL]); // here is the bug
    if (!(bootstrapClassLoader instanceof {
        _printToJSConsole("Error: failed! " + bootstrapClassLoader);

Then I rebuild the openinfocard extension, installed it and tried it at This still does not work:
InternalError: Unable to convert JavaScript value file:/C:/Dokumente%20und%20Einstellungen/Axel%20Nennker/Anwendungsdaten/Mozilla/Firefox/Profiles/o71lzy3u.minefield/extensions/%7B211DBAEA-CE99-11DA-8254-96BEC52F3316%7D/components/firefoxClassLoader.jar to Java value of type[]

To me this looks like the javascript interpreter is overlooking the square brackets around firefoxClassLoaderURL in line 271. I expect this behaviour:
- js interpreter (jsi) parses the function call ( newinstance([firefoxClassLoaderURL]) )
- jsi parses arg (  [firefoxClassLoaderURL] ) and constructs a js array of objects
- jsi tries to find matching function and detects that a java array of URL would match
- jsi converts js array of object to java array of URL
- jsi calls java function "newinstance" with java array of URL as parameter.

So I expect the error to be in mozilla/js/src/* somewhere and NOT in java; but you are the expert. I am just guessing but my guess is that trying it with 6u10ea is a waste of time.

I wrote a little test to verify the 2 cases reported by Oriol Mula & Axel Nennker:

<script language="javascript" type="text/javascript">
function FuncOriol() {
var u = ['http://javaweb.sfbay/~dp144265/miscs/test.jar')]; 
var c = new;

function FuncAxel() {
var jarURL = new'http://javaweb.sfbay/~dp144265/miscs/test.jar');
var urlArray = java.lang.reflect.Array.newInstance(, 1);
//urlArray[0] = jarURL;
//alert("Hello: " + urlArray[0].toString());

<button onclick="FuncOriol()">Oriol's testcase</button>
<button onclick="FuncAxel()">Axel's testcase</button>


(Note that: if you're using any JRE version older than 6u10, it's OJI Plugin that's used.  NPRuntime Java Plugin is the new generation Java Plugin that will be the default starting 6u10, and will eventually replace OJI Plugin. NPRuntime Java Plugin requires FF3 to work.
For latest 6u10 build, goto:

I tested with FF3 and 6u10's OJI Java Plugin and NPRuntime Java Plugin, and here's what I saw:

1) Oriol's testcase & OJI Plugin: I confirmed that JS parser fails to parse this line correctly:
var u = ['http://javaweb.sfbay/~dp144265/miscs/test.jar')];
and var c = new; will result in the following JS error:

"Unable to convert JavaScript value http://javaweb.sfbay/~dp144265/miscs/test.jar to Java value of type[]"

This is a problem with FF3's JS parser. So from Sun, we cannot do anything about it. Johnny, could you please help take a look.

2) Oriol's testcase & NPRuntime plugin: 
The following JS error is received when parsing this line:
var u = ['http://javaweb.sfbay/~dp144265/miscs/test.jar')];

"Attempt to call a default method on object with no invokeDefault method"

Again, this is a problem with the JS parser. Johnny may be able to help.

3) Axel's testcase with OJI Plugin:  works fine as indicated by Axel.

4) Axel's testcase with NPRuntime Plugin: 
This line:
var urlArray = java.lang.reflect.Array.newInstance(, 1);
results in a Java Exception:
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$ Source)
	at Method)
	at sun.plugin2.main.client.LiveConnectSupport$PerAppletInfo.doObjectOp(Unknown Source)
	at sun.plugin2.main.client.LiveConnectSupport$PerAppletInfo$ Source)
	at Source)

Apparently, NPRuntime plugin returns sun.plugin2.liveconnect.JavaNameSpace JavaClass for the '' argument.  This is a bug with NPRuntime plugin.
I will file a Sun bug on this so we can work on it.
Sun CR#6695751 has been created to track above problem (4) with NPRuntime Plugin in JRE 6u10.

Johnny, could you please take a look at problems (1) and (2) in my previous post.

The syntax


is invalid. You need to write


I was unaware of the syntax in JavaScript 1.4 to refer to Class objects directly via e.g.

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

This is an RFE for the new Java Plug-In at this point. You can achieve the same result with

var urlArray = java.lang.reflect.Array.newInstance(java.lang.Class.forName(""), 1);
This still does not work with Firefox 3 RC1:

"InternalError: Unable to convert JavaScript value file:/C:/Dokumente%20und%20Einstellungen/Nennker.Axel/Anwendungsdaten/Mozilla/Firefox/Profiles/kb7ofbop.default/extensions/%7B211DBAEA-CE99-11DA-8254-96BEC52F3316%7D/components/firefoxClassLoader.jar to Java value of type[]".
This is fixed with java6u12.
Product: Core → Core Graveyard
Mass-closing bugs in the "OJI" component: OJI plugin integration was replaced with npruntime long ago, and these bugs appear to be irrelevant now. If there is in fact a real bug that remains, please file it new in the "Core" product, component "Plug-ins".
Closed: 11 years ago
Resolution: --- → INCOMPLETE
You need to log in before you can comment on or make changes to this bug.