JDK-4962037 : Support for default value of annotation member in reflection API
  • Type: Enhancement
  • Component: core-libs
  • Sub-Component: java.lang:reflect
  • Affected Version: 5.0
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: generic
  • CPU: generic
  • Submitted: 2003-12-02
  • Updated: 2012-09-28
  • Resolved: 2004-02-04
Related Reports
Duplicate :  
Description

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.

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