[kaffe] java.lang.IllegalAccessError

Ito Kazumitsu kaz at maczuka.gcd.org
Thu Nov 13 07:11:02 PST 2003


>>>>> ":" == Ito Kazumitsu <kaz at maczuka.gcd.org> writes:

:> I hope the last patch of mine will solve this.

But that patch will not work if the nesting of classes gets deeper:

bash-2.05b$ cat a/A.java 
package a;
public class A {
  protected class A1 {
    public A1() {}
  }
}
bash-2.05b$ cat b/B.java 
package b;
import a.A;
public class B extends A {
  public static void main(String[] args) {
    B b = new B();
    b.foo();
  }

  void foo() {
    B1 b1 = new B1();
    B1.B2 b2 = b1.new B2();
    B1.B2.B3 b3 = b2.new B3();
    B1.B2.B3.B4 b4 = b3.new B4();
    b1.bar();
    b2.bar();
    b3.bar();
    b4.bar();
  }

  class B1 {
    void bar() { A1 a1 = B.this.new A1(); }
    class B2 {
      void bar() { A1 a1 = B.this.new A1(); }
      class B3 {
        void bar() { A1 a1 = B.this.new A1(); }
        class B4 {
          void bar() { A1 a1 = B.this.new A1(); }
        }}}}
}
bash-2.05b$ java b.B
java.lang.IllegalAccessError: a/A$A1.<init>
   at b.B$B1$B2.bar (B.java:23)
   at b.B.foo (B.java:15)
   at b.B.main (B.java:6)




More information about the kaffe mailing list