Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

java.lang.VerifyError thrown executing ClassCompiler produced class

39 views
Skip to first unread message

darrel karisch

unread,
Feb 27, 2008, 1:17:23 PM2/27/08
to
I am experiencing a problem with ClassCompiler with some of my scripts
using either rhino 1.6 or 1.7
js.jar manifests...

rhino 1.6 from 11/18/2006
Manifest-Version: 1.0
Ant-Version: Apache Ant 1.6.5
Created-By: 1.5.0_06-b05 (Sun Microsystems Inc.)
Main-Class: org.mozilla.javascript.tools.shell.Main
Class-Path: xbean.jar

rhino 1.7 from 8/19/2007
Manifest-Version: 1.0
Ant-Version: Apache Ant 1.6.5
Created-By: 1.5.0_07-b03 (Sun Microsystems Inc.)
Main-Class: org.mozilla.javascript.tools.shell.Main
Class-Path: xbean.jar

the following contrived code example exhibits the problem producing a
java.lang.VerifyError when a new instance is created.
verifyError.js

var o = new Object;
o.setX = function (id) {
this.oid = id;
}
function setX(n) {
if (n == "" || n == null)
n = 0;

var s = new Object;
s.xyz = n;

if(s != null) {
o.setX(s.xyz);
}
}
setX('x');

all compilations using jdk1.6...
> java -version
java version "1.6.0_01-ea"
Java(TM) SE Runtime Environment (build 1.6.0_01-ea-b03)
Java HotSpot(TM) Server VM (build 1.6.0_01-ea-b03, mixed mode)

> java org.mozilla.javascript.tools.jsc.Main -nosource -O 9 -version 160 verifyError.js
> java org.mozilla.javascript.tools.jsc.Main verifyError

Exception in thread "main" java.lang.VerifyError: (class: verifyError,
method: _c2 signature: (LverifyError;Lorg/mozilla/javascript/
Context;Lorg/mozilla/javascript/Scriptable;Lorg/mozilla/javascript/
Scriptable;Ljava/lang/Object;D[Ljava/lang/Object;)Ljava/lang/Object;)
Register 4 contains wrong type
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Class.java:2389)
at java.lang.Class.getConstructor0(Class.java:2699)
at java.lang.Class.newInstance0(Class.java:326)
at java.lang.Class.newInstance(Class.java:308)


changing version to 120 or 140 has no effect...

> java org.mozilla.javascript.tools.jsc.Main -nosource -O 9 -version 140 verifyError.js
> java org.mozilla.javascript.tools.jsc.Main verifyError

Exception in thread "main" java.lang.VerifyError: (class: verifyError,
method: _c2 signature: (LverifyError;Lorg/mozilla/javascript/
Context;Lorg/mozilla/javascript/Scriptable;Lorg/mozilla/javascript/
Scriptable;Ljava/lang/Object;D[Ljava/lang/Object;)Ljava/lang/Object;)
Register 4 contains wrong type


changing optimization to 1 has no effect...

> java org.mozilla.javascript.tools.jsc.Main -nosource -O 1 -version 140 verifyError.js
> java org.mozilla.javascript.tools.jsc.Main verifyError

Exception in thread "main" java.lang.VerifyError: (class: verifyError,
method: _c2 signature: (LverifyError;Lorg/mozilla/javascript/
Context;Lorg/mozilla/javascript/Scriptable;Lorg/mozilla/javascript/
Scriptable;Ljava/lang/Object;D[Ljava/lang/Object;)Ljava/lang/Object;)
Register 4 contains wrong type

changing optimization to -1 or zero works...

> java org.mozilla.javascript.tools.jsc.Main -nosource -O 0 -version 140 verifyError.js
> java org.mozilla.javascript.tools.jsc.Main verifyError

no exception thrown.

oddly enough, certain minor code changes cure the problem. e.g.

comment out...
/*
if (n == "" || n == null)
n = 0;
*/

or comment out...
// o.setX(s.ID);

or change...
s.xyz = 1;

or...

change one of the function names so that they are different.

each of these trivial modifications cures the problem in all
compilation cases.

darrel karisch

unread,
Feb 27, 2008, 4:31:30 PM2/27/08
to
correction. the class is executed with the appropriate classpath
thusly...

> java -classpath $classpath verifyError

Norris Boyd

unread,
Feb 27, 2008, 10:44:19 PM2/27/08
to

Norris Boyd

unread,
Feb 28, 2008, 8:35:03 PM2/28/08
to

Thanks for finding and isolating this problem. The compiler's
optimization to represent numbers as primitives rather than objects
was confused.

I've now checked in a fix to CVS.

--N

0 new messages