Access to static final field before its initiation

XMLWordPrintable

    • x86_64
    • generic

      A DESCRIPTION OF THE PROBLEM :
      static final field can be accessed befor its initiaion

      possible duplicate of JDK-7193460

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      try to compile and run attached source code

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      compilation error
      ACTUAL -
      output:
      0
      5


      ---------- BEGIN SOURCE ----------
      public class Main {
          private static final int a;
          static {
              System.out.println(Main.a);
              a=5;
              System.out.println(a);
          }
          public static void main(String[] args) {
          }
      }
      ---------- END SOURCE ----------

            Assignee:
            Unassigned
            Reporter:
            Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: