import org.springframework.core.annotation.AnnotationUtils; import java.lang.annotation.*; import java.lang.reflect.Method; @Retention(RetentionPolicy.RUNTIME) @interface MyTool { String value(); } interface MyUseCase { @MyTool("hello") void doSomething(); } class MyUseCaseImpl implements MyUseCase { public void doSomething() { } } public class TestAnnotation { public static void main(String[] args) throws Exception { Method m = MyUseCaseImpl.class.getDeclaredMethod("doSomething"); MyTool ann = AnnotationUtils.findAnnotation(m, MyTool.class); System.out.println("Annotation found: " + (ann != null ? ann.value() : "null")); } }