VerifyError when compiling jetty

Bjarni Thorisson bjarni@menandmice.com
Wed Jan 29 16:40:00 GMT 2003


Hello, and thanks for the quick reply.
Below is a simple class you can compile into bytecode with gcj and try to
run it. Then this error should occurr:
<--------------------clip----------------------------->
Exception in thread "main" java.lang.VerifyError: (class: Smu$Foo, method:
run signature: ()V) Illegal use of nonvirtual function call
 at Smu.start(Smu.java:28)
 at Smu.main(Smu.java:13)
<-------------------/clip----------------------------->
If the line:
Smu.this.doFoo();
in Foo's run method is commented out, then this error occurrs when run (with
jre 1.3):
<--------------------clip----------------------------->
Exception in thread "main" java.lang.VerifyError: (class: Smu$Foo, method:
<init> signature: (LSmu;)V) Expecting to find object/array on stack
 at Smu.start(Smu.java:28)
 at Smu.main(Smu.java:13)
<-------------------/clip----------------------------->
The later error does not occurr when run in jre 1.4.
<------------------- code begins ----------------------------->
public class Smu
{
	private transient Foo itsFoo= null;
	public Smu()
	{}
	public static void main( String[] args )
	{
		Smu itsSmu= new Smu();
		itsSmu.start();
		itsSmu.stop();
	}
	public boolean isStarted()
	{
		return itsFoo != null;
	}
	public void start()
	{
		if ( itsFoo == null)
		{
			itsFoo= new Foo();
			itsFoo.start();
		}
	}
	public void stop()
	{
		Foo foo= itsFoo;
		itsFoo= null;
		if ( foo != null ) {
			foo.interrupt();
		}
	}
	private void doFoo()
	{
		System.out.println( "foo!" );
	}
	class Foo extends Thread
	{
		public void run()
		{
			try{
				while (isStarted())
				{
					try {
						sleep( 1000 );
						Smu.this.doFoo();
					}
					catch ( InterruptedException ie ) { continue; }
				}
			}
			finally
			{
				Smu.this.itsFoo= null;
			}
		}
		Foo()
		{
			super( "Foo" );
		}
	} // Foo
} // Smu
<------------------- code ends ----------------------------->
Thanks,
Bjarni


More information about the Java mailing list

AltStyle によって変換されたページ (->オリジナル) /