1 /*******************************************************************************
2  * Copyright (c) 2016, 2017 IBM Corporation and others.
3  *
4  * This program and the accompanying materials
5  * are made available under the terms of the Eclipse Public License 2.0
6  * which accompanies this distribution, and is available at
7  * https://www.eclipse.org/legal/epl-2.0/
8  *
9  * SPDX-License-Identifier: EPL-2.0
10  *
11  * Contributors:
12  *     IBM Corporation - initial API and implementation
13  *******************************************************************************/
14 package org.eclipse.jdt.core.tests.compiler.parser;
15 
16 import java.io.IOException;
17 
18 import org.eclipse.jdt.core.tests.util.CompilerTestSetup;
19 import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
20 import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
21 
22 import junit.framework.Test;
23 
24 public class ModuleDeclarationSyntaxTest extends AbstractSyntaxTreeTest {
25 
ModuleDeclarationSyntaxTest(String name, String referenceCompiler, String referenceCompilerTestsScratchArea)26 	public ModuleDeclarationSyntaxTest(String name, String referenceCompiler,
27 			String referenceCompilerTestsScratchArea) {
28 		super(name, referenceCompiler, referenceCompilerTestsScratchArea);
29 	}
testClass()30 	public static Class<?> testClass() {
31 		return ModuleDeclarationSyntaxTest.class;
32 	}
33 	@Override
initialize(CompilerTestSetup setUp)34 	public void initialize(CompilerTestSetup setUp) {
35 		super.initialize(setUp);
36 	}
suite()37 	public static Test suite() {
38 		return buildMinimalComplianceTestSuite(testClass(), F_9);
39 	}
40 
41 	static {
42 		//		TESTS_NAMES = new String[] { "test0009" };
43 		//		TESTS_NUMBERS = new int[] { 133, 134, 135 };
44 	}
ModuleDeclarationSyntaxTest(String testName)45 	public ModuleDeclarationSyntaxTest(String testName){
46 		super(testName, null, null);
47 	}
test0001()48 	public void test0001() throws IOException {
49 		String source =
50 				"module com.greetings {\n" +
51 				"}\n";
52 		String expectedUnitToString =
53 				"module com.greetings {\n" +
54 				"}\n";
55 		CompilerOptions options = new CompilerOptions(getCompilerOptions());
56 		options.complianceLevel = ClassFileConstants.JDK9;
57 		options.sourceLevel = ClassFileConstants.JDK9;
58 		options.targetJDK = ClassFileConstants.JDK9;
59 		checkParse(CHECK_PARSER, source.toCharArray(), null, "module-info", expectedUnitToString, null, options);
60 	}
test0002()61 	public void test0002() throws IOException {
62 		String source =
63 				"module com.greetings {\n" +
64 				    "requires org.astro;" +
65 				"}\n";
66 		String expectedUnitToString =
67 				"module com.greetings {\n" +
68 				"  requires org.astro;\n" +
69 				"}\n";
70 		CompilerOptions options = new CompilerOptions(getCompilerOptions());
71 		options.complianceLevel = ClassFileConstants.JDK9;
72 		options.sourceLevel = ClassFileConstants.JDK9;
73 		options.targetJDK = ClassFileConstants.JDK9;
74 		checkParse(CHECK_PARSER, source.toCharArray(), null, "module-info", expectedUnitToString, null, options);
75 	}
test0003()76 	public void test0003() throws IOException {
77 		String source =
78 				"module org.astro {\n" +
79 				"    exports org.astro;\n" +
80 				"}\n";
81 		String expectedUnitToString =
82 				"module org.astro {\n" +
83 				"  exports org.astro;\n" +
84 				"}\n";
85 		CompilerOptions options = new CompilerOptions(getCompilerOptions());
86 		options.complianceLevel = ClassFileConstants.JDK9;
87 		options.sourceLevel = ClassFileConstants.JDK9;
88 		options.targetJDK = ClassFileConstants.JDK9;
89 		checkParse(CHECK_PARSER, source.toCharArray(), null, "module-info", expectedUnitToString, null, options);
90 	}
test0004()91 	public void test0004() throws IOException {
92 		String source =
93 				"module org.astro {\n" +
94 				"    exports org.astro to com.greetings, com.example1, com.example2;\n" +
95 				"}\n";
96 		String expectedUnitToString =
97 				"module org.astro {\n" +
98 				"  exports org.astro to com.greetings, com.example1, com.example2;\n" +
99 				"}\n";
100 		CompilerOptions options = new CompilerOptions(getCompilerOptions());
101 		options.complianceLevel = ClassFileConstants.JDK9;
102 		options.sourceLevel = ClassFileConstants.JDK9;
103 		options.targetJDK = ClassFileConstants.JDK9;
104 		checkParse(CHECK_PARSER, source.toCharArray(), null, "module-info", expectedUnitToString, null, options);
105 	}
test0005()106 	public void test0005() throws IOException {
107 		String source =
108 				"module com.socket {\n" +
109 				"    exports com.socket;\n" +
110 				"    exports com.socket.spi;\n" +
111 				"    uses com.socket.spi.NetworkSocketProvider;\n" +
112 				"}\n";
113 		String expectedUnitToString =
114 				"module com.socket {\n" +
115 				"  exports com.socket;\n" +
116 				"  exports com.socket.spi;\n" +
117 				"  uses com.socket.spi.NetworkSocketProvider;\n" +
118 				"}\n";
119 		CompilerOptions options = new CompilerOptions(getCompilerOptions());
120 		options.complianceLevel = ClassFileConstants.JDK9;
121 		options.sourceLevel = ClassFileConstants.JDK9;
122 		options.targetJDK = ClassFileConstants.JDK9;
123 		checkParse(CHECK_PARSER, source.toCharArray(), null, "module-info", expectedUnitToString, null, options);
124 	}
test0006()125 	public void test0006() throws IOException {
126 		String source =
127 				"module org.fastsocket {\n" +
128 				"    requires com.socket;\n" +
129 				"    provides com.socket.spi.NetworkSocketProvider\n" +
130 				"      with org.fastsocket.FastNetworkSocketProvider;\n" +
131 				"}\n";
132 		String expectedUnitToString =
133 				"module org.fastsocket {\n" +
134 				"  requires com.socket;\n" +
135 				"  provides com.socket.spi.NetworkSocketProvider with org.fastsocket.FastNetworkSocketProvider;\n" +
136 				"}\n";
137 		CompilerOptions options = new CompilerOptions(getCompilerOptions());
138 		options.complianceLevel = ClassFileConstants.JDK9;
139 		options.sourceLevel = ClassFileConstants.JDK9;
140 		options.targetJDK = ClassFileConstants.JDK9;
141 		checkParse(CHECK_PARSER, source.toCharArray(), null, "module-info", expectedUnitToString, null, options);
142 	}
test0007()143 	public void test0007() throws IOException {
144 		String source =
145 				"module org.fastsocket {\n" +
146 				"    requires com.socket;\n" +
147 				"    provides com.socket.spi.NetworkSocketProvider;\n" +
148 				"}\n";
149 		String expectedErrorString =
150 				"----------\n" +
151 				"1. ERROR in module-info (at line 3)\n" +
152 				"	provides com.socket.spi.NetworkSocketProvider;\n" +
153 				"	                       ^\n" +
154 				"Syntax error on token \".\", with expected\n" +
155 				"----------\n";
156 		CompilerOptions options = new CompilerOptions(getCompilerOptions());
157 		options.complianceLevel = ClassFileConstants.JDK9;
158 		options.sourceLevel = ClassFileConstants.JDK9;
159 		options.targetJDK = ClassFileConstants.JDK9;
160 		checkParse(CHECK_PARSER, source.toCharArray(), expectedErrorString, "module-info", null, null, options);
161 	}
test0008()162 	public void test0008() throws IOException {
163 		String source =
164 				"module @Marker com.greetings {\n" +
165 				"	requires org.astro;" +
166 				"}\n";
167 		String errorMsg =
168 				"----------\n" +
169 				"1. ERROR in module-info (at line 1)\n" +
170 				"	module @Marker com.greetings {\n" +
171 				"	^^^^^^\n" +
172 				"Syntax error on token(s), misplaced construct(s)\n" +
173 				"----------\n" +
174 				"2. ERROR in module-info (at line 1)\n" +
175 				"	module @Marker com.greetings {\n"+
176 				"	        ^^^^^^\n"+
177 				"Syntax error on token \"Marker\", module expected after this token\n" +
178 				 "----------\n";
179 		CompilerOptions options = new CompilerOptions(getCompilerOptions());
180 		options.complianceLevel = ClassFileConstants.JDK9;
181 		options.sourceLevel = ClassFileConstants.JDK9;
182 		options.targetJDK = ClassFileConstants.JDK9;
183 		checkParse(CHECK_PARSER, source.toCharArray(), errorMsg, "module-info", null, null, options);
184 	}
test0009()185 	public void test0009() throws IOException {
186 		String source =
187 				"module com.greetings {\n" +
188 				"	requires @Marker org.astro;\n" +
189 				"}\n";
190 		String errorMsg =
191 				"----------\n" +
192 				"1. ERROR in module-info (at line 1)\n" +
193 				"	module com.greetings {\n	requires @Marker org.astro;\n" +
194 				"	^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
195 				"Syntax error on token(s), misplaced construct(s)\n" +
196 				"----------\n" +
197 				"2. ERROR in module-info (at line 2)\n" +
198 				"	requires @Marker org.astro;\n"+
199 				"	          ^^^^^^\n"+
200 				"Syntax error on token \"Marker\", package expected after this token\n" +
201 				"----------\n"+
202 				"3. ERROR in module-info (at line 3)\n"+
203 				"	}\n" +
204 				"	^\n" +
205 				"Syntax error on token \"}\", delete this token\n" +
206 				 "----------\n";
207 		CompilerOptions options = new CompilerOptions(getCompilerOptions());
208 		options.complianceLevel = ClassFileConstants.JDK9;
209 		options.sourceLevel = ClassFileConstants.JDK9;
210 		options.targetJDK = ClassFileConstants.JDK9;
211 		checkParse(CHECK_PARSER, source.toCharArray(), errorMsg, "module-info", null, null, options);
212 	}
test0010()213 	public void test0010() throws IOException {
214 		String source =
215 				"module com.greetings {\n" +
216 				"	requires private org.astro;\n" +
217 				"}\n";
218 		String errorMsg =
219 				"----------\n" +
220 				"1. ERROR in module-info (at line 2)\n" +
221 				"	requires private org.astro;\n"+
222 				"	         ^^^^^^^\n"+
223 				"Syntax error on token \"private\", delete this token\n" +
224 				 "----------\n";
225 		CompilerOptions options = new CompilerOptions(getCompilerOptions());
226 		options.complianceLevel = ClassFileConstants.JDK9;
227 		options.sourceLevel = ClassFileConstants.JDK9;
228 		options.targetJDK = ClassFileConstants.JDK9;
229 		checkParse(CHECK_PARSER, source.toCharArray(), errorMsg, "module-info", null, null, options);
230 	}
test0011()231 	public void test0011() throws IOException {
232 		String source =
233 				"module com.greetings {\n" +
234 				"	exports @Marker com.greetings;\n" +
235 				"}\n";
236 		String errorMsg =
237 				"----------\n" +
238 				"1. ERROR in module-info (at line 1)\n" +
239 				"	module com.greetings {\n	exports @Marker com.greetings;\n" +
240 				"	^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
241 				"Syntax error on token(s), misplaced construct(s)\n" +
242 				"----------\n" +
243 				"2. ERROR in module-info (at line 2)\n" +
244 				"	exports @Marker com.greetings;\n"+
245 				"	         ^^^^^^\n"+
246 				"Syntax error on token \"Marker\", package expected after this token\n" +
247 				"----------\n"+
248 				"3. ERROR in module-info (at line 3)\n"+
249 				"	}\n" +
250 				"	^\n" +
251 				"Syntax error on token \"}\", delete this token\n" +
252 				 "----------\n";
253 		CompilerOptions options = new CompilerOptions(getCompilerOptions());
254 		options.complianceLevel = ClassFileConstants.JDK9;
255 		options.sourceLevel = ClassFileConstants.JDK9;
256 		options.targetJDK = ClassFileConstants.JDK9;
257 		checkParse(CHECK_PARSER, source.toCharArray(), errorMsg, "module-info", null, null, options);
258 	}
test0012()259 	public void test0012() throws IOException {
260 		String source =
261 				"module com.greetings {\n" +
262 				"	exports com.greetings to @Marker org.astro;\n" +
263 				"}\n";
264 		String errorMsg =
265 				"----------\n" +
266 				"1. ERROR in module-info (at line 2)\n" +
267 				"	exports com.greetings to @Marker org.astro;\n"+
268 				"	                         ^^^^^^^\n"+
269 				"Syntax error on tokens, delete these tokens\n" +
270 				 "----------\n";
271 		CompilerOptions options = new CompilerOptions(getCompilerOptions());
272 		options.complianceLevel = ClassFileConstants.JDK9;
273 		options.sourceLevel = ClassFileConstants.JDK9;
274 		options.targetJDK = ClassFileConstants.JDK9;
275 		checkParse(CHECK_PARSER, source.toCharArray(), errorMsg, "module-info", null, null, options);
276 	}
test0013()277 	public void test0013() throws IOException {
278 		String source =
279 				"module com.greetings {\n" +
280 				"	uses @Marker org.astro.World;\n" +
281 				"}\n";
282 		String errorMsg =
283 				"----------\n" +
284 				"1. ERROR in module-info (at line 2)\n" +
285 				"	uses @Marker org.astro.World;\n" +
286 				"	     ^^^^^^^\n"+
287 				"Syntax error, type annotations are illegal here\n" +
288 				 "----------\n";
289 		CompilerOptions options = new CompilerOptions(getCompilerOptions());
290 		options.complianceLevel = ClassFileConstants.JDK9;
291 		options.sourceLevel = ClassFileConstants.JDK9;
292 		options.targetJDK = ClassFileConstants.JDK9;
293 		checkParse(CHECK_PARSER, source.toCharArray(), errorMsg, "module-info", null, null, options);
294 	}
test0014()295 	public void test0014() throws IOException {
296 		String source =
297 				"module com.greetings {\n" +
298 				"	provides @Marker org.astro.World with @Marker com.greetings.Main;\n" +
299 				"}\n";
300 		String errorMsg =
301 				"----------\n" +
302 				"1. ERROR in module-info (at line 2)\n" +
303 				"	provides @Marker org.astro.World with @Marker com.greetings.Main;\n" +
304 				"	         ^^^^^^^\n"+
305 				"Syntax error, type annotations are illegal here\n" +
306 				"----------\n" +
307 				"2. ERROR in module-info (at line 2)\n" +
308 				"	provides @Marker org.astro.World with @Marker com.greetings.Main;\n" +
309 				"	                                      ^^^^^^^\n"+
310 				"Syntax error, type annotations are illegal here\n" +
311 				 "----------\n";
312 		CompilerOptions options = new CompilerOptions(getCompilerOptions());
313 		options.complianceLevel = ClassFileConstants.JDK9;
314 		options.sourceLevel = ClassFileConstants.JDK9;
315 		options.targetJDK = ClassFileConstants.JDK9;
316 		checkParse(CHECK_PARSER, source.toCharArray(), errorMsg, "module-info", null, null, options);
317 	}
test0015()318 	public void test0015() throws IOException {
319 		String source =
320 				"module com.greetings {\n" +
321 				    "requires transitive org.astro;" +
322 				"}\n";
323 		String expectedUnitToString =
324 				"module com.greetings {\n" +
325 				"  requires transitive org.astro;\n" +
326 				"}\n";
327 		CompilerOptions options = new CompilerOptions(getCompilerOptions());
328 		options.complianceLevel = ClassFileConstants.JDK9;
329 		options.sourceLevel = ClassFileConstants.JDK9;
330 		options.targetJDK = ClassFileConstants.JDK9;
331 		checkParse(CHECK_PARSER, source.toCharArray(), null, "module-info", expectedUnitToString, null, options);
332 	}
test0016()333 	public void test0016() throws IOException {
334 		String source =
335 				"module com.greetings {\n" +
336 				    "requires static org.astro;" +
337 				"}\n";
338 		String expectedUnitToString =
339 				"module com.greetings {\n" +
340 				"  requires static org.astro;\n" +
341 				"}\n";
342 		CompilerOptions options = new CompilerOptions(getCompilerOptions());
343 		options.complianceLevel = ClassFileConstants.JDK9;
344 		options.sourceLevel = ClassFileConstants.JDK9;
345 		options.targetJDK = ClassFileConstants.JDK9;
346 		checkParse(CHECK_PARSER, source.toCharArray(), null, "module-info", expectedUnitToString, null, options);
347 	}
test0017()348 	public void test0017() throws IOException {
349 		String source =
350 				"module com.greetings {\n" +
351 				    "requires transitive static org.astro;" +
352 				"}\n";
353 		String expectedUnitToString =
354 				"module com.greetings {\n" +
355 				"  requires transitive static org.astro;\n" +
356 				"}\n";
357 		CompilerOptions options = new CompilerOptions(getCompilerOptions());
358 		options.complianceLevel = ClassFileConstants.JDK9;
359 		options.sourceLevel = ClassFileConstants.JDK9;
360 		options.targetJDK = ClassFileConstants.JDK9;
361 		checkParse(CHECK_PARSER, source.toCharArray(), null, "module-info", expectedUnitToString, null, options);
362 	}
test0018()363 	public void test0018() throws IOException {
364 		String source =
365 				"import com.socket.spi.NetworkSocketProvider;\n" +
366 				"module org.fastsocket {\n" +
367 				"    requires com.socket;\n" +
368 				"    provides NetworkSocketProvider\n" +
369 				"      with org.fastsocket.FastNetworkSocketProvider;\n" +
370 				"}\n";
371 		String expectedUnitToString =
372 				"import com.socket.spi.NetworkSocketProvider;\n" +
373 				"module org.fastsocket {\n" +
374 				"  requires com.socket;\n" +
375 				"  provides NetworkSocketProvider with org.fastsocket.FastNetworkSocketProvider;\n" +
376 				"}\n";
377 		CompilerOptions options = new CompilerOptions(getCompilerOptions());
378 		options.complianceLevel = ClassFileConstants.JDK9;
379 		options.sourceLevel = ClassFileConstants.JDK9;
380 		options.targetJDK = ClassFileConstants.JDK9;
381 		checkParse(CHECK_PARSER, source.toCharArray(), null, "module-info", expectedUnitToString, null, options);
382 	}
test0019()383 	public void test0019() throws IOException {
384 		String source =
385 				"import com.socket.spi.*;\n" +
386 				"module org.fastsocket {\n" +
387 				"    requires com.socket;\n" +
388 				"    provides NetworkSocketProvider\n" +
389 				"      with org.fastsocket.FastNetworkSocketProvider;\n" +
390 				"}\n";
391 		String expectedUnitToString =
392 				"import com.socket.spi.*;\n" +
393 				"module org.fastsocket {\n" +
394 				"  requires com.socket;\n" +
395 				"  provides NetworkSocketProvider with org.fastsocket.FastNetworkSocketProvider;\n" +
396 				"}\n";
397 		CompilerOptions options = new CompilerOptions(getCompilerOptions());
398 		options.complianceLevel = ClassFileConstants.JDK9;
399 		options.sourceLevel = ClassFileConstants.JDK9;
400 		options.targetJDK = ClassFileConstants.JDK9;
401 		checkParse(CHECK_PARSER, source.toCharArray(), null, "module-info", expectedUnitToString, null, options);
402 	}
test0020()403 	public void test0020() throws IOException {
404 		String source =
405 				"open module com.greetings {\n" +
406 				    "requires transitive static org.astro;" +
407 				"}\n";
408 		String expectedUnitToString =
409 				"open module com.greetings {\n" +
410 				"  requires transitive static org.astro;\n" +
411 				"}\n";
412 		CompilerOptions options = new CompilerOptions(getCompilerOptions());
413 		options.complianceLevel = ClassFileConstants.JDK9;
414 		options.sourceLevel = ClassFileConstants.JDK9;
415 		options.targetJDK = ClassFileConstants.JDK9;
416 		checkParse(CHECK_PARSER, source.toCharArray(), null, "module-info", expectedUnitToString, null, options);
417 	}
test0021()418 	public void test0021() throws IOException {
419 		String source =
420 				"module org.fastsocket {\n" +
421 				"    requires com.socket;\n" +
422 				"    provides com.socket.spi.NetworkSocketProvider\n" +
423 				"      with org.fastsocket.FastNetworkSocketProvider, org.fastSocket.SlowNetworkSocketProvider;\n" +
424 				"}\n";
425 		String expectedUnitToString =
426 				"module org.fastsocket {\n" +
427 				"  requires com.socket;\n" +
428 				"  provides com.socket.spi.NetworkSocketProvider with org.fastsocket.FastNetworkSocketProvider, org.fastSocket.SlowNetworkSocketProvider;\n" +
429 				"}\n";
430 		CompilerOptions options = new CompilerOptions(getCompilerOptions());
431 		options.complianceLevel = ClassFileConstants.JDK9;
432 		options.sourceLevel = ClassFileConstants.JDK9;
433 		options.targetJDK = ClassFileConstants.JDK9;
434 		checkParse(CHECK_PARSER, source.toCharArray(), null, "module-info", expectedUnitToString, null, options);
435 	}
test0022()436 	public void test0022() throws IOException {
437 		String source =
438 				"module org.astro {\n" +
439 				"    opens org.astro;\n" +
440 				"}\n";
441 		String expectedUnitToString =
442 				"module org.astro {\n" +
443 				"  opens org.astro;\n" +
444 				"}\n";
445 		CompilerOptions options = new CompilerOptions(getCompilerOptions());
446 		options.complianceLevel = ClassFileConstants.JDK9;
447 		options.sourceLevel = ClassFileConstants.JDK9;
448 		options.targetJDK = ClassFileConstants.JDK9;
449 		checkParse(CHECK_PARSER, source.toCharArray(), null, "module-info", expectedUnitToString, null, options);
450 	}
test0023()451 	public void test0023() throws IOException {
452 		String source =
453 				"module org.astro {\n" +
454 				"    opens org.astro to com.greetings, com.example1, com.example2;\n" +
455 				"}\n";
456 		String expectedUnitToString =
457 				"module org.astro {\n" +
458 				"  opens org.astro to com.greetings, com.example1, com.example2;\n" +
459 				"}\n";
460 		CompilerOptions options = new CompilerOptions(getCompilerOptions());
461 		options.complianceLevel = ClassFileConstants.JDK9;
462 		options.sourceLevel = ClassFileConstants.JDK9;
463 		options.targetJDK = ClassFileConstants.JDK9;
464 		checkParse(CHECK_PARSER, source.toCharArray(), null, "module-info", expectedUnitToString, null, options);
465 	}
test0024()466 	public void test0024() throws IOException {
467 		String source =
468 				"module org.astro {\n" +
469 				"    exports org.astro to com.greetings, com.example1, com.example2;\n" +
470 				"    opens org.astro to com.greetings, com.example1, com.example2;\n" +
471 				"    opens org.astro.galaxy to com.greetings, com.example1, com.example2;\n" +
472 				"}\n";
473 		String expectedUnitToString =
474 				"module org.astro {\n" +
475 				"  exports org.astro to com.greetings, com.example1, com.example2;\n" +
476 				"  opens org.astro to com.greetings, com.example1, com.example2;\n" +
477 				"  opens org.astro.galaxy to com.greetings, com.example1, com.example2;\n" +
478 				"}\n";
479 		CompilerOptions options = new CompilerOptions(getCompilerOptions());
480 		options.complianceLevel = ClassFileConstants.JDK9;
481 		options.sourceLevel = ClassFileConstants.JDK9;
482 		options.targetJDK = ClassFileConstants.JDK9;
483 		checkParse(CHECK_PARSER, source.toCharArray(), null, "module-info", expectedUnitToString, null, options);
484 	}
test0025()485 	public void test0025() throws IOException {
486 		String source =
487 				"@Foo\n" +
488 				"module org.astro {\n" +
489 				"    exports org.astro to com.greetings, com.example1, com.example2;\n" +
490 				"    opens org.astro to com.greetings, com.example1, com.example2;\n" +
491 				"    opens org.astro.galaxy to com.greetings, com.example1, com.example2;\n" +
492 				"}\n";
493 		String expectedUnitToString =
494 				"@Foo\n" +
495 				"module org.astro {\n" +
496 				"  exports org.astro to com.greetings, com.example1, com.example2;\n" +
497 				"  opens org.astro to com.greetings, com.example1, com.example2;\n" +
498 				"  opens org.astro.galaxy to com.greetings, com.example1, com.example2;\n" +
499 				"}\n";
500 		CompilerOptions options = new CompilerOptions(getCompilerOptions());
501 		options.complianceLevel = ClassFileConstants.JDK9;
502 		options.sourceLevel = ClassFileConstants.JDK9;
503 		options.targetJDK = ClassFileConstants.JDK9;
504 		checkParse(CHECK_PARSER, source.toCharArray(), null, "module-info", expectedUnitToString, null, options);
505 	}
test0026()506 	public void test0026() throws IOException {
507 		String source =
508 				"@Foo\n" +
509 				"open module org.astro {\n" +
510 				"    exports org.astro to com.greetings, com.example1, com.example2;\n" +
511 				"    opens org.astro to com.greetings, com.example1, com.example2;\n" +
512 				"    opens org.astro.galaxy to com.greetings, com.example1, com.example2;\n" +
513 				"}\n";
514 		String expectedUnitToString =
515 				"@Foo\n" +
516 				"open module org.astro {\n" +
517 				"  exports org.astro to com.greetings, com.example1, com.example2;\n" +
518 				"  opens org.astro to com.greetings, com.example1, com.example2;\n" +
519 				"  opens org.astro.galaxy to com.greetings, com.example1, com.example2;\n" +
520 				"}\n";
521 		CompilerOptions options = new CompilerOptions(getCompilerOptions());
522 		options.complianceLevel = ClassFileConstants.JDK9;
523 		options.sourceLevel = ClassFileConstants.JDK9;
524 		options.targetJDK = ClassFileConstants.JDK9;
525 		checkParse(CHECK_PARSER, source.toCharArray(), null, "module-info", expectedUnitToString, null, options);
526 	}
527 
test0027()528 	public void test0027() throws IOException {
529 		String source =
530 				"@Foo @Bar(x = 2) @Baz(\"true\")\n" +
531 				"open module org.astro {\n" +
532 				"    exports org.astro to com.greetings, com.example1, com.example2;\n" +
533 				"    opens org.astro to com.greetings, com.example1, com.example2;\n" +
534 				"    opens org.astro.galaxy to com.greetings, com.example1, com.example2;\n" +
535 				"}\n";
536 		String expectedUnitToString =
537 				"@Foo @Bar(x = 2) @Baz(\"true\")\n" +
538 				"open module org.astro {\n" +
539 				"  exports org.astro to com.greetings, com.example1, com.example2;\n" +
540 				"  opens org.astro to com.greetings, com.example1, com.example2;\n" +
541 				"  opens org.astro.galaxy to com.greetings, com.example1, com.example2;\n" +
542 				"}\n";
543 		CompilerOptions options = new CompilerOptions(getCompilerOptions());
544 		options.complianceLevel = ClassFileConstants.JDK9;
545 		options.sourceLevel = ClassFileConstants.JDK9;
546 		options.targetJDK = ClassFileConstants.JDK9;
547 		checkParse(CHECK_PARSER, source.toCharArray(), null, "module-info", expectedUnitToString, null, options);
548 	}
549 
testBug518626()550 	public void testBug518626() throws IOException {
551 		String source =
552 				"module module.test {\n" +
553 				"    provides X with Y;\n" +
554 				"}\n";
555 		String expectedUnitToString =
556 				"module module.test {\n" +
557 				"  provides X with Y;\n" +
558 				"}\n";
559 		CompilerOptions options = new CompilerOptions(getCompilerOptions());
560 		options.complianceLevel = ClassFileConstants.JDK9;
561 		options.sourceLevel = ClassFileConstants.JDK9;
562 		options.targetJDK = ClassFileConstants.JDK9;
563 		checkParse(CHECK_PARSER, source.toCharArray(), null, "module-info", expectedUnitToString, null, options);
564 	}
testbug488541()565 	public void testbug488541() throws IOException {
566 		String source =
567 				"module module {\n" +
568 				"   requires requires;\n" +
569 				"   exports to to exports;\n" +
570 				"   uses module;\n" +
571 				"   provides uses with to;\n" +
572 				"}\n";
573 		String expectedUnitToString =
574 				"module module {\n" +
575 				"  requires requires;\n" +
576 				"  exports to to exports;\n" +
577 				"  uses module;\n" +
578 				"  provides uses with to;\n" +
579 				"}\n";
580 		CompilerOptions options = new CompilerOptions(getCompilerOptions());
581 		options.complianceLevel = ClassFileConstants.JDK9;
582 		options.sourceLevel = ClassFileConstants.JDK9;
583 		options.targetJDK = ClassFileConstants.JDK9;
584 		checkParse(CHECK_PARSER, source.toCharArray(), null, "module-info", expectedUnitToString, null, options);
585 	}
testbug488541a()586 	public void testbug488541a() throws IOException {
587 		String source =
588 			"import module.pack1.exports.pack2;\n" +
589 			"import module.open.pack1.opens.pack2;\n" +
590 			"@open @module(true)\n" +
591 			"open module module.module.module {\n" +
592 			"   requires static transitive requires;\n" +
593 			"   requires transitive static transitive;\n" +
594 			"   exports to to exports;\n" +
595 			"   opens module.to.pack1 to to.exports;\n" +
596 			"   uses module;\n" +
597 			"   provides uses with to;\n" +
598 			"}\n";
599 		String expectedUnitToString =
600 			"import module.pack1.exports.pack2;\n" +
601 			"import module.open.pack1.opens.pack2;\n" +
602 			"@open @module(true)\n" +
603 			"open module module.module.module {\n" +
604 			"  requires transitive static requires;\n" +
605 			"  requires transitive static transitive;\n" +
606 			"  exports to to exports;\n" +
607 			"  opens module.to.pack1 to to.exports;\n" +
608 			"  uses module;\n" +
609 			"  provides uses with to;\n" +
610 			"}\n";
611 		CompilerOptions options = new CompilerOptions(getCompilerOptions());
612 		options.complianceLevel = ClassFileConstants.JDK9;
613 		options.sourceLevel = ClassFileConstants.JDK9;
614 		options.targetJDK = ClassFileConstants.JDK9;
615 		checkParse(CHECK_PARSER, source.toCharArray(), null, "module-info", expectedUnitToString, null, options);
616 	}
testbug488541b()617 	public void testbug488541b() throws IOException {
618 		String source =
619 				"module module {\n" +
620 				"   requires requires;\n" +
621 				"   exports to to exports, module;\n" +
622 				"   uses module;\n" +
623 				"   provides uses with to, open, module;\n" +
624 				"}\n";
625 		String expectedUnitToString =
626 				"module module {\n" +
627 				"  requires requires;\n" +
628 				"  exports to to exports, module;\n" +
629 				"  uses module;\n" +
630 				"  provides uses with to, open, module;\n" +
631 				"}\n";
632 		CompilerOptions options = new CompilerOptions(getCompilerOptions());
633 		options.complianceLevel = ClassFileConstants.JDK9;
634 		options.sourceLevel = ClassFileConstants.JDK9;
635 		options.targetJDK = ClassFileConstants.JDK9;
636 		checkParse(CHECK_PARSER, source.toCharArray(), null, "module-info", expectedUnitToString, null, options);
637 	}
638 
639 }
640