Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8287315

Add APIs and bootstrap methods for classes that implement annotation interfaces

    XMLWordPrintable

Details

    Description

      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.


      Attachments

        Activity

          People

            Unassigned Unassigned
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: