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

Class.getDeclaredAnnotations presents annotations parameters in random order

    XMLWordPrintable

    Details

      Description

      ADDITIONAL SYSTEM INFORMATION :
      Picked up _JAVA_OPTIONS: -Dawt.useSystemAAFontSettings=gasp
      java version "1.8.0_151"
      Java(TM) SE Runtime Environment (build 1.8.0_151-b12)
      Java HotSpot(TM) 64-Bit Server VM (build 25.151-b12, mixed mode)

      A DESCRIPTION OF THE PROBLEM :
      Class.getDeclaredAnnotations sometimes presents annotations parameters in different order when executing the following program

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. Compile the program
      2. Run it using Oracle HotSpot java

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Annotations parameters always in the same order.
      ACTUAL -
      Sometimes A(name=A, namespace=B), sometimes A(namespace=B, name=A).

      ---------- BEGIN SOURCE ----------
      @Retention(RUNTIME)
      public @interface A {
          String name() default "A";
          String namespace() default "B" ;
      }

      @A()
      public class B {
          public static void main(String[] args) {
      for(Annotation a : B.class.getDeclaredAnnotations()) {
      System.out.println(a);
      }
          }
      }
      ---------- END SOURCE ----------

      FREQUENCY : often


        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                fmatte Fairoz Matte
                Reporter:
                webbuggrp Webbug Group
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: