Hi Ito,

Here is a better example. The previous could not be compiled directly if you try to compile indepedently then you'll see the runtime accepts it. Here I have an example which compiles and should run on a VM. However kaffe throws an IllegalAccessError.

Regards,

Guilhem.

Ito Kazumitsu wrote:

From: Ito Kazumitsu <[EMAIL PROTECTED]>
Date: Thu, 22 Dec 2005 11:08:15 +0900 (JST)

The runtime access control is much simpler than the compile-time
access control.  And we may be able to omit the checking of nested
relations of classes at runtime.

Simply omitting the checking of nested relations of classes
causes IllegalAccessError, which was reported in November, 2003.

I am afraid Sun's VM spec:

A class or interface C is accessible to a class or interface D if and only if
either of the following conditions are true:

(Runtime):
  - C is public.
  - C and D are members of the same runtime package.

is incomplete and something should be said about the case
where C is protected.

Attached below is my proposed patch.  I have deleted the
checking of outer classes for determining slot_acc,
but kept such checking for determining class_acc.

With this patch applied,

  - All the regression tests pass.
  - Mauve test gnu.testlet.java.lang.Class.newInstance shows the
    same results as Sun's JDK.
  - The testcase attached to
    http://www.kaffe.org/pipermail/kaffe/2003-November/096187.html
    passes.

package a;

public class legal1
{
	static protected class A
	{
		public int b;
	}

	static public A getA()
	{
		A a = new A();

		a.b = 1;
		return a;
	}
}
import a.*;

public class legal2 extends legal1
{
	static public void main(String args[])
	{
		final legal1.A a = legal1.getA();
		Object o;
		
		o = new Object() {
			public String toString() 
			{
				return (new Integer(a.b)).toString();
			}
		};
		System.out.println(o);
	}
}
_______________________________________________
kaffe mailing list
kaffe@kaffe.org
http://kaffe.org/cgi-bin/mailman/listinfo/kaffe

Reply via email to