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

Support for default value of annotation member in reflection API

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Duplicate
    • Icon: P3 P3
    • None
    • 5.0
    • core-libs



      Name: siR10004 Date: 12/02/2003



      Removing default value of an annotation member leads to incompatible
      change in API. For example, let us consider the following example from
      the JSR 175 specification :

      --------------------------------------------------------------------------
      // Annotation type declaration with defaults on some members
      public @interface RequestForEnhancement {
          int id(); // No default - must be specified in each annotation
          String synopsis(); // No default - must be specified in each annotation
          String engineer() default "[unassigned]";
          String date() default "[unimplemented]";
      }

      ...
      // Normal annotation with default values
      @RequestForEnhancement(
          id = 4561414,
          synopsis = "Balance the federal budget"
      )
      public static void balanceFederalBudget() {
          throw new UnsupportedOperationException("Not implemented");
      }
      ...
      --------------------------------------------------------------------------

      If default value of 'engineer' (or 'date') is removed from the definition
      of 'RequestForEnhancement' this example could not be compiled without error.

      However, reflection support for metadata (CCC 4891872) is missing
      the feature to recognize an annotation members with (without) default value.
      This feature is important for the new jck sigtest for Tiger.

      ======================================================================

            jjb Josh Bloch
            duke J. Duke
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: