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

Access to static final field before its initiation

    Details

    • Type: Bug
    • Status: New
    • Priority: P3
    • Resolution: Unresolved
    • Affects Version/s: 8, 11
    • Fix Version/s: None
    • Component/s: tools
    • Subcomponent:
    • CPU:
      x86_64
    • OS:
      generic

      Description

      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 ----------

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              webbuggrp Webbug Group
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated: