fork download
  1. @interface Foo {
  2. int abc();
  3. }
  4.  
  5. interface Parent {
  6. default void printAbc() {
  7. int abc = this.getClass().getDeclaredAnnotation(Foo.class).abc();
  8. System.out.println(abc);
  9. }
  10. }
  11.  
  12. @Foo(abc = 123)
  13. class Child implements Parent {
  14. public static void main(String[] args) {
  15. new Child().printAbc();
  16. }
  17. }
Runtime error #stdin #stdout #stderr 0.06s 32516KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
Exception in thread "main" java.lang.NullPointerException
	at Parent.printAbc(Main.java:7)
	at Child.main(Main.java:15)