I got a very weird problem and a weird solution:
class Parent {
protected void aProtectedMethod() { doSomething(); }
}
class Child extends Parent {
void anotherMethod() {
new SomeInterface() {
public void interfaceMethod() {
aProtectedMethod();
}
};
}
}
When child.anotherMethod() is run, I got IllegalAccessException at myProtectedMethod(), saying my inner class doesn't have access to the Parent class...
However, if I add:
protected void aProtectedMethod() { super.aProtectedMethod(); }
in my Child class, everything is fine...
I wonder why this is?