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

Static blank final variables can be assigned twice in try/catch blocks.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P3 P3
    • None
    • 1.1.4
    • tools
    • generic
    • generic


      allan.jacobs@Eng 1997-10-27

      Blank finals should only be initialized once. Static blank final
      variables can be assigned two values in try and catch blocks. The
      following code is derived from Modena (v 2.2) test niner127.

      algol% cat X.java

      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);
        }
      }
      algol% javac -d . X.java
      algol% java X
      4

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

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: