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

(scope) static final variable declared after use and self initialized

XMLWordPrintable

    • b57
    • x86
    • windows_xp
    • Verified

      Name: tb29552 Date: 04/15/2003


      public class FinalStaticBug {
          public static void main(String[] p_args)
          {
              System.out.println("Order By: " + ORDER_BY_DATE_TIME);
          }

          private static final String ORDER_BY_DATE_TIME = ORDER_BY_DATE_TIME;
      }


      Compiles OK using javac from 1.3.1 and 1.4.x, reporting 'null'
      at runtime:

      % javac -g -J-showversion FinalStaticBug.java
      java version "1.3.1"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1-b24)
      Java HotSpot(TM) Client VM (build 1.3.1-b24, mixed mode)

      % java FinalStaticBug
      Order By: null

      The oldjavac compiler in 1.3.1 reports an error at compile time:

      % oldjavac -g -J-showversion FinalStaticBug.java
      java version "1.3.1"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1-b24)
      Java HotSpot(TM) Client VM (build 1.3.1-b24, mixed mode)

      FinalStaticBug.java:7: Can't make forward reference to ORDER_BY_DATE_TIME in class FinalStaticBug.
          private static final String ORDER_BY_DATE_TIME = ORDER_BY_DATE_TIME;
                                                           ^
      1 error



      (Review ID: 184134)
      ======================================================================
      ###@###.### 10/25/04 21:26 GMT

            ahe Peter Ahe
            tbell Tim Bell
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: