org.aspectj/tests/hasmember/HasPrivateFieldInherited.aj

28 lines
514 B
Plaintext

public aspect HasPrivateFieldInherited {
declare parents : D && hasfield(* printer) implements Printable;
public static void main(String[] args) {
C c = new C();
if ((c instanceof Printable)) {
throw new RuntimeException("declare parents : hasfield failed on super");
}
D d = new D();
if ((d instanceof Printable)) {
throw new RuntimeException("declare parents : hasfield failed on sub");
}
}
}
class C {
private String printer;
}
class D extends C {
}
interface Printable {};