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

Allow run-time constant support for annotations attribute

    XMLWordPrintable

Details

    Description

      A DESCRIPTION OF THE REQUEST :
      I am considering "static final" types that can be read from application configuration (file/DB ) as runtime constants. My application needs one such annotation attribute as per client requirements.

      private static final int MY_CONST = Integer.parseInt(myConfig.getProperty("ClientDependantAttribute"));

      @MyAnnotation(MyAttribute=MY_CONST) // <- Give error
      public void foo(int bar)

      JUSTIFICATION :
      I want to use great java constructs like aspects and annotations, but because of this limitation it restricts such use.
      Now I have to either add a duplicate perfectly reusable code in every method definitions or use a non-configurable value for annotation attribute.

      I am sure many of other users will appreciate this enhancement.


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      private static final int RETRY_CNT = Integer.parseInt(myConfig.getProperty("RetryCounts"));

      @Retry(maxRetries=RETRY_CNT) // <- This should be acceptable
      public void foo(int bar)

      Attachments

        Activity

          People

            darcy Joe Darcy
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: