Initialization test

Artur Biesiadowski abies at pg.gda.pl
Wed Oct 28 03:01:03 PST 1998


I'm sorry if you will get multiple copies of that mail.

Attached is test for class initialization. I know that it might be hard
to conform to it, but specs say so. I know for sure that tya fails this
test, I haven't checked kaffe and japhar, because I do not have them at
hand.

Feel free to include it into your regression testing if you do not have
something similar yet.

Artur
-------------- next part --------------
public class InitTest
{
	static boolean passed = true;

	public static void main(String argv[] )
	{
		int x;
		if ( argv.length > 10 )
		{
			x = Class1.field;
			Class1.field = 5;
			Class3.runMe();
		}
		else
		{
			Class2.field = 5;
			Class2.runMe();
		}

		x = Class4.finalfield;

		if ( passed )
			System.out.println("PASSED");
		else
			System.out.println("FAILED");
	}
}

class Class1
{
	static int field;
	static {
		System.out.println("Class1 clinit - WRONG(static access)");
		InitTest.passed = false;
	}
}

class Class2
{
	static int field;
	static {
		System.out.println("Class2 clinit");
	}

	static void runMe() {}
}

class Class3
{
	static {
		System.out.println("Class3 clinit - WRONG(static mcall)");
		InitTest.passed = false;
	}

	static void runMe() {}
}

class Class4
{
	final static int finalfield = 5;
	static {
		System.out.println("Class4 clinit - WRONG(final static access)");
		InitTest.passed = false;
	}
}


More information about the kaffe mailing list