Unimplemented classes generate error too early

smurf at noris.de smurf at noris.de
Thu Jun 3 23:33:56 PDT 1999



>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