تعليقات توضيحية مخصصة
في هذا الدرس 4 موضوعات
هذا الدرس مخطط له. يعرض المخطط أدناه الموضوعات التي سيغطيها، ولم يُنشر الدرس الكامل بعد.
نص الدروس والتمارين باللغة الإنجليزية، بينما تبقى واجهة الموقع وعناوين الدروس بالعربية.
في هذا الدرس
define and read a runtime annotation.
الموضوعات المخطط لها
- Declare with
@interface; elements look like methods. - Meta-annotations:
@Retention(RUNTIME)so reflection can see it;@Targetlimits where it applies. - Without RUNTIME retention the annotation is invisible at runtime.
- Read with
method.isAnnotationPresentorgetAnnotation. - Frameworks pair annotations with reflection or proxies.
تفاصيل المخطط المبدئي
عرض عملي
@Retention(RetentionPolicy.RUNTIME) @Target(ElementType.METHOD)
@interface Audited { String action() default ""; }اختبر فهمك
What happens with @Retention(SOURCE)?
أظهر الإجابة
The annotation is dropped before runtime, so reflection cannot see it.
التطبيق
طبّق هذا الدرس بمختبر الوحدة وتمارينها واختبارها.
تعليم الدرس كمكتمل اختياري ويمكنك التراجع عنه في أي وقت. يبقى تقدمك محفوظًا في هذا المتصفح.