-
Enhancement
-
Resolution: Unresolved
-
P4
-
None
-
19, 20, 21
-
generic
-
generic
A DESCRIPTION OF THE PROBLEM :
Currently, any project which intends to create a custom subclass of an annotation interface has to reinvent the wheel to correctly implement all the methods specified in `java.lang.annotation.Annotation` and the annotation interface, because the JDK’s implementation is stored in private methods of `sun.reflect.annotation.AnnotationInvocationHandler`.
I propose to add a public API to `java.lang.runtime` for creating `MethodHandle`s and `CallSite`s like `java.lang.runtime.ObjectMethods`, but for `Annotation`s instead of `Record`s.
--------------------------------------------------------------------------------
Additionally, it would be a quality‑of‑life improvement if compiled annotation interfaces provided default implementations for methods with an `AnnotationDefault` attribute and the `Annotation.annotationType()` method.
Currently, any project which intends to create a custom subclass of an annotation interface has to reinvent the wheel to correctly implement all the methods specified in `java.lang.annotation.Annotation` and the annotation interface, because the JDK’s implementation is stored in private methods of `sun.reflect.annotation.AnnotationInvocationHandler`.
I propose to add a public API to `java.lang.runtime` for creating `MethodHandle`s and `CallSite`s like `java.lang.runtime.ObjectMethods`, but for `Annotation`s instead of `Record`s.
--------------------------------------------------------------------------------
Additionally, it would be a quality‑of‑life improvement if compiled annotation interfaces provided default implementations for methods with an `AnnotationDefault` attribute and the `Annotation.annotationType()` method.