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

var in resource specification can be redeclared as exception parameter in catch clause

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not an Issue
    • Icon: P4 P4
    • None
    • 7
    • tools
    • generic
    • generic

      ccc write-up specifies:
      "...the name of the variable may not be...redeclared as an exception parameter of a catch clause in a try statement of the directly enclosing method or initializer block"
      but this code compiles without error:
      public class negtest06 {
        String test1( ) {
          String ret = null;
          try {
            try ( java.io.FileInputStream str = new java.io.FileInputStream("foo.txt") ) {
              ret = str.getClass().getSimpleName();
            } catch( Exception str) {}
          } catch ( Exception str ) {}
          return ret;
        }
      }

            darcy Joe Darcy
            ssides Steve Sides
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: