Unimplemented classes generate error too early

Godmar Back gback at cs.utah.edu
Mon Jun 7 20:11:51 PDT 1999



 Matthias,

thanks for the bug reports.  

Kaffe's jit compiles a method at a time.
It expects to load most classes that are referred to in this 
method at this point in time.

This also explains your complaint about where ClassNotFoundErrors are
reported (the other mail you sent.), I believe.

The JLS gives VM implementors large freedom in deciding when classes
are resolved, so I don't think we're out of "spec" here.
Somebody with better knowledge of the JLS prove me wrong on this.

It's unfortunate that browser have come to rely on such unspecified
behavior.  As a work-around, use the Class.forName("bar", null, false) 
method within a method that does not refer to bar directly.

Thinking about it, this is probably the only sanctioned method of
testing for whether a class exists.

	- Godmar

ps:  there's now a jitterbug database at www.kaffe.org, so whatever
script you used to submit this bug is obsolete.

> 
> 
> 
> >Submitter-Id:  kaffe-user
> >Originator: 	Matthias Urlichs
> >Organization:	noris network GmbH, Nuernberg, Germany
> >Confidential:  no
> >Synopsis:	Unknown classes generate errors even when the class is never needed
> >Severity:	critical
> >Priority:	medium
> >Category: 	
> >Class:		sw-bug
> >Release:	
> >Environment:
> 	System: Linux play 2.3.3-noris-ac2 #5 SMP Tue May 25 13:50:39 MEST 1999 i686 unknown
> 	Architecture: i686
> 	Machine: Unknown
> >Description:
> 	If a class conditionally requires another class which is unknown,
> 	Java should cause an exception only when that class is actually
> 	required, not when loading the class.
> 
> 	This is important when running applets which conditionally use
> 	classes for specific browsers.
> 
> >How-To-Repeat:
> 
> ====================== HelloWorldApp.java
> import test.foo;
> class HelloWorldApp {
> 	public static void main (String args[]) {
> 		test.foo xxx = new test.foo();
> 		System.out.println("Hello World!");
> 		xxx.foof();
> 	}
> }
> ====================== test/foo.java
> package test;
> import test.bar;
> public class foo 
> {
> 
>     public foo()
>     { x_foof = false; }
> 	public void foof() {
> 		if (x_foof) {
> 			System.out.println("do Bar");
> 			test.bar baa = new test.bar(); x_foof = baa.baab();
> 		} else
> 			System.out.println("no Bar needed");
> 	}
> 
>     boolean x_foof;
> }
> ====================== test/bar.java
> 
> package test;
> public class bar
> {
> 	public bar() {}
> 	public boolean baab() { return true; }
> }
> ======================
> 
> Compile all three, then remove test/bar.class.
> 
> Expected output:
> Hello World!
> no Bar needed
> 
> Actual output:
> Hello World!
> java.lang.NoClassDefFoundError: test/bar
> 
> >Fix:
> 	
> 



More information about the kaffe mailing list