The JLS states in section 7.1:
"A package may not contain a type declaration and a subpackage of the same
name, or a compile-time error results."
The compiler does not hesitate to create such ambiguities. It will create a class which collides with a package:
package java;
public class util {
}
And it will create a package which collides with a class:
package java.lang.String;
public class Bad {
}
The compiler should be modified to give helpful error messages when these situations occur.
Bug report 4027499 includes this behavior and others, but it is more broad and not as specific.
todd.turnidge@Eng 1997-12-29
"A package may not contain a type declaration and a subpackage of the same
name, or a compile-time error results."
The compiler does not hesitate to create such ambiguities. It will create a class which collides with a package:
package java;
public class util {
}
And it will create a package which collides with a class:
package java.lang.String;
public class Bad {
}
The compiler should be modified to give helpful error messages when these situations occur.
Bug report 4027499 includes this behavior and others, but it is more broad and not as specific.
todd.turnidge@Eng 1997-12-29
- duplicates
-
JDK-4047844 type declaration and subpackage of the same name are permited
- Closed
-
JDK-4111352 subpackage and class with the same name
- Closed
-
JDK-4243915 Package clashes with class of same name.
- Closed
- relates to
-
JDK-4027499 Checks for package/class ambiguity are incomplete and perhaps incorrect.
- Closed