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

Definite unassignment problem with try/catch

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 1.2.0
    • 1.1.1, 1.1.4
    • tools
    • None
    • 1.2beta4
    • generic, x86
    • generic, windows_95
    • Not verified



      Name: tb29552 Date: 07/30/97


      Reported by: "Roly Perera" <###@###.###>

      In the following code, x is a blank final. Javac allows it to
      be assigned twice:

      void f() {
          final int x;

          try {
              x = 4;
              throw new Exception();
          }
          catch (Exception e) {
              x = 5; // ???
          }
      }

      See a longer example in the Comments section.

      ======================================================================

      Another example (final variable is also static), from 4094677:

      class X {
        static final int i ;
        static {
           try{
             i = 3;
             throw new Throwable();
           }catch(Throwable thb) { i = 4;}
        }

        public static void main( String[] argv ) {
          X ox = new X();
          System.out.println(ox.i);
        }
      }

      william.maddox@Eng 1997-11-21

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

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: