This repository was archived by the owner on Sep 19, 2023. It is now read-only.
File tree 3 files changed +16
-2
lines changed
src/jdk.compiler/share/classes/com/sun/tools/javac/parser
test/langtools/tools/javac/unnamedclass
3 files changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -3995,6 +3995,7 @@ public JCTree.JCCompilationUnit parseCompilationUnit() {
3995
3995
}
3996
3996
3997
3997
if (isTopLevelMethodOrField ) {
3998
+ checkSourceLevel (token .pos , Feature .UNNAMED_CLASSES );
3998
3999
defs .appendList (topLevelMethodOrFieldDeclaration (mods ));
3999
4000
isUnnamedClass = true ;
4000
4001
} else {
@@ -4025,8 +4026,6 @@ public JCTree.JCCompilationUnit parseCompilationUnit() {
4025
4026
4026
4027
// Restructure top level to be an unnamed class.
4027
4028
private List <JCTree > constructUnnamedClass (List <JCTree > origDefs ) {
4028
- checkSourceLevel (Feature .UNNAMED_CLASSES );
4029
-
4030
4029
ListBuffer <JCTree > topDefs = new ListBuffer <>();
4031
4030
ListBuffer <JCTree > defs = new ListBuffer <>();
4032
4031
Original file line number Diff line number Diff line change
1
+ /**
2
+ * @test /nodynamiccopyright/
3
+ * @bug 8310314
4
+ * @summary Ensure proper error position for the "unnamed classes not supported" error
5
+ * @compile/fail/ref=SourceLevelErrorPosition.out -XDrawDiagnostics SourceLevelErrorPosition.java
6
+ */
7
+ class Nested {}
8
+ void main () {
9
+ System .err .println ("" );
10
+ }
11
+ void test () {
12
+ System .err .println ("" );
13
+ }
Original file line number Diff line number Diff line change
1
+ SourceLevelErrorPosition.java:8:1: compiler.err.preview.feature.disabled.plural: (compiler.misc.feature.unnamed.classes)
2
+ 1 error
You can’t perform that action at this time.
0 commit comments