I\'m following this tutorial on Java annotaitons and implemented the Test annotation as shown there. But when running the code I get the following output.
java.l
This issue is here:
method.invoke(null);
This method's first parameter is the object to invoke the method on. This is the dynamic (reflection) equivalent of something like this:
Object foo = null;
foo.toString();
Of course we would expect this code to give a NullPointerException
because foo
is null
.