Currently, the HotSpotVM looks for a set of per-method annotations so that it can treat these methods specially later on. These annotations are:
sun_reflect_CallerSensitive_signature
java_lang_invoke_ForceInline_signature
java_lang_invoke_DontInline_signature
java_lang_invoke_InjectedProfile_signature
java_lang_invoke_LambdaForm_Compiled_signature
java_lang_invoke_LambdaForm_Hidden_signature
jdk_internal_HotSpotIntrinsicCandidate_signature
java_lang_invoke_Stable_signature
sun_misc_Contended_signature
There are two problems with these annotations:
Problem 1:
All annotations are specific to the HotSpot VM but they are located in four different classes. To improve the consistency of the JDK codebase, it would be good it all annotations were located in the same package.
Problem 2:
The annotations are likely to not be useful for anyone except the HotSpot VM, but all annotations have RetentionPolicy.Runtime. A more appropriate annotation type could be RetentionPolicy.Class.
The reason for retention policy Runtime for these classes is the way the HotSpot VM currently processes annotations. Annotations not visible at runtime are already "gone" by the time the above-listed special annotations are processed and their presence is noted by the VM (in ClassFileParser::AnnotationCollector::annotation_index). It would be good to change the VM to process special annotations earlier (or to retain them until a later point at class loading) and then also change the retention policy of all the above-listed classes to Class.