So we have
public abstract class A{ protected abstract String f(); } public class B extends A{ protected String f(){...} } public class C extends A{ protected String f(){ A b = (A) Class.forName("B", true, getClass().getClassLoader()).newInstance(); return bf(); }
This does not allow me to access bf() , saying that bf() is in a protected area, however f was protected by A , and since C extends A , it must also access f() .
source share