[kaffe] difference between kaffe and Sun's JDK: IllegalAccessException
    Ito Kazumitsu 
    ito.kazumitsu at mail.hidec.co.jp
       
    Sun Apr 18 19:41:02 PDT 2004
    
    
  
Hi,
The attached program,
  - when run with Sun's JDK (java version "1.4.2_04"), throws
    java.lang.IllegalAccessException.
  - when run with Kaffe,  ends normally.
Is this Sun's bug incorrectly checking the accessibility,
or Kaffe's bug neglecting a necessary accessibility checking?
I would like to think this is Sun's bug.
bash$ cat a/A.java
package a;
import java.lang.reflect.Method;
public class A {
    public static void main(String[] args) throws Exception {
        new A();
    }
    public A() throws Exception {
        new A1();
    }
    private class A1 extends b.B {
        A1() throws Exception {
            execFoo();
        }
        public Method getFoo() {
            try {
                return A1.class.getMethod("foo", null);
            }
            catch (NoSuchMethodException e) {
                return null;
            }
        }
        public void foo() {
            System.out.println("foo");
        }
    }
}
bash$ cat b/B.java
package b;
import java.lang.reflect.Method;
public abstract class B {
    public abstract Method getFoo();
    public void execFoo() throws Exception {
        getFoo().invoke(this, null);
    }
}
bash$ java a.A
java.lang.IllegalAccessException: Class b.B can not access a member of class a.A$A1 with modifiers "public"
	at sun.reflect.Reflection.ensureMemberAccess(Reflection.java:57)
	at java.lang.reflect.Method.invoke(Method.java:317)
	at b.B.execFoo(B.java:7)
	at a.A$A1.<init>(A.java:16)
	at a.A.<init>(A.java:10)
	at a.A.main(A.java:6)
Exception in thread "main" bash$ 
bash$ kaffe a.A
foo
    
    
More information about the kaffe
mailing list