У меня есть родительский класс Parent
и дочерний класс Child
, определяемый таким образом:
class Parent {
@MyAnnotation("hello")
void foo() {
// implementation irrelevant
}
}
class Child {
@Override
foo() {
// implementation irrelevant
}
}
Если я получаю ссылку Method
на Child::foo
, будет childFoo.getAnnotation(MyAnnotation.class)
дать мне @MyAnnotation
? Или это будет null
?
Мне интереснее узнать, как или с аннотацией работает с наследованием Java.