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

final variable constructor assignment checking broken in 1.2ea

    • sparc
    • solaris_2.6



      Name: igT44549 Date: 02/08/99


      Given the following code:

      class Test
      {
          final int x ;
          Test()
          {
              try
              {
                  x = f() ;
              }
              catch(Exception e)
              {
                  x = 0 ;
              }
              System.err.println("x=" + x) ;
          }
          int f() throws Exception
          {
              return 1 ;
          }
      }

      javac from the jdk1.1.7 compiles this code successfully.
      javac from the jdk1.2ea results in the following errors:

      Test.java:3: Blank final variable 'x' may not have been initialized. It must be assigned a value in an initializer, or in every constructor.
              final int x ;
                          ^
      Test.java:12: Can't assign a second value to a blank final variable: x
                              x = 0 ;
                              ^
      Test.java:14: Variable x may not have been initialized.
                      System.err.println("x=" + x) ;
                                                ^
      3 errors
      (Review ID: 49071)
      ======================================================================

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

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: