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

Compiler not catching duplicate variable declaration error

XMLWordPrintable

    • 1.1
    • sparc
    • solaris_2.4
    • Not verified

      From mail sent to ###@###.###:

      From ###@###.### Tue Jan 2 10:16 PST 1996
      Date: Tue, 2 Jan 96 08:09:26 -0600
      X-Sender: ###@###.### (Unverified)
      Mime-Version: 1.0
      To: java@java
      From: "David P. Hummel" <###@###.###>
      Subject: JDK 1.0 beta 2 compiler bug?

      Technical Support,

      Consider the following class:

      public class bar {
              void foo() {
                      ;
              }
              int foo;
      }

      I receive the following error when I compile this class:

      "Duplicate variable declaration: int foo was void foo()"

      Now, consider this class with the declarations switched:

      public class bar {
              int foo;
              void foo() {
                      ;
              }
      }

      When I compile this class, I don't receive an error from the
      compiler. According to section 6.1.6 of the Java Specification,
      I was expecting the following error:

      "Duplicate variable declaration: void foo() was int foo"

      (I experience the same behavior using both Windows95 and Solaris
      2.4 versions of the JDK 1.0 beta 2.)

      Does this example expose an bug in the compiler or an bug
      in my understanding of section 6.1.6?

      Thank you.

      - David P. Hummel

            fyellinsunw Frank Yellin (Inactive)
            duke J. Duke
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: