-
Bug
-
Resolution: Duplicate
-
P3
-
None
-
1.1.2
-
sparc
-
solaris_2.5
Name: ngC57085 Date: 04/26/97
Java compiler (JDK1.1.2) permits a package to contain a type declaration and a subpackage of the same name.
JLS (7.1) says:
"
A package may not contain a type declaration and a subpackage of the same name,
or a compile-time error results.
"
Next test is successfully compiled by jdk instead of error message.
> javac -d . pkgs00602c.java
> javac -d . pkgs00602.java
> java -verify javasoft.sqe.tests.lang.pkgs006.pkgs00602.pkgs00602
> echo $status
95
>
------------------------pkgs00602c--------------
package javasoft.sqe.tests.lang.pkgs006.pkgs00602.pkgs00602a;
public class pkgs00602c {
public static int plus(int p1, int p2) {
return p1+p2;
}
}
--------------------------------------
------------------------pkgs00602--------------
package javasoft.sqe.tests.lang.pkgs006.pkgs00602;
import java.io.PrintStream;
import javasoft.sqe.tests.lang.pkgs006.pkgs00602.pkgs00602a.pkgs00602c;
public class pkgs00602 {
public static void main(String argv[]) {
System.exit(run(argv, System.out) + 95/*STATUS_TEMP*/);
}
public static int run(String argv[],PrintStream out) {
if ( pkgs00602a.sum (1,2) != pkgs00602c.plus (1,2) ) {
out.println("failed");
return 2/*STATUS_FAILED*/;
}
return 0/*STATUS_PASSED*/;
}
}
class pkgs00602a {
public static int sum(int p1, int p2) {
return p1+p2;
}
}
--------------------------------------
======================================================================
- duplicates
-
JDK-4101529 compiler should never create package/class ambiguity
-
- Closed
-