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

Spurious unitialized blank final errors when variable accessed in inner class

XMLWordPrintable

    • generic, x86, sparc
    • generic, solaris_2.6, windows_nt

      This example should be accepted without error.

      % javac C.java
      C.java:17: Blank final variable 'o' may not have been initialized. It must be assigned a value in an initializer, or in every constructor.
        private final Object o;
                              ^
      1 error

      //(company - UCAR , email - ###@###.###)
      /*
       * Compiling produces the error message:
       * C.java:10: Blank final variable 'o' may not have
       * been initialized. It must be assigned a value in
       * an initializer, or in every constructor.
       */
      public class C { // slight variation of Bug Id 4056774
        C() {
          o = null;
        }
        class R {
          void printo() {
            System.out.println(o);
          }
        }
        private final Object o;
      }

      william.maddox@Eng 1998-06-10


      Name: skT88420 Date: 10/06/99


      javac does not compile a valid java code.
      It prints

       javac com/polytechnik/datainterface/SimpleDataReaderWithoutDatabase.java
      com/polytechnik/datainterface/SimpleDataReaderWithoutDatabase.java:47: Blank final variable 'LOOKUPINDEXESNAME' may not have been initialized. It must be assigned a value in an initializer, or in every constructor.
        private final static Dictionary LOOKUPINDEXESNAME,LOOKUPINDEXESID,FUNCTIONSETS,TIMESERIES,ENTITIESWITHLOCALTIMESERIES;
                                                         ^
      com/polytechnik/datainterface/SimpleDataReaderWithoutDatabase.java:47: Blank final variable 'LOOKUPINDEXESID' may not have been initialized. It must be assigned a value in an initializer, or in every constructor.
        private final static Dictionary LOOKUPINDEXESNAME,LOOKUPINDEXESID,FUNCTIONSETS,TIMESERIES,ENTITIESWITHLOCALTIMESERIES;
                                                                         ^
      com/polytechnik/datainterface/SimpleDataReaderWithoutDatabase.java:47: Blank final variable 'FUNCTIONSETS' may not have been initialized. It must be assigned a value in an initializer, or in every constructor.
        private final static Dictionary LOOKUPINDEXESNAME,LOOKUPINDEXESID,FUNCTIONSETS,TIMESERIES,ENTITIESWITHLOCALTIMESERIES;
                                                                                      ^
      com/polytechnik/datainterface/SimpleDataReaderWithoutDatabase.java:47: Blank final variable 'TIMESERIES' may not have been initialized. It must be assigned a value in an initializer, or in every constructor.
        private final static Dictionary LOOKUPINDEXESNAME,LOOKUPINDEXESID,FUNCTIONSETS,TIMESERIES,ENTITIESWITHLOCALTIMESERIES;
                                                                                                 ^
      com/polytechnik/datainterface/SimpleDataReaderWithoutDatabase.java:47: Blank final variable 'ENTITIESWITHLOCALTIMESERIES' may not have been initialized. It must be assigned a value in an initializer, or in every constructor.
        private final static Dictionary LOOKUPINDEXESNAME,LOOKUPINDEXESID,FUNCTIONSETS,TIMESERIES,ENTITIESWITHLOCALTIMESERIES;
                                                                                                                             ^
      com/polytechnik/datainterface/SimpleDataReaderWithoutDatabase.java:123: Blank final variable 'TIMETOHOLDIDLE' may not have been initialized. It must be assigned a value in an initializer, or in every constructor.
        static final long TIMETOHOLDIDLE;
                                        ^
      com/polytechnik/datainterface/SimpleDataReaderWithoutDatabase.java:126: Blank final variable 'PERIODTOCLEAR' may not have been initialized. It must be assigned a value in an initializer, or in every constructor.
        static final long PERIODTOCLEAR;
                                       ^
      com/polytechnik/datainterface/SimpleDataReaderWithoutDatabase.java:129: Blank final variable 'MAXENTRIES' may not have been initialized. It must be assigned a value in an initializer, or in every constructor.
        static final int MAXENTRIES;
                                   ^
      com/polytechnik/datainterface/SimpleDataReaderWithoutDatabase.java:132: Blank final variable 'DELAYBEFORECLEANING' may not have been initialized. It must be assigned a value in an initializer, or in every constructor.
        static final long DELAYBEFORECLEANING;
                                             ^
      com/polytechnik/datainterface/SimpleDataReaderWithoutDatabase.java:135: Blank final variable 'MAX_SIMULTANEOUS_CONNECTIONS' may not have been initialized. It must be assigned a value in an initializer, or in every constructor.
        final static int MAX_SIMULTANEOUS_CONNECTIONS;
                                                     ^
      com/polytechnik/datainterface/SimpleDataReaderWithoutDatabase.java:138: Blank final variable 'STARTINGTIME' may not have been initialized. It must be assigned a value in an initializer, or in every constructor.
        final static long STARTINGTIME;
                                      ^
      com/polytechnik/datainterface/SimpleDataReaderWithoutDatabase.java:141: Blank final variable 'HOURTOEXPIRE' may not have been initialized. It must be assigned a value in an initializer, or in every constructor.
        final static long HOURTOEXPIRE;
                                      ^
      com/polytechnik/datainterface/SimpleDataReaderWithoutDatabase.java:370: Blank final variable 'timeseriecache' may not have been initialized. It must be assigned a value in an initializer, or in every constructor.
        private final Dictionary timeseriecache;
                                               ^
      com/polytechnik/datainterface/SimpleDataReaderWithoutDatabase.java:371: Blank final variable 'dummydouble' may not have been initialized. It must be assigned a value in an initializer, or in every constructor.
        private final double [] dummydouble;
                                           ^
      14 errors

      The relevant part of the source is
      (there is only one constructor).

        /** Timeserie Cache. */
        private final Dictionary timeseriecache;
        private final double [] dummydouble;
        // private final long [] dummylong;

        private SimpleDataReaderWithoutDatabase(long t_from,long t_to,long expiration_time)
          {
            super(t_from,t_to,expiration_time);
            this.timeseriecache=new Hashtable(200);
            this.dummydouble=new double [super.timepointsarray.length];
            // this.dummylong=new long [super.timepointsarray.length];
            for(int i=0;i<this.dummydouble.length;i++)
      {
      this.dummydouble[i]=Double.NaN;
      // this.dummylong[i]=0L;
      }
          }

      and
       /** The time to hold the entries. */
        static final long TIMETOHOLDIDLE;

        /** How often to clear cache. */
        static final long PERIODTOCLEAR;

        /** Maximal number of entries in cache. */
        static final int MAXENTRIES;

        /** A delay before cleaning. */
        static final long DELAYBEFORECLEANING;

       /** Maximal number of simultaneously open connections. */
        final static int MAX_SIMULTANEOUS_CONNECTIONS;

        /** Starting time for historical data. */
        final static long STARTINGTIME;

        /** An hour when the reader is expired (currently 18:00). */
        final static long HOURTOEXPIRE;

      where all these
      fields are initialized inside
      static {

      }
      clause.

      It does not print this error if I try to extract just
      the code of above.
      I can send an original program
      (it is pretty big, 120Kb) if requested.

      Vladislav
      (Review ID: 96066)
      ======================================================================

            wmaddoxsunw William Maddox (Inactive)
            wmaddoxsunw William Maddox (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: