@@ -106,40 +106,64 @@ public void test001() {
106106 Map <String , String > options = getCompilerOptions ();
107107 String old = options .get (CompilerOptions .OPTION_EnablePreviews );
108108 options .put (CompilerOptions .OPTION_EnablePreviews , CompilerOptions .DISABLED );
109- try {
110- runNegativeTest (
111- new String [] {
112- "X.java" ,
113- "import p.*;\n " +
114- "public class X {\n " +
115- " Zork z = null;\n " +
116- " ABC abc = null;\n " +
117- " public void foo () {\n " +
118- " (new ABC()).doSomething();\n " +
119- " }\n " +
120- "}\n " ,
121- },
109+ String output = this .complianceLevel == ClassFileConstants .JDK17 ?
110+ "----------\n " +
111+ "1. ERROR in X.java (at line 3)\n " +
112+ " Zork z = null;\n " +
113+ " ^^^^\n " +
114+ "Zork cannot be resolved to a type\n " +
115+ "----------\n " +
116+ "2. WARNING in X.java (at line 4)\n " +
117+ " ABC abc = null;\n " +
118+ " ^^^\n " +
119+ "You are using an API that is part of the preview feature \' Test Feature\' and may be removed in future\n " +
120+ "----------\n " +
121+ "3. WARNING in X.java (at line 6)\n " +
122+ " (new ABC()).doSomething();\n " +
123+ " ^^^^^^^^^^^^^^^^^^^^^^^^^\n " +
124+ "You are using an API that is part of the preview feature \' Test Feature\' and may be removed in future\n " +
125+ "----------\n " +
126+ "4. WARNING in X.java (at line 6)\n " +
127+ " (new ABC()).doSomething();\n " +
128+ " ^^^\n " +
129+ "You are using an API that is part of the preview feature \' Test Feature\' and may be removed in future\n " +
130+ "----------\n " :
122131 "----------\n " +
123132 "1. ERROR in X.java (at line 3)\n " +
124133 " Zork z = null;\n " +
125134 " ^^^^\n " +
126135 "Zork cannot be resolved to a type\n " +
127136 "----------\n " +
128- "2. ERROR in X.java (at line 4)\n " +
137+ "2. WARNING in X.java (at line 4)\n " +
129138 " ABC abc = null;\n " +
130139 " ^^^\n " +
131- "This API is part of the preview feature \' Test Feature\' which is disabled by default. Use --enable-preview to enable \n " +
140+ "You are using an API that is part of the preview feature \' Test Feature\' and may be removed in future \n " +
132141 "----------\n " +
133- "3. ERROR in X.java (at line 6)\n " +
142+ "3. WARNING in X.java (at line 6)\n " +
134143 " (new ABC()).doSomething();\n " +
135144 " ^^^^^^^^^^^^^^^^^^^^^^^^^\n " +
136- "This API is part of the preview feature \' Test Feature\' which is disabled by default. Use --enable-preview to enable \n " +
145+ "You are using an API that is part of the preview feature \' Test Feature\' and may be removed in future \n " +
137146 "----------\n " +
138- "4. ERROR in X.java (at line 6)\n " +
147+ "4. WARNING in X.java (at line 6)\n " +
139148 " (new ABC()).doSomething();\n " +
140149 " ^^^\n " +
141- "This API is part of the preview feature \' Test Feature\' which is disabled by default. Use --enable-preview to enable\n " +
142- "----------\n " ,
150+ "You are using an API that is part of the preview feature \' Test Feature\' and may be removed in future\n " +
151+ "----------\n " ;
152+
153+ try {
154+ runNegativeTest (
155+ new String [] {
156+ "X.java" ,
157+ "import p.*;\n " +
158+ "public class X {\n " +
159+ " Zork z = null;\n " +
160+ " ABC abc = null;\n " +
161+ " public void foo () {\n " +
162+ " (new ABC()).doSomething();\n " +
163+ " }\n " +
164+ "}\n " ,
165+ },
166+ output ,
143167 classLibs ,
144168 true ,
145169 options );
@@ -158,6 +182,34 @@ public void test002() {
158182 String old = options .get (CompilerOptions .OPTION_EnablePreviews );
159183 options .put (CompilerOptions .OPTION_EnablePreviews , CompilerOptions .DISABLED );
160184 String [] classLibs = getClasspathWithPreviewAPI ();
185+ String output = this .complianceLevel == ClassFileConstants .JDK17 ?
186+ "----------\n " +
187+ "1. ERROR in X.java (at line 3)\n " +
188+ " Zork z = null;\n " +
189+ " ^^^^\n " +
190+ "Zork cannot be resolved to a type\n " +
191+ "----------\n " +
192+ "2. WARNING in X.java (at line 4)\n " +
193+ " ABC abc = null;\n " +
194+ " ^^^\n " +
195+ "You are using an API that is part of the preview feature \' Test Feature\' and may be removed in future\n " +
196+ "----------\n " +
197+ "3. WARNING in X.java (at line 6)\n " +
198+ " (new ABC()).doSomething();\n " +
199+ " ^^^^^^^^^^^^^^^^^^^^^^^^^\n " +
200+ "You are using an API that is part of the preview feature \' Test Feature\' and may be removed in future\n " +
201+ "----------\n " +
202+ "4. WARNING in X.java (at line 6)\n " +
203+ " (new ABC()).doSomething();\n " +
204+ " ^^^\n " +
205+ "You are using an API that is part of the preview feature \' Test Feature\' and may be removed in future\n " +
206+ "----------\n " :
207+ "----------\n " +
208+ "1. ERROR in X.java (at line 4)\n " +
209+ " Zork z = null;\n " +
210+ " ^^^^\n " +
211+ "Zork cannot be resolved to a type\n " +
212+ "----------\n " ;
161213 try {
162214 runNegativeTest (
163215 new String [] {
@@ -172,27 +224,7 @@ public void test002() {
172224 " }\n " +
173225 "}\n " ,
174226 },
175- "----------\n " +
176- "1. ERROR in X.java (at line 4)\n " +
177- " Zork z = null;\n " +
178- " ^^^^\n " +
179- "Zork cannot be resolved to a type\n " +
180- "----------\n " +
181- "2. ERROR in X.java (at line 5)\n " +
182- " ABC abc = null;\n " +
183- " ^^^\n " +
184- "This API is part of the preview feature \' Test Feature\' which is disabled by default. Use --enable-preview to enable\n " +
185- "----------\n " +
186- "3. ERROR in X.java (at line 7)\n " +
187- " (new ABC()).doSomething();\n " +
188- " ^^^^^^^^^^^^^^^^^^^^^^^^^\n " +
189- "This API is part of the preview feature \' Test Feature\' which is disabled by default. Use --enable-preview to enable\n " +
190- "----------\n " +
191- "4. ERROR in X.java (at line 7)\n " +
192- " (new ABC()).doSomething();\n " +
193- " ^^^\n " +
194- "This API is part of the preview feature \' Test Feature\' which is disabled by default. Use --enable-preview to enable\n " +
195- "----------\n " ,
227+ output ,
196228 classLibs ,
197229 true ,
198230 options );
0 commit comments