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

import of class declared in compilation unit: allowed or no?

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 5.0
    • 1.4.0
    • specification
    • 5.0
    • generic
    • solaris_8
    • Verified

      The following test, narrowed down from from jacks 7.5.1-canonical-1,
      distinguishes javac 1.3 from javac 1.4. The spec is not clear whether
      this program is allowed or not. Whichever is intended, the spec should
      be clarified and the compiler brought in line with the spec.

      (If there is a choice, I suggest we consider deeming the old behavior
      as correct, as there are other test suites and compilers that imitate
      that behavior.)

      frog:~/workspaces/test/jikes $ cat -n T.java
           1 package p1;
           2 import p1.T;
           3
           4 class T {
           5 public static void main(String[] args) {
           6 }
           7 }
      frog:~/workspaces/test/jikes $ /java/re/jdk/1.2.2/archive/solaris/bin/javac T.java
      frog:~/workspaces/test/jikes $ /java/re/jdk/1.3.0/archive/solaris/fcs/binaries/solaris/bin/javac T.java
      frog:~/workspaces/test/jikes $ /java/re/jdk/1.4/archive/fcs/binaries/solsparc/bin/javac T.java
      T.java:2: p1.T is already defined in this compilation unit
      import p1.T;
      ^
      1 error
      frog:~/workspaces/test/jikes $

            abuckley Alex Buckley
            gafter Neal Gafter (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: