मैं इस तरह अपने ही टिप्पणी का प्रकार बनाया है:जावा में कक्षा एनोटेशन कैसे प्राप्त करें?
public @interface NewAnnotationType {}
और एक वर्ग के लिए यह संलग्न:
@NewAnnotationType
public class NewClass {
public void DoSomething() {}
}
और मैं इस तरह प्रतिबिंब के माध्यम से वर्ग एनोटेशन प्राप्त करने की कोशिश:
Class newClass = NewClass.class;
for (Annotation annotation : newClass.getDeclaredAnnotations()) {
System.out.println(annotation.toString());
}
लेकिन यह कुछ भी प्रिंट नहीं कर रहा है। मैं क्या गलत कर रहा हूं?
तो एक एनोटेशन संकलन समय पर ही उपलब्ध है। –