During work on JDK-8263900 I discovered that the error produced when selecting .class on an unknown/misspelled type gave an odd error:
% javac -version
javac 16
% cat X.java
public class X {
void x() {
Class c = java.lang.class;
}
}
% javac X.java
X.java:3: error: package java does not exist
Class c = java.lang.class;
^
1 error
I get the same confusing error with e.g. "new java.lang()"
This bug goes back to at least Java 11, but Java 8 u232 appears to get it right, explaining that there's no java.lang class in those cases. I haven't bisected the exact cause, but I'm assuming that it may have been related to (or obscured by) access checkes introduced in module system.
I believe the problem is the same as inJDK-8264216 which is specific to Valhalla -- a PR with a fix is underway.
% javac -version
javac 16
% cat X.java
public class X {
void x() {
Class c = java.lang.class;
}
}
% javac X.java
X.java:3: error: package java does not exist
Class c = java.lang.class;
^
1 error
I get the same confusing error with e.g. "new java.lang()"
This bug goes back to at least Java 11, but Java 8 u232 appears to get it right, explaining that there's no java.lang class in those cases. I haven't bisected the exact cause, but I'm assuming that it may have been related to (or obscured by) access checkes introduced in module system.
I believe the problem is the same as in