Last Comment Bug 391349 - Exception on startup on JDK 1.4
: Exception on startup on JDK 1.4
Product: Rhino
Classification: Components
Component: Core (show other bugs)
: 1.6R6
: x86 Linux
-- normal (vote)
: ---
Assigned To: Norris Boyd
Depends on:
  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:
QA Whiteboard:
Iteration: ---
Points: ---

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 User image 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

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:


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?


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

Checking in src/org/mozilla/javascript/jdk15/;
/cvsroot/mozilla/js/rhino/src/org/mozilla/javascript/jdk15/,v  <--
new revision:; previous revision: 1.1
Comment 2 User image 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 User image 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 Please try it out.

Checking in src/org/mozilla/javascript/jdk15/;
/cvsroot/mozilla/js/rhino/src/org/mozilla/javascript/jdk15/,v  <--
new revision:; previous revision:
Comment 4 User image 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 User image 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/;
/cvsroot/mozilla/js/rhino/src/org/mozilla/javascript/jdk15/,v  <--
new revision: 1.5; previous revision: 1.4
Comment 6 User image lchen 2007-11-13 01:35:43 PST
Can you tell me which build will include this fix?
Comment 7 User image Norris Boyd 2007-11-13 08:40:38 PST
This fix is already in 1.6R7. See
Comment 8 User image 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 User image 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.