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

wrong handling of declaration of an exception parameter

XMLWordPrintable

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



      Name: ###@###.### Date: 09/05/96

      compiler do not permit to declare an exception parameter
                   of the same name as a variable from the embracing block
                   though there is no prohibition in the Java Language Specification.
                   Moreover such declaration is in effect only within a catch block.
                   So it would be reasonably to suppose that it would screen the
                   declaration of the same name variable from the embracing block.

      Tests: compilation of the following test

      public class test
      {
      public static void main(String argv[])
      {
      float zero = 0.0f, e;

      try {
      e = zero / zero;
      } catch (ArithmeticException e) {
      System.out.println(e.getMessage());
      }
      }
      }

      produces such error diagnostics:

      novo40% javac test.java
      test.java:9: Variable 'e' is already defined in this method.
      } catch (ArithmeticException e) {
      ^
      1 error

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

            fyellinsunw Frank Yellin (Inactive)
            wensunw Wen Wen (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: