[kaffe] Should IllegalAccessException be thrown or not?

Ito Kazumitsu kaz at maczuka.gcd.org
Fri Dec 9 18:18:13 PST 2005

From: Ito Kazumitsu <kaz at maczuka.gcd.org>
Subject: Re: [kaffe] ecj-compiled kaffe fails in regression tests
Date: Fri, 09 Dec 2005 15:03:16 +0900 (JST)

> Sun's JDK gives this (when DEBUG is set to true):
> Generating canonical stream
>   Serializing TestSerialFields$Test0001
>     Exception: java.lang.IllegalAccessException
> java.lang.IllegalAccessException: Class TestSerialFields can not access a member of class TestSerialFields$Test0001 with modifiers "private"
>         at sun.reflect.Reflection.ensureMemberAccess(Reflection.java:65)
>         at java.lang.Class.newInstance0(Class.java:344)
>         at java.lang.Class.newInstance(Class.java:303)
>         at TestSerialFields.generateBytes(TestSerialFields.java:529)
>         at TestSerialFields.main(TestSerialFields.java:623)
> Exception in thread "main" java.lang.NullPointerException
>         at TestSerialFields.checkClass(TestSerialFields.java:604)
>         at TestSerialFields.main(TestSerialFields.java:633)
> If Sun's JDK is correct, Kaffe fails to detect this IllegalAccessException
> and the regression tests have been depending on such behavour of Kaffe.

I have made a simpler test case.

public class TestPrivateClass {
	private static class Test0001 {

	public static void main(String[] args) {
		try {
			Object obj = Test0001.class.newInstance();
		catch (Exception e) {

This ends normally when run on Kaffe, but when run on Sun's JDK,

java.lang.IllegalAccessException: Class TestPrivateClass can not access a member of class TestPrivateClass$Test0001 with modifiers "private"
        at sun.reflect.Reflection.ensureMemberAccess(Unknown Source)
        at java.lang.Class.newInstance0(Unknown Source)
        at java.lang.Class.newInstance(Unknown Source)
        at TestPrivateClass.main(TestPrivateClass.java:7)

More information about the kaffe mailing list