Detail
#27843
Missing annotation @Retention(RUNTIME) at the annotation @NoDialogContentCheck
The @Retention(RUNTIME) meta-annotation is missing from the @NoDialogContentCheck annotation. As a result, it may not be available at runtime. Because the default for @Retention is: RetentionPolicy.CLASS And that leaves it to the arbitrariness of the JVM:
Annotations are to be recorded in the class file by the compiler but **need not be retained by the VM at run time**. This is the default behavior.
As a result, the annotation @NoDialogContentCheck is sometimes not found at runtime, which means that dialogs may not be opened by mistake.
There are probably a handful of other such cases. A text search in *.java files finds 120 hits for @interface, but only 113 for @Retention.
Implementation
- All annotations get a retention annotation.
- All annotations get the retention RUNTIME.
Reason: This ensures that no annotations are lost at runtime and we do not have to worry about correct retention. The fact that Java does not retain all annotations until runtime but throws some away beforehand dates back to 2002, when memories were much smaller than they are today. Today, this distinction is no longer necessary.
Test
- Search for @interface in *.j ava files.
- Search for the following regex in *.java files: @Retention\((RetentionPolicy\.)?RUNTIME\)
- Both searches must return the same number of results.