Last Comment Bug 391349 - Exception on startup on JDK 1.4
: Exception on startup on JDK 1.4
Status: RESOLVED FIXED
:
Product: Rhino
Classification: Components
Component: Core (show other bugs)
: 1.6R6
: x86 Linux
: -- normal (vote)
: ---
Assigned To: Norris Boyd
:
:
Mentors:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2007-08-08 05:24 PDT by Norris Boyd
Modified: 2007-11-13 17:20 PST (History)
2 users (show)
See Also:
Crash Signature:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---


Attachments
Proposed patch (948 bytes, patch)
2007-08-08 05:24 PDT, Norris Boyd
no flags Details | Diff | Splinter Review
Updated patch, handling all exceptions correctly (821 bytes, patch)
2007-08-08 08:00 PDT, Jürg Lehni
no flags Details | Diff | Splinter Review

Description Norris Boyd 2007-08-08 05:24:06 PDT
Created attachment 275764 [details] [diff] [review]
Proposed patch

from newsgroup:

I run into this problem today when runing Rhino on JDK 1.4 on Mac:

java.lang.NoSuchMethodError: java.lang.reflect.Method.isVarArgs()Z
at org.mozilla.javascript.jdk15.VMBridge_jdk15.isVarArgs
(VMBridge_jdk15.java:48)

It seems that VMBridge_jdk15 is used although I am on 1.4.

Looking at VMBridge's code for deciding which one to use, I saw that  
it loops through these and tries to instantiate them:

org.mozilla.javascript.VMBridge_custom
org.mozilla.javascript.jdk15.VMBridge_jdk15
org.mozilla.javascript.jdk13.VMBridge_jdk13
org.mozilla.javascript.jdk11.VMBridge_jdk11

And for some reason it seems to be able to instantiate VMBridge_jdk15  
on 1.4 and is happy.

I then looked at VMBridge_jdk15 and did not see any condition that  
should prevent it from being able to do so. Or should the missing  
isVarArgs() be enough a reason for it to not load?

Is it just me, or is this currently broken for 1.4?

Jürg 

Attaching proposed fix from Jürg from later in the same thread.
Comment 1 Norris Boyd 2007-08-08 05:37:44 PDT
Fixed:

Checking in src/org/mozilla/javascript/jdk15/VMBridge_jdk15.java;
/cvsroot/mozilla/js/rhino/src/org/mozilla/javascript/jdk15/VMBridge_jdk15.java,v  <--  VMBridge_jdk15.java
new revision: 1.1.4.1; previous revision: 1.1
done
Comment 2 Jürg Lehni 2007-08-08 08:00:26 PDT
Created attachment 275780 [details] [diff] [review]
Updated patch, handling all exceptions correctly

The proposed patch works for me. But I think it should be done differently since org.mozilla.javascript.Kit.newInstanceOrNull does not handle NoSuchMethodException. I am actually not sure anymore why it works, I guess a SecurityException is thrown, which newInstanceOrNull handles.
So here a new version that throws exceptions handled by newInstanceOrNull and also uses the strategy proposed by Attila.
Comment 3 Norris Boyd 2007-08-08 10:24:23 PDT
Okay, I've redone the change based upon the latest patch. The new candidate is now at ftp://ftp.mozilla.org/pub/mozilla.org/js/rhino1_6R7-candidate2.zip. Please try it out.

Checking in src/org/mozilla/javascript/jdk15/VMBridge_jdk15.java;
/cvsroot/mozilla/js/rhino/src/org/mozilla/javascript/jdk15/VMBridge_jdk15.java,v  <--  VMBridge_jdk15.java
new revision: 1.1.4.2; previous revision: 1.1.4.1
done
Comment 4 Jürg Lehni 2007-11-08 01:16:00 PST
It appears that the old patch is still in place in CVS. This should be updated, since its result is not handled correctly by newInstanceOrNull. Is there a reason for waiting with this?
Comment 5 Norris Boyd 2007-11-08 05:13:11 PST
Thanks for asking -- I'd committed to the branch for 1.6R7 but not to the trunk for 1.7R1. I've now checked it into the trunk:

Checking in src/org/mozilla/javascript/jdk15/VMBridge_jdk15.java;
/cvsroot/mozilla/js/rhino/src/org/mozilla/javascript/jdk15/VMBridge_jdk15.java,v  <--  VMBridge_jdk15.java
new revision: 1.5; previous revision: 1.4
done
Comment 6 lchen 2007-11-13 01:35:43 PST
Can you tell me which build will include this fix?
Thanks.
Comment 7 Norris Boyd 2007-11-13 08:40:38 PST
This fix is already in 1.6R7. See http://www.mozilla.org/rhino/download.html.
Comment 8 lchen 2007-11-13 17:08:56 PST
I have tried 1.6R7 but seems the issue still can reproduce. I saw the same NoSuchMethodError.

I will try again
Comment 9 lchen 2007-11-13 17:20:59 PST
It's my mistake,it works.
Thank you.

Note You need to log in before you can comment on or make changes to this bug.