--- a/langtools/test/tools/javac/modules/AbstractOrInnerClassServiceImplTest.java Mon May 02 15:01:54 2016 -0700
+++ b/langtools/test/tools/javac/modules/AbstractOrInnerClassServiceImplTest.java Mon May 02 16:17:39 2016 -0700
@@ -47,7 +47,7 @@
}
@Test
- void testAbstractServiceImpl(Path base) throws Exception {
+ public void testAbstractServiceImpl(Path base) throws Exception {
Path src = base.resolve("src");
tb.writeJavaFiles(src,
"module m { provides p1.Service with p2.Impl; }",
@@ -68,7 +68,7 @@
}
@Test
- void testInnerClassServiceImpl(Path base) throws Exception {
+ public void testInnerClassServiceImpl(Path base) throws Exception {
Path src = base.resolve("src");
tb.writeJavaFiles(src,
"module m { provides p1.Service with p2.Outer.Inner; }",
@@ -89,7 +89,7 @@
}
@Test
- void testInnerInterfaceServiceImpl(Path base) throws Exception {
+ public void testInnerInterfaceServiceImpl(Path base) throws Exception {
Path src = base.resolve("src");
tb.writeJavaFiles(src,
"module m { provides p1.Service with p2.Outer.Inner; }",
--- a/langtools/test/tools/javac/modules/AddLimitMods.java Mon May 02 15:01:54 2016 -0700
+++ b/langtools/test/tools/javac/modules/AddLimitMods.java Mon May 02 16:17:39 2016 -0700
@@ -79,7 +79,7 @@
}
@Test
- void testManual(Path base) throws Exception {
+ public void testManual(Path base) throws Exception {
Path moduleSrc = base.resolve("module-src");
Path m1 = moduleSrc.resolve("m1");
@@ -176,7 +176,7 @@
}
@Test
- void testAllModulePath(Path base) throws Exception {
+ public void testAllModulePath(Path base) throws Exception {
if (Files.isDirectory(base))
tb.cleanDirectory(base);
@@ -284,7 +284,7 @@
}
@Test
- void testRuntime2Compile(Path base) throws Exception {
+ public void testRuntime2Compile(Path base) throws Exception {
Path classpathSrc = base.resolve("classpath-src");
Path classpathOut = base.resolve("classpath-out");
--- a/langtools/test/tools/javac/modules/AddReadsTest.java Mon May 02 15:01:54 2016 -0700
+++ b/langtools/test/tools/javac/modules/AddReadsTest.java Mon May 02 16:17:39 2016 -0700
@@ -58,7 +58,7 @@
}
@Test
- void testAddReads(Path base) throws Exception {
+ public void testAddReads(Path base) throws Exception {
Path src = base.resolve("src");
Path src_m1 = src.resolve("m1");
tb.writeJavaFiles(src_m1,
@@ -150,7 +150,7 @@
}
@Test
- void testAddReadsUnnamedModule(Path base) throws Exception {
+ public void testAddReadsUnnamedModule(Path base) throws Exception {
Path jar = prepareTestJar(base);
Path moduleSrc = base.resolve("module-src");
@@ -175,7 +175,7 @@
}
@Test
- void testAddReadsUnnamedModulePackageConflict(Path base) throws Exception {
+ public void testAddReadsUnnamedModulePackageConflict(Path base) throws Exception {
Path jar = prepareTestJar(base);
Path moduleSrc = base.resolve("module-src");
@@ -202,7 +202,7 @@
}
@Test
- void testAddReadsUnnamedToJavaBase(Path base) throws Exception {
+ public void testAddReadsUnnamedToJavaBase(Path base) throws Exception {
Path jar = prepareTestJar(base);
Path src = base.resolve("src");
Path classes = base.resolve("classes");
@@ -223,7 +223,7 @@
}
@Test
- void testAddReadsToJavaBase(Path base) throws Exception {
+ public void testAddReadsToJavaBase(Path base) throws Exception {
Path src = base.resolve("src");
Path classes = base.resolve("classes");
@@ -275,7 +275,7 @@
}
@Test
- void testX(Path base) throws Exception {
+ public void testX(Path base) throws Exception {
Path src = base.resolve("src");
Path src_m1 = src.resolve("m1");
tb.writeJavaFiles(src_m1,
--- a/langtools/test/tools/javac/modules/AnnotationProcessing.java Mon May 02 15:01:54 2016 -0700
+++ b/langtools/test/tools/javac/modules/AnnotationProcessing.java Mon May 02 16:17:39 2016 -0700
@@ -68,7 +68,7 @@
}
@Test
- void testAPSingleModule(Path base) throws Exception {
+ public void testAPSingleModule(Path base) throws Exception {
Path moduleSrc = base.resolve("module-src");
Path m1 = moduleSrc.resolve("m1");
@@ -95,7 +95,7 @@
}
@Test
- void testAPMultiModule(Path base) throws Exception {
+ public void testAPMultiModule(Path base) throws Exception {
Path moduleSrc = base.resolve("module-src");
Path m1 = moduleSrc.resolve("m1");
Path m2 = moduleSrc.resolve("m2");
@@ -196,7 +196,7 @@
}
@Test
- void testVerifyUsesProvides(Path base) throws Exception {
+ public void testVerifyUsesProvides(Path base) throws Exception {
Path moduleSrc = base.resolve("module-src");
Path m1 = moduleSrc.resolve("m1");
@@ -254,7 +254,7 @@
}
@Test
- void testPackageNoModule(Path base) throws Exception {
+ public void testPackageNoModule(Path base) throws Exception {
Path src = base.resolve("src");
Path classes = base.resolve("classes");
--- a/langtools/test/tools/javac/modules/AnnotationProcessorsInModulesTest.java Mon May 02 15:01:54 2016 -0700
+++ b/langtools/test/tools/javac/modules/AnnotationProcessorsInModulesTest.java Mon May 02 16:17:39 2016 -0700
@@ -156,7 +156,7 @@
Path classes;
@Test
- void testUseOnlyOneProcessor(Path base) throws Exception {
+ public void testUseOnlyOneProcessor(Path base) throws Exception {
initialization(base);
String log = new JavacTask(tb)
.options("-processormodulepath", processorCompiledModules.toString(),
@@ -172,7 +172,7 @@
}
@Test
- void testAnnotationProcessorExecutionOrder(Path base) throws Exception {
+ public void testAnnotationProcessorExecutionOrder(Path base) throws Exception {
initialization(base);
List<String> log = new JavacTask(tb)
.options("-processormodulepath", processorCompiledModules.toString(),
@@ -202,7 +202,7 @@
}
@Test
- void testErrorOutputIfOneProcessorNameIsIncorrect(Path base) throws Exception {
+ public void testErrorOutputIfOneProcessorNameIsIncorrect(Path base) throws Exception {
initialization(base);
String log = new JavacTask(tb)
.options("-XDrawDiagnostics", "-processormodulepath", processorCompiledModules.toString(),
@@ -218,7 +218,7 @@
}
@Test
- void testOptionsExclusion(Path base) throws Exception {
+ public void testOptionsExclusion(Path base) throws Exception {
initialization(base);
List<String> log = new JavacTask(tb)
.options("-XDrawDiagnostics", "-processormodulepath", processorCompiledModules.toString(),
--- a/langtools/test/tools/javac/modules/AutomaticModules.java Mon May 02 15:01:54 2016 -0700
+++ b/langtools/test/tools/javac/modules/AutomaticModules.java Mon May 02 16:17:39 2016 -0700
@@ -48,7 +48,7 @@
}
@Test
- void testSimple(Path base) throws Exception {
+ public void testSimple(Path base) throws Exception {
Path legacySrc = base.resolve("legacy-src");
tb.writeJavaFiles(legacySrc,
"package api; import java.awt.event.ActionListener; public abstract class Api implements ActionListener {}");
@@ -98,7 +98,7 @@
}
@Test
- void testUnnamedModule(Path base) throws Exception {
+ public void testUnnamedModule(Path base) throws Exception {
Path legacySrc = base.resolve("legacy-src");
tb.writeJavaFiles(legacySrc,
"package api; public abstract class Api { public void run(CharSequence str) { } private void run(base.Base base) { } }",
@@ -156,7 +156,7 @@
}
@Test
- void testModuleInfoFromClassFileDependsOnAutomatic(Path base) throws Exception {
+ public void testModuleInfoFromClassFileDependsOnAutomatic(Path base) throws Exception {
Path automaticSrc = base.resolve("automaticSrc");
tb.writeJavaFiles(automaticSrc, "package api; public class Api {}");
Path automaticClasses = base.resolve("automaticClasses");
--- a/langtools/test/tools/javac/modules/DoclintOtherModules.java Mon May 02 15:01:54 2016 -0700
+++ b/langtools/test/tools/javac/modules/DoclintOtherModules.java Mon May 02 16:17:39 2016 -0700
@@ -47,7 +47,7 @@
}
@Test
- void testSimple(Path base) throws Exception {
+ public void testSimple(Path base) throws Exception {
Path src = base.resolve("src");
Path m1 = src.resolve("m1");
Path m2 = src.resolve("m2");
--- a/langtools/test/tools/javac/modules/DuplicateClassTest.java Mon May 02 15:01:54 2016 -0700
+++ b/langtools/test/tools/javac/modules/DuplicateClassTest.java Mon May 02 16:17:39 2016 -0700
@@ -47,7 +47,7 @@
}
@Test
- void testSimple(Path base) throws Exception {
+ public void testSimple(Path base) throws Exception {
Path m1 = base.resolve("m1");
Path m2 = base.resolve("m2");
tb.writeJavaFiles(m1,
--- a/langtools/test/tools/javac/modules/EdgeCases.java Mon May 02 15:01:54 2016 -0700
+++ b/langtools/test/tools/javac/modules/EdgeCases.java Mon May 02 16:17:39 2016 -0700
@@ -66,7 +66,7 @@
}
@Test
- void testAddExportUndefinedModule(Path base) throws Exception {
+ public void testAddExportUndefinedModule(Path base) throws Exception {
Path src = base.resolve("src");
tb.writeJavaFiles(src, "package test; import undef.Any; public class Test {}");
Path classes = base.resolve("classes");
@@ -89,7 +89,7 @@
}
@Test
- void testModuleSymbolOutterMostClass(Path base) throws Exception {
+ public void testModuleSymbolOutterMostClass(Path base) throws Exception {
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
try (StandardJavaFileManager fm = compiler.getStandardFileManager(null, null, null)) {
Path moduleSrc = base.resolve("module-src");
@@ -110,7 +110,7 @@
}
@Test
- void testParseEnterAnalyze(Path base) throws Exception {
+ public void testParseEnterAnalyze(Path base) throws Exception {
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
try (StandardJavaFileManager fm = compiler.getStandardFileManager(null, null, null)) {
Path moduleSrc = base.resolve("module-src");
@@ -148,7 +148,7 @@
}
@Test
- void testModuleImplicitModuleBoundaries(Path base) throws Exception {
+ public void testModuleImplicitModuleBoundaries(Path base) throws Exception {
Path src = base.resolve("src");
Path src_m1 = src.resolve("m1");
tb.writeJavaFiles(src_m1,
@@ -180,7 +180,7 @@
}
@Test
- void testAssignClassToAutomaticModule(Path base) throws Exception {
+ public void testAssignClassToAutomaticModule(Path base) throws Exception {
//check that if a ClassSymbol belongs to an automatic module, it is properly assigned and not
//duplicated when being accessed through a classfile.
Path automaticSrc = base.resolve("automaticSrc");
@@ -239,7 +239,7 @@
}
@Test
- void testEmptyImplicitModuleInfo(Path base) throws Exception {
+ public void testEmptyImplicitModuleInfo(Path base) throws Exception {
Path src = base.resolve("src");
Path src_m1 = src.resolve("m1");
Files.createDirectories(src_m1);
@@ -270,7 +270,7 @@
}
@Test
- void testClassPackageClash(Path base) throws Exception {
+ public void testClassPackageClash(Path base) throws Exception {
Path src = base.resolve("src");
Path src_m1 = src.resolve("m1");
tb.writeJavaFiles(src_m1,
--- a/langtools/test/tools/javac/modules/GraphsTest.java Mon May 02 15:01:54 2016 -0700
+++ b/langtools/test/tools/javac/modules/GraphsTest.java Mon May 02 16:17:39 2016 -0700
@@ -28,7 +28,8 @@
* @modules
* jdk.compiler/com.sun.tools.javac.api
* jdk.compiler/com.sun.tools.javac.main
- * @build toolbox.ToolBox toolbox.JarTask toolbox.JavacTask ModuleTestBase
+ * @build toolbox.ToolBox toolbox.JarTask toolbox.JavacTask toolbox.ModuleBuilder
+ * ModuleTestBase
* @run main GraphsTest
*/
@@ -41,6 +42,7 @@
import toolbox.JarTask;
import toolbox.JavacTask;
+import toolbox.ModuleBuilder;
import toolbox.Task;
import toolbox.ToolBox;
@@ -69,11 +71,11 @@
*
*/
@Test
- void diamond(Path base) throws Exception {
+ public void diamond(Path base) throws Exception {
Path modules = Files.createDirectories(base.resolve("modules"));
- new ModuleBuilder("J")
+ new ModuleBuilder(tb, "J")
.exports("openJ")
.classes("package openJ; public class J { }")
.classes("package closedJ; public class J { }")
@@ -87,25 +89,25 @@
.run()
.writeAll();
- new ModuleBuilder("O")
+ new ModuleBuilder(tb, "O")
.exports("openO")
.requiresPublic("J", jarModules)
.classes("package openO; public class O { openJ.J j; }")
.classes("package closedO; public class O { }")
.build(modules);
- new ModuleBuilder("N")
+ new ModuleBuilder(tb, "N")
.requiresPublic("O", modules, jarModules)
.exports("openN")
.classes("package openN; public class N { }")
.classes("package closedN; public class N { }")
.build(modules);
- new ModuleBuilder("L")
+ new ModuleBuilder(tb, "L")
.requiresPublic("O", modules, jarModules)
.exports("openL")
.classes("package openL; public class L { }")
.classes("package closedL; public class L { }")
.build(modules);
- ModuleBuilder m = new ModuleBuilder("M");
+ ModuleBuilder m = new ModuleBuilder(tb, "M");
//positive case
Path positiveSrc = m
.requires("N", modules)
@@ -178,14 +180,14 @@
@Test
public void reexportOfQualifiedExport(Path base) throws Exception {
Path modules = base.resolve("modules");
- new ModuleBuilder("M")
+ new ModuleBuilder(tb, "M")
.requiresPublic("N")
.write(modules);
- new ModuleBuilder("N")
+ new ModuleBuilder(tb, "N")
.exportsTo("pack", "M")
.classes("package pack; public class Clazz { }")
.write(modules);
- new ModuleBuilder("L")
+ new ModuleBuilder(tb, "L")
.requires("M")
.classes("package p; public class A { A(pack.Clazz cl){} } ")
.write(modules);
--- a/langtools/test/tools/javac/modules/HelloWorldTest.java Mon May 02 15:01:54 2016 -0700
+++ b/langtools/test/tools/javac/modules/HelloWorldTest.java Mon May 02 16:17:39 2016 -0700
@@ -58,7 +58,7 @@
+ HELLO_WORLD;
@Test
- void testLegacyMode(Path base) throws Exception {
+ public void testLegacyMode(Path base) throws Exception {
Path src = base.resolve("src");
tb.writeJavaFiles(src, HELLO_WORLD);
@@ -85,7 +85,7 @@
}
@Test
- void testUnnamedModule(Path base) throws Exception {
+ public void testUnnamedModule(Path base) throws Exception {
Path src = base.resolve("src");
tb.writeJavaFiles(src, HELLO_WORLD);
@@ -101,7 +101,7 @@
}
@Test
- void testSingleModule(Path base) throws Exception {
+ public void testSingleModule(Path base) throws Exception {
Path src = base.resolve("src");
tb.writeFile(src.resolve("module-info.java"), "module m { }");
tb.writeJavaFiles(src, PKG_HELLO_WORLD);
@@ -121,7 +121,7 @@
}
@Test
- void testModuleSourcePath(Path base) throws Exception {
+ public void testModuleSourcePath(Path base) throws Exception {
Path src = base.resolve("src");
Path src_m1 = src.resolve("m1");
tb.writeFile(src_m1.resolve("module-info.java"), "module m1 { }");
--- a/langtools/test/tools/javac/modules/MOptionTest.java Mon May 02 15:01:54 2016 -0700
+++ b/langtools/test/tools/javac/modules/MOptionTest.java Mon May 02 16:17:39 2016 -0700
@@ -47,7 +47,7 @@
}
@Test
- void testOneModule(Path base) throws Exception {
+ public void testOneModule(Path base) throws Exception {
Path src = base.resolve("src");
Path m1 = src.resolve("m1");
Path build = base.resolve("build");
@@ -112,7 +112,7 @@
}
@Test
- void testNoOutputDir(Path base) throws Exception {
+ public void testNoOutputDir(Path base) throws Exception {
Path src = base.resolve("src");
Path m1 = src.resolve("m1");
Path build = base.resolve("build");
@@ -135,7 +135,7 @@
}
@Test
- void testNoModuleSourcePath(Path base) throws Exception {
+ public void testNoModuleSourcePath(Path base) throws Exception {
Path src = base.resolve("src");
Path m1 = src.resolve("m1");
Path build = base.resolve("build");
@@ -158,7 +158,7 @@
}
@Test
- void testMultiModule(Path base) throws Exception {
+ public void testMultiModule(Path base) throws Exception {
Path src = base.resolve("src");
Path m1 = src.resolve("m1");
Path m2 = src.resolve("m2");
--- a/langtools/test/tools/javac/modules/ModuleFinderTest.java Mon May 02 15:01:54 2016 -0700
+++ b/langtools/test/tools/javac/modules/ModuleFinderTest.java Mon May 02 16:17:39 2016 -0700
@@ -48,7 +48,7 @@
}
@Test
- void testDuplicateModulesOnPath(Path base) throws Exception {
+ public void testDuplicateModulesOnPath(Path base) throws Exception {
Path src = base.resolve("src");
tb.writeJavaFiles(src, "module m1 { }");
--- a/langtools/test/tools/javac/modules/ModuleInfoTest.java Mon May 02 15:01:54 2016 -0700
+++ b/langtools/test/tools/javac/modules/ModuleInfoTest.java Mon May 02 16:17:39 2016 -0700
@@ -51,7 +51,7 @@
* Check error message if module declaration not in module-info.java.
*/
@Test
- void testModuleDeclNotInModuleJava(Path base) throws Exception {
+ public void testModuleDeclNotInModuleJava(Path base) throws Exception {
Path src = base.resolve("src");
tb.writeFile(src.resolve("M.java"), "module M { }");
String log = new JavacTask(tb)
@@ -69,7 +69,7 @@
* Verify that a package private class can be put in module-info.java.
*/
@Test
- void testNotModuleDeclInModuleJava_1(Path base) throws Exception {
+ public void testNotModuleDeclInModuleJava_1(Path base) throws Exception {
Path src = base.resolve("src");
tb.writeFile(src.resolve("module-info.java"), "class C { }");
new JavacTask(tb)
@@ -83,7 +83,7 @@
* Verify that a public class cannot be put in module-info.java.
*/
@Test
- void testNotModuleDeclInModuleJava_2(Path base) throws Exception {
+ public void testNotModuleDeclInModuleJava_2(Path base) throws Exception {
Path src = base.resolve("src");
tb.writeFile(src.resolve("module-info.java"), "public class C { }");
String log = new JavacTask(tb)
@@ -101,7 +101,7 @@
* Verify that only one module decl can be put in module-info.java.
*/
@Test
- void testSingleModuleDecl(Path base) throws Exception {
+ public void testSingleModuleDecl(Path base) throws Exception {
Path src = base.resolve("src");
tb.writeJavaFiles(src, "module M1 { } /*...*/ module M2 { }");
String log = new JavacTask(tb)
@@ -119,7 +119,7 @@
* Verify that missing requires are reported.
*/
@Test
- void testRequiresNotFound(Path base) throws Exception {
+ public void testRequiresNotFound(Path base) throws Exception {
Path src = base.resolve("src");
tb.writeJavaFiles(src, "module M1 { requires M2; }");
String log = new JavacTask(tb)
@@ -137,7 +137,7 @@
* Verify that missing exports are reported.
*/
@Test
- void testExportsNotFound(Path base) throws Exception {
+ public void testExportsNotFound(Path base) throws Exception {
Path src = base.resolve("src");
tb.writeJavaFiles(src, "module M1 { exports p to M2; }");
String log = new JavacTask(tb)
@@ -155,7 +155,7 @@
* Verify that a simple loop is detected.
*/
@Test
- void testRequiresSelf(Path base) throws Exception {
+ public void testRequiresSelf(Path base) throws Exception {
Path src = base.resolve("src");
tb.writeJavaFiles(src, "module M { requires M; }");
String log = new JavacTask(tb)
@@ -173,7 +173,7 @@
* Verify that a multi-module loop is detected.
*/
@Test
- void testRequiresLoop(Path base) throws Exception {
+ public void testRequiresLoop(Path base) throws Exception {
Path src = base.resolve("src");
Path src_m1 = src.resolve("m1");
tb.writeFile(src_m1.resolve("module-info.java"), "module m1 { requires m2; }");
@@ -201,7 +201,7 @@
* Verify that a multi-module loop is detected.
*/
@Test
- void testRequiresPublicLoop(Path base) throws Exception {
+ public void testRequiresPublicLoop(Path base) throws Exception {
Path src = base.resolve("src");
Path src_m1 = src.resolve("m1");
tb.writeFile(src_m1.resolve("module-info.java"), "module m1 { requires m2; }");
@@ -229,7 +229,7 @@
* Verify that duplicate requires are detected.
*/
@Test
- void testDuplicateRequires(Path base) throws Exception {
+ public void testDuplicateRequires(Path base) throws Exception {
Path src = base.resolve("src");
Path src_m1 = src.resolve("m1");
tb.writeFile(src_m1.resolve("module-info.java"), "module m1 { }");
@@ -255,7 +255,7 @@
* Verify that duplicate exported packages are detected.
*/
@Test
- void testDuplicateExports_packages(Path base) throws Exception {
+ public void testDuplicateExports_packages(Path base) throws Exception {
Path src = base.resolve("src");
tb.writeJavaFiles(src, "module m1 { exports p; exports p; }");
@@ -278,7 +278,7 @@
* Verify that duplicate exported packages are detected.
*/
@Test
- void testDuplicateExports_packages2(Path base) throws Exception {
+ public void testDuplicateExports_packages2(Path base) throws Exception {
Path src = base.resolve("src");
tb.writeJavaFiles(src.resolve("m1"), "module m1 { exports p; exports p to m2; }");
tb.writeJavaFiles(src.resolve("m2"), "module m2 { }");
@@ -302,7 +302,7 @@
* Verify that duplicate exported packages are detected.
*/
@Test
- void testDuplicateExports_modules(Path base) throws Exception {
+ public void testDuplicateExports_modules(Path base) throws Exception {
Path src = base.resolve("src");
Path src_m1 = src.resolve("m1");
tb.writeFile(src_m1.resolve("module-info.java"), "module m1 { }");
--- a/langtools/test/tools/javac/modules/ModuleInfoTreeAccess.java Mon May 02 15:01:54 2016 -0700
+++ b/langtools/test/tools/javac/modules/ModuleInfoTreeAccess.java Mon May 02 16:17:39 2016 -0700
@@ -61,7 +61,7 @@
}
@Test
- void testTreePathForModuleDecl(Path base) throws Exception {
+ public void testTreePathForModuleDecl(Path base) throws Exception {
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
try (StandardJavaFileManager fm = compiler.getStandardFileManager(null, null, null)) {
--- a/langtools/test/tools/javac/modules/ModulePathTest.java Mon May 02 15:01:54 2016 -0700
+++ b/langtools/test/tools/javac/modules/ModulePathTest.java Mon May 02 16:17:39 2016 -0700
@@ -30,7 +30,8 @@
* jdk.compiler/com.sun.tools.javac.main
* jdk.jdeps/com.sun.tools.javap
* jdk.jlink/jdk.tools.jmod
- * @build toolbox.ToolBox toolbox.JarTask toolbox.JavacTask ModuleTestBase
+ * @build toolbox.ToolBox toolbox.JarTask toolbox.JavacTask toolbox.ModuleBuilder
+ * ModuleTestBase
* @run main ModulePathTest
*/
@@ -41,6 +42,7 @@
import toolbox.JarTask;
import toolbox.JavacTask;
+import toolbox.ModuleBuilder;
import toolbox.Task;
import toolbox.ToolBox;
@@ -54,7 +56,7 @@
}
@Test
- void testNotExistsOnPath(Path base) throws Exception {
+ public void testNotExistsOnPath(Path base) throws Exception {
Path src = base.resolve("src");
tb.writeJavaFiles(src, "class C { }");
@@ -71,7 +73,7 @@
}
@Test
- void testNotADirOnPath_1(Path base) throws Exception {
+ public void testNotADirOnPath_1(Path base) throws Exception {
Path src = base.resolve("src");
tb.writeJavaFiles(src, "class C { }");
tb.writeFile("dummy.txt", "");
@@ -89,7 +91,7 @@
}
@Test
- void testNotADirOnPath_2(Path base) throws Exception {
+ public void testNotADirOnPath_2(Path base) throws Exception {
Path src = base.resolve("src");
tb.writeJavaFiles(src, "class C { }");
tb.writeFile("dummy.jimage", "");
@@ -107,7 +109,7 @@
}
@Test
- void testExplodedModuleOnPath(Path base) throws Exception {
+ public void testExplodedModuleOnPath(Path base) throws Exception {
Path modSrc = base.resolve("modSrc");
tb.writeJavaFiles(modSrc,
"module m1 { exports p; }",
@@ -137,7 +139,7 @@
}
@Test
- void testBadExplodedModuleOnPath(Path base) throws Exception {
+ public void testBadExplodedModuleOnPath(Path base) throws Exception {
Path modClasses = base.resolve("modClasses");
tb.writeFile(modClasses.resolve("module-info.class"), "module m1 { }");
@@ -162,7 +164,7 @@
}
@Test
- void testAutoJarOnPath(Path base) throws Exception {
+ public void testAutoJarOnPath(Path base) throws Exception {
Path jarSrc = base.resolve("jarSrc");
tb.writeJavaFiles(jarSrc,
"package p; public class CC { }");
@@ -195,7 +197,7 @@
}
@Test
- void testModJarOnPath(Path base) throws Exception {
+ public void testModJarOnPath(Path base) throws Exception {
Path jarSrc = base.resolve("jarSrc");
tb.writeJavaFiles(jarSrc,
"module m1 { exports p; }",
@@ -231,7 +233,7 @@
}
@Test
- void testBadJarOnPath(Path base) throws Exception {
+ public void testBadJarOnPath(Path base) throws Exception {
Path src = base.resolve("src");
tb.writeJavaFiles(src, "class C { }");
tb.writeFile("dummy.jar", "");
@@ -249,7 +251,7 @@
}
@Test
- void testJModOnPath(Path base) throws Exception {
+ public void testJModOnPath(Path base) throws Exception {
Path jmodSrc = base.resolve("jmodSrc");
tb.writeJavaFiles(jmodSrc,
"module m1 { exports p; }",
@@ -282,7 +284,7 @@
}
@Test
- void testBadJModOnPath(Path base) throws Exception {
+ public void testBadJModOnPath(Path base) throws Exception {
Path src = base.resolve("src");
tb.writeJavaFiles(src, "class C { }");
tb.writeFile("dummy.jmod", "");
@@ -300,9 +302,9 @@
}
@Test
- void relativePath(Path base) throws Exception {
+ public void relativePath(Path base) throws Exception {
final Path modules = base.resolve("modules");
- new ModuleBuilder("m1").build(modules);
+ new ModuleBuilder(tb, "m1").build(modules);
Path src = base.resolve("src");
tb.writeJavaFiles(src, "module m2 { requires m1; }", "class A { }");
@@ -316,9 +318,9 @@
}
@Test
- void duplicatePaths_1(Path base) throws Exception {
+ public void duplicatePaths_1(Path base) throws Exception {
final Path modules = base.resolve("modules");
- new ModuleBuilder("m1").build(modules);
+ new ModuleBuilder(tb, "m1").build(modules);
Path src = base.resolve("src");
tb.writeJavaFiles(src, "module m2 { requires m1; }", "class A { }");
@@ -332,9 +334,9 @@
}
@Test
- void duplicatePaths_2(Path base) throws Exception {
+ public void duplicatePaths_2(Path base) throws Exception {
final Path modules = base.resolve("modules");
- new ModuleBuilder("m1").build(modules);
+ new ModuleBuilder(tb, "m1").build(modules);
Path src = base.resolve("src");
tb.writeJavaFiles(src, "module m2 { requires m1; }", "class A { }");
@@ -349,15 +351,15 @@
}
@Test
- void oneModuleHidesAnother(Path base) throws Exception {
+ public void oneModuleHidesAnother(Path base) throws Exception {
final Path module = base.resolve("modules");
- new ModuleBuilder("m1")
+ new ModuleBuilder(tb, "m1")
.exports("pkg1")
.classes("package pkg1; public class E { }")
.build(module);
final Path deepModuleDir = module.resolve("deepModuleDir");
- new ModuleBuilder("m1")
+ new ModuleBuilder(tb, "m1")
.exports("pkg2")
.classes("package pkg2; public class E { }")
.build(deepModuleDir);
@@ -374,19 +376,19 @@
}
@Test
- void modulesInDifferentContainers(Path base) throws Exception {
+ public void modulesInDifferentContainers(Path base) throws Exception {
final Path modules = base.resolve("modules");
- new ModuleBuilder("m1")
+ new ModuleBuilder(tb, "m1")
.exports("one")
.classes("package one; public class A { }")
.build(modules);
- new ModuleBuilder("m2")
+ new ModuleBuilder(tb, "m2")
.requires("m1", modules)
.build(base.resolve("tmp"));
jar(base.resolve("tmp/m2"), modules.resolve("m2.jar"));
- new ModuleBuilder("m3")
+ new ModuleBuilder(tb, "m3")
.requires("m2", modules)
.build(base.resolve("tmp"));
jmod(base.resolve("tmp/m3"), modules.resolve("m3.jmod"));
--- a/langtools/test/tools/javac/modules/ModuleSourcePathTest.java Mon May 02 15:01:54 2016 -0700
+++ b/langtools/test/tools/javac/modules/ModuleSourcePathTest.java Mon May 02 16:17:39 2016 -0700
@@ -56,7 +56,7 @@
}
@Test
- void testSourcePathConflict(Path base) throws Exception {
+ public void testSourcePathConflict(Path base) throws Exception {
Path sp = base.resolve("src");
Path msp = base.resolve("srcmodules");
@@ -74,7 +74,7 @@
}
@Test
- void testUnnormalizedPath1(Path base) throws Exception {
+ public void testUnnormalizedPath1(Path base) throws Exception {
Path src = base.resolve("src");
Path src_m1 = src.resolve("m1");
tb.writeJavaFiles(src_m1, "module m1 { }");
@@ -91,7 +91,7 @@
}
@Test
- void testUnnormalizedPath2(Path base) throws Exception {
+ public void testUnnormalizedPath2(Path base) throws Exception {
Path src = base.resolve("src");
Path src_m1 = src.resolve("m1");
tb.writeJavaFiles(src_m1, "module m1 { }");
@@ -115,7 +115,7 @@
}
@Test
- void regularBraces(Path base) throws Exception {
+ public void regularBraces(Path base) throws Exception {
generateModules(base, "src1", "src2/inner_dir");
final Path modules = base.resolve("modules");
@@ -136,7 +136,7 @@
}
@Test
- void mismatchedBraces(Path base) throws Exception {
+ public void mismatchedBraces(Path base) throws Exception {
final List<String> sourcePaths = Arrays.asList(
"{",
"}",
@@ -165,7 +165,7 @@
}
@Test
- void deepBraces(Path base) throws Exception {
+ public void deepBraces(Path base) throws Exception {
String[] modulePaths = {"src/src1",
"src/src2",
"src/src3",
@@ -197,7 +197,7 @@
}
@Test
- void fileInPath(Path base) throws Exception {
+ public void fileInPath(Path base) throws Exception {
Path src = base.resolve("src");
tb.writeJavaFiles(src.resolve("kettle$"), "module kettle$ { }", "package electric; class Heater { }");
tb.writeFile(base.resolve("dummy.txt"), "");
@@ -218,7 +218,7 @@
}
@Test
- void noAlternative(Path base) throws Exception {
+ public void noAlternative(Path base) throws Exception {
Path src = base.resolve("src");
tb.writeJavaFiles(src.resolve("kettle$"), "module kettle$ { }", "package electric; class Heater { }");
@@ -238,7 +238,7 @@
}
@Test
- void noChoice(Path base) throws Exception {
+ public void noChoice(Path base) throws Exception {
tb.writeJavaFiles(base.resolve("kettle$"), "module kettle$ { }", "package electric; class Heater { }");
final Path modules = base.resolve("modules");
@@ -257,7 +257,7 @@
}
@Test
- void nestedModules(Path src) throws Exception {
+ public void nestedModules(Path src) throws Exception {
Path carModule = src.resolve("car");
tb.writeJavaFiles(carModule, "module car { }", "package light; class Headlight { }");
tb.writeJavaFiles(carModule.resolve("engine"), "module engine { }", "package flat; class Piston { }");
@@ -277,7 +277,7 @@
}
@Test
- void relativePaths(Path base) throws Exception {
+ public void relativePaths(Path base) throws Exception {
Path src = base.resolve("src");
tb.writeJavaFiles(src.resolve("kettle"), "module kettle { }", "package electric; class Heater { }");
@@ -296,7 +296,7 @@
}
@Test
- void duplicatePaths(Path base) throws Exception {
+ public void duplicatePaths(Path base) throws Exception {
Path src = base.resolve("src");
tb.writeJavaFiles(src.resolve("m1"), "module m1 { }", "package a; class A { }");
@@ -315,7 +315,7 @@
}
@Test
- void notExistentPaths(Path base) throws Exception {
+ public void notExistentPaths(Path base) throws Exception {
tb.writeJavaFiles(base.resolve("m1"), "module m1 { requires m0; }", "package a; class A { }");
final Path modules = base.resolve("modules");
@@ -334,7 +334,7 @@
}
@Test
- void notExistentPathShouldBeSkipped(Path base) throws Exception {
+ public void notExistentPathShouldBeSkipped(Path base) throws Exception {
tb.writeJavaFiles(base.resolve("m1"), "module m1 { }", "package a; class A { }");
final Path modules = base.resolve("modules");
@@ -352,7 +352,7 @@
}
@Test
- void commas(Path base) throws Exception {
+ public void commas(Path base) throws Exception {
Path src = base.resolve("src");
tb.writeJavaFiles(src.resolve("m1"), "module m1 { }", "package a; class A { }");
@@ -371,7 +371,7 @@
}
@Test
- void asterisk(Path base) throws Exception {
+ public void asterisk(Path base) throws Exception {
tb.writeJavaFiles(base.resolve("kettle").resolve("classes"), "module kettle { }",
"package electric; class Heater { }");
@@ -391,7 +391,7 @@
}
@Test
- void asteriskInDifferentSets(Path base) throws Exception {
+ public void asteriskInDifferentSets(Path base) throws Exception {
Path src = base.resolve("src");
final Path module = src.resolve("kettle");
tb.writeJavaFiles(module.resolve("classes"), "module kettle { }", "package electric; class Heater { }");
@@ -417,7 +417,7 @@
}
@Test
- void asteriskIllegalUse(Path base) throws Exception {
+ public void asteriskIllegalUse(Path base) throws Exception {
final List<String> sourcePaths = Arrays.asList(
"*",
"**",
--- a/langtools/test/tools/javac/modules/ModuleTestBase.java Mon May 02 15:01:54 2016 -0700
+++ b/langtools/test/tools/javac/modules/ModuleTestBase.java Mon May 02 16:17:39 2016 -0700
@@ -43,19 +43,20 @@
import java.util.stream.Collectors;
import toolbox.JavacTask;
+import toolbox.TestRunner;
import toolbox.ToolBox;
/**
* Base class for module tests.
*/
-public class ModuleTestBase {
+public class ModuleTestBase extends TestRunner {
protected ToolBox tb;
- protected PrintStream out;
private int errors;
- /** Marker annotation for test methods to be invoked by runTests. */
- @Retention(RetentionPolicy.RUNTIME)
- @interface Test { }
+ ModuleTestBase() {
+ super(System.err);
+ tb = new ToolBox();
+ }
/**
* Run all methods annotated with @Test, and throw an exception if any
@@ -63,47 +64,12 @@
*
* @throws Exception if any errors occurred
*/
- void runTests() throws Exception {
- if (tb == null)
- tb = new ToolBox();
- out = System.err;
-
- for (Method m: getClass().getDeclaredMethods()) {
- Annotation a = m.getAnnotation(Test.class);
- if (a != null) {
- try {
- out.println("Running test " + m.getName());
- Path baseDir = Paths.get(m.getName());
- m.invoke(this, new Object[] { baseDir });
- } catch (InvocationTargetException e) {
- Throwable cause = e.getCause();
- error("Exception: " + e.getCause());
- cause.printStackTrace(out);
- }
- out.println();
- }
- }
- if (errors > 0)
- throw new Exception(errors + " errors occurred");
+ protected void runTests() throws Exception {
+ runTests(m -> new Object[] { Paths.get(m.getName()) });
}
- // move to ToolBox?
- // change returntyp to List<Path> -- means updating ToolBox methods
Path[] findJavaFiles(Path... paths) throws IOException {
- Set<Path> files = new TreeSet<>();
- for (Path p : paths) {
- Files.walkFileTree(p, new SimpleFileVisitor<Path>() {
- @Override
- public FileVisitResult visitFile(Path file, BasicFileAttributes attrs)
- throws IOException {
- if (file.getFileName().toString().endsWith(".java")) {
- files.add(file);
- }
- return FileVisitResult.CONTINUE;
- }
- });
- }
- return files.toArray(new Path[files.size()]);
+ return tb.findJavaFiles(paths);
}
void error(String message) {
@@ -111,79 +77,4 @@
errors++;
}
- public class ModuleBuilder {
-
- private final String name;
- private String requires = "";
- private String exports = "";
- private String uses = "";
- private String provides = "";
- private String modulePath = "";
- private List<String> content = new ArrayList<>();
-
- public ModuleBuilder(String name) {
- this.name = name;
- }
-
- public ModuleBuilder requiresPublic(String requires, Path... modulePath) {
- return requires("public " + requires, modulePath);
- }
-
- public ModuleBuilder requires(String requires, Path... modulePath) {
- this.requires += " requires " + requires + ";\n";
- this.modulePath += Arrays.stream(modulePath)
- .map(Path::toString)
- .collect(Collectors.joining(File.pathSeparator));
- return this;
- }
-
- public ModuleBuilder exportsTo(String pkg, String module) {
- return exports(pkg + " to " + module);
- }
-
- public ModuleBuilder exports(String pkg) {
- this.exports += " exports " + pkg + ";\n";
- return this;
- }
-
- public ModuleBuilder uses(String uses) {
- this.uses += " uses " + uses + ";\n";
- return this;
- }
-
- public ModuleBuilder provides(String service, String implementation) {
- this.provides += " provides " + service + " with " + implementation + ";\n";
- return this;
- }
-
- public ModuleBuilder classes(String... content) {
- this.content.addAll(Arrays.asList(content));
- return this;
- }
-
- public Path write(Path where) throws IOException {
- Files.createDirectories(where);
- List<String> sources = new ArrayList<>();
- sources.add("module " + name + "{"
- + requires
- + exports
- + uses
- + provides
- + "}");
- sources.addAll(content);
- Path moduleSrc = where.resolve(name + "/src");
- tb.writeJavaFiles(moduleSrc, sources.toArray(new String[]{}));
- return moduleSrc;
- }
-
- public void build(Path where) throws IOException {
- Path moduleSrc = write(where);
- new JavacTask(tb)
- .outdir(where.resolve(name))
- .options("-mp", modulePath)
- .files(findJavaFiles(moduleSrc))
- .run()
- .writeAll();
- }
- }
}
--- a/langtools/test/tools/javac/modules/ModulesAndClassPathTest.java Mon May 02 15:01:54 2016 -0700
+++ b/langtools/test/tools/javac/modules/ModulesAndClassPathTest.java Mon May 02 16:17:39 2016 -0700
@@ -55,7 +55,7 @@
}
@Test
- void testModulesAndClassPath(Path base) throws Exception {
+ public void testModulesAndClassPath(Path base) throws Exception {
Path jar = prepareTestJar(base);
Path moduleSrc = base.resolve("module-src");
@@ -106,7 +106,7 @@
}
@Test
- void testImplicitSourcePathModuleInfo(Path base) throws Exception {
+ public void testImplicitSourcePathModuleInfo(Path base) throws Exception {
Path jar = prepareTestJar(base);
Path moduleSrc = base.resolve("module-src");
@@ -139,7 +139,7 @@
}
@Test
- void testModuleInfoFromOutput(Path base) throws Exception {
+ public void testModuleInfoFromOutput(Path base) throws Exception {
Path jar = prepareTestJar(base);
Path moduleSrc = base.resolve("module-src");
@@ -221,7 +221,7 @@
}
@Test
- void testClassOutputVisibleForIncrementalCompilation(Path base) throws Exception {
+ public void testClassOutputVisibleForIncrementalCompilation(Path base) throws Exception {
Path moduleSrc = base.resolve("module-src");
Path m1 = moduleSrc.resolve("m1");
--- a/langtools/test/tools/javac/modules/MultiModuleModeTest.java Mon May 02 15:01:54 2016 -0700
+++ b/langtools/test/tools/javac/modules/MultiModuleModeTest.java Mon May 02 16:17:39 2016 -0700
@@ -49,7 +49,7 @@
}
@Test
- void testDuplicateModules(Path base) throws Exception {
+ public void testDuplicateModules(Path base) throws Exception {
Path src = base.resolve("src");
Path src_m1 = src.resolve("m1");
tb.writeJavaFiles(src_m1, "module m1 { }");
@@ -72,7 +72,7 @@
}
@Test
- void testCantFindModule(Path base) throws Exception {
+ public void testCantFindModule(Path base) throws Exception {
Path src = base.resolve("src");
Path src_m1 = src.resolve("m1");
tb.writeJavaFiles(src_m1, "module m1 { }");
@@ -95,7 +95,7 @@
}
@Test
- void testModuleNameMismatch(Path base) throws Exception {
+ public void testModuleNameMismatch(Path base) throws Exception {
Path src = base.resolve("src");
Path src_m1 = src.resolve("m1");
tb.writeJavaFiles(src_m1, "module m2 { }");
@@ -116,7 +116,7 @@
}
@Test
- void testImplicitModuleSource(Path base) throws Exception {
+ public void testImplicitModuleSource(Path base) throws Exception {
Path src = base.resolve("src");
tb.writeJavaFiles(src.resolve("m1"), "module m1 { }");
tb.writeJavaFiles(src.resolve("m2"), "module m2 { requires m1; }");
@@ -132,7 +132,7 @@
}
@Test
- void testImplicitModuleClass(Path base) throws Exception {
+ public void testImplicitModuleClass(Path base) throws Exception {
Path src1 = base.resolve("src1");
tb.writeJavaFiles(src1.resolve("m1"), "module m1 { }");
Path modules1 = base.resolve("modules1");
--- a/langtools/test/tools/javac/modules/NPECompilingModuleInfoTest.java Mon May 02 15:01:54 2016 -0700
+++ b/langtools/test/tools/javac/modules/NPECompilingModuleInfoTest.java Mon May 02 16:17:39 2016 -0700
@@ -45,7 +45,7 @@
}
@Test
- void testCompileNoError(Path base) throws Exception {
+ public void testCompileNoError(Path base) throws Exception {
Path mod = base.resolve("mod");
tb.writeJavaFiles(mod, "module mod { exports pkg; }");
Path pkg = mod.resolve("pkg");
--- a/langtools/test/tools/javac/modules/NPEEmptyFileTest.java Mon May 02 15:01:54 2016 -0700
+++ b/langtools/test/tools/javac/modules/NPEEmptyFileTest.java Mon May 02 16:17:39 2016 -0700
@@ -45,7 +45,7 @@
}
@Test
- void compileEmptyFile(Path base) throws Exception {
+ public void compileEmptyFile(Path base) throws Exception {
Path modules = base.resolve("modules");
Files.createDirectories(modules);
Path emptyJavaFile = base.resolve("Test.java");
--- a/langtools/test/tools/javac/modules/OutputDirTest.java Mon May 02 15:01:54 2016 -0700
+++ b/langtools/test/tools/javac/modules/OutputDirTest.java Mon May 02 16:17:39 2016 -0700
@@ -60,7 +60,7 @@
}
@Test
- void testError(Path base) throws Exception {
+ public void testError(Path base) throws Exception {
String log = new JavacTask(tb)
.options("-XDrawDiagnostics",
"-modulesourcepath", src.toString())
@@ -74,7 +74,7 @@
}
@Test
- void testProcOnly(Path base) throws IOException {
+ public void testProcOnly(Path base) throws IOException {
new JavacTask(tb)
.options("-XDrawDiagnostics",
"-proc:only",
@@ -85,7 +85,7 @@
}
@Test
- void testClassOutDir(Path base) throws IOException {
+ public void testClassOutDir(Path base) throws IOException {
Path classes = base.resolve("classes");
new JavacTask(tb)
.options("-XDrawDiagnostics",
@@ -97,7 +97,7 @@
}
@Test
- void testExplodedOutDir(Path base) throws Exception {
+ public void testExplodedOutDir(Path base) throws Exception {
Path modSrc = base.resolve("modSrc");
tb.writeJavaFiles(modSrc,
"module m1 { exports p; }",
@@ -131,7 +131,7 @@
}
@Test
- void testInExplodedOutDir(Path base) throws Exception {
+ public void testInExplodedOutDir(Path base) throws Exception {
Path modSrc = base.resolve("modSrc");
tb.writeJavaFiles(modSrc,
"module m1 { exports p; }",
--- a/langtools/test/tools/javac/modules/PackageConflictTest.java Mon May 02 15:01:54 2016 -0700
+++ b/langtools/test/tools/javac/modules/PackageConflictTest.java Mon May 02 16:17:39 2016 -0700
@@ -28,7 +28,7 @@
* @modules
* jdk.compiler/com.sun.tools.javac.api
* jdk.compiler/com.sun.tools.javac.main
- * @build toolbox.ToolBox toolbox.JavacTask ModuleTestBase
+ * @build toolbox.ToolBox toolbox.JavacTask toolbox.ModuleBuilder ModuleTestBase
* @run main PackageConflictTest
*/
@@ -38,6 +38,7 @@
import java.util.List;
import toolbox.JavacTask;
+import toolbox.ModuleBuilder;
import toolbox.Task;
import toolbox.ToolBox;
@@ -48,7 +49,7 @@
}
@Test
- void testSimple(Path base) throws Exception {
+ public void testSimple(Path base) throws Exception {
Path src = base.resolve("src");
tb.writeJavaFiles(src,
"package java.util; public class MyList { }");
@@ -68,7 +69,7 @@
}
@Test
- void testDisjoint(Path base) throws Exception {
+ public void testDisjoint(Path base) throws Exception {
Path m1 = base.resolve("m1");
Path m2 = base.resolve("m2");
tb.writeJavaFiles(m1,
@@ -89,7 +90,7 @@
}
@Test
- void testConflictInDependencies(Path base) throws Exception {
+ public void testConflictInDependencies(Path base) throws Exception {
Path m1 = base.resolve("m1");
Path m2 = base.resolve("m2");
Path m3 = base.resolve("m3");
@@ -123,13 +124,13 @@
}
@Test
- void testSimple2(Path base) throws Exception {
+ public void testSimple2(Path base) throws Exception {
Path modules = base.resolve("modules");
- new ModuleBuilder("N")
+ new ModuleBuilder(tb, "N")
.exports("pack")
.classes("package pack; public class A { }")
.build(modules);
- new ModuleBuilder("M")
+ new ModuleBuilder(tb, "M")
.requires("N")
.classes("package pack; public class B { pack.A f; }")
.write(modules);
@@ -147,14 +148,14 @@
}
@Test
- void testPrivateConflict(Path base) throws Exception {
+ public void testPrivateConflict(Path base) throws Exception {
Path modules = base.resolve("modules");
- new ModuleBuilder("N")
+ new ModuleBuilder(tb, "N")
.exports("publ")
.classes("package pack; public class A { }")
.classes("package publ; public class B { }")
.write(modules);
- new ModuleBuilder("M")
+ new ModuleBuilder(tb, "M")
.requires("N")
.classes("package pack; public class C { publ.B b; }")
.write(modules);
@@ -173,14 +174,14 @@
}
@Test
- void testPrivateConflictOnModulePath(Path base) throws Exception {
+ public void testPrivateConflictOnModulePath(Path base) throws Exception {
Path modules = base.resolve("modules");
- new ModuleBuilder("N")
+ new ModuleBuilder(tb, "N")
.exports("publ")
.classes("package pack; public class A { }")
.classes("package publ; public class B { }")
.build(modules);
- new ModuleBuilder("M")
+ new ModuleBuilder(tb, "M")
.requires("N")
.classes("package pack; public class C { publ.B b; }")
.write(modules);
@@ -199,17 +200,17 @@
}
@Test
- void testRequiresConflictExports(Path base) throws Exception {
+ public void testRequiresConflictExports(Path base) throws Exception {
Path modules = base.resolve("modules");
- new ModuleBuilder("M")
+ new ModuleBuilder(tb, "M")
.exports("pack")
.classes("package pack; public class A { }")
.build(modules);
- new ModuleBuilder("N")
+ new ModuleBuilder(tb, "N")
.exports("pack")
.classes("package pack; public class B { }")
.build(modules);
- new ModuleBuilder("K")
+ new ModuleBuilder(tb, "K")
.requires("M")
.requires("N")
.classes("package pkg; public class C { pack.A a; pack.B b; }")
@@ -231,18 +232,18 @@
}
@Test
- void testQulifiedExportsToDifferentModules(Path base) throws Exception {
+ public void testQulifiedExportsToDifferentModules(Path base) throws Exception {
Path modules = base.resolve("modules");
- new ModuleBuilder("U").write(modules);
- new ModuleBuilder("M")
+ new ModuleBuilder(tb, "U").write(modules);
+ new ModuleBuilder(tb, "M")
.exports("pkg to U")
.classes("package pkg; public class A { public static boolean flagM; }")
.write(modules);
- new ModuleBuilder("N")
+ new ModuleBuilder(tb, "N")
.exports("pkg to K")
.classes("package pkg; public class A { public static boolean flagN; }")
.write(modules);
- ModuleBuilder moduleK = new ModuleBuilder("K");
+ ModuleBuilder moduleK = new ModuleBuilder(tb, "K");
moduleK.requires("M")
.requires("N")
.classes("package p; public class DependsOnN { boolean f = pkg.A.flagN; } ")
--- a/langtools/test/tools/javac/modules/PackageMultipleModules.java Mon May 02 15:01:54 2016 -0700
+++ b/langtools/test/tools/javac/modules/PackageMultipleModules.java Mon May 02 16:17:39 2016 -0700
@@ -49,7 +49,7 @@
}
@Test
- void testSimple(Path base) throws Exception {
+ public void testSimple(Path base) throws Exception {
Path m1 = base.resolve("m1");
Path m2 = base.resolve("m2");
tb.writeJavaFiles(m1,
--- a/langtools/test/tools/javac/modules/PluginsInModulesTest.java Mon May 02 15:01:54 2016 -0700
+++ b/langtools/test/tools/javac/modules/PluginsInModulesTest.java Mon May 02 16:17:39 2016 -0700
@@ -127,7 +127,7 @@
Path classes;
@Test
- void testUseOnlyOneProcessor(Path base) throws Exception {
+ public void testUseOnlyOneProcessor(Path base) throws Exception {
initialization(base);
List<String> log = new JavacTask(tb)
.options("-processormodulepath", processorCompiledModules.toString(),
--- a/langtools/test/tools/javac/modules/ProvidesTest.java Mon May 02 15:01:54 2016 -0700
+++ b/langtools/test/tools/javac/modules/ProvidesTest.java Mon May 02 16:17:39 2016 -0700
@@ -48,7 +48,7 @@
}
@Test
- void testSimple(Path base) throws Exception {
+ public void testSimple(Path base) throws Exception {
Path src = base.resolve("src");
tb.writeJavaFiles(src,
"module m { provides p1.C1 with p2.C2; }",
@@ -65,7 +65,7 @@
}
@Test
- void testMulti(Path base) throws Exception {
+ public void testMulti(Path base) throws Exception {
Path src = base.resolve("src");
tb.writeJavaFiles(src.resolve("m1"),
"module m1 { exports p1; }",
@@ -86,7 +86,7 @@
}
@Test
- void testMissingWith(Path base) throws Exception {
+ public void testMissingWith(Path base) throws Exception {
Path src = base.resolve("src");
tb.writeJavaFiles(src,
"module m { provides p.C; }",
@@ -108,7 +108,7 @@
}
@Test
- void testDuplicateProvides(Path base) throws Exception {
+ public void testDuplicateProvides(Path base) throws Exception {
Path src = base.resolve("src");
tb.writeJavaFiles(src,
"module m { provides p1.C1 with p2.C2; provides p1.C1 with p2.C2; }",
@@ -126,7 +126,7 @@
}
@Test
- void testMissingService(Path base) throws Exception {
+ public void testMissingService(Path base) throws Exception {
Path src = base.resolve("src");
tb.writeJavaFiles(src,
"module m { provides p.Missing with p.C; }",
@@ -151,7 +151,7 @@
}
@Test
- void testProvidesFromAnotherModule(Path base) throws Exception {
+ public void testProvidesFromAnotherModule(Path base) throws Exception {
Path modules = base.resolve("modules");
tb.writeJavaFiles(modules.resolve("M"),
"module M { exports p; }",
@@ -177,7 +177,7 @@
}
@Test
- void testServiceIsNotImplemented(Path base) throws Exception {
+ public void testServiceIsNotImplemented(Path base) throws Exception {
Path src = base.resolve("src");
tb.writeJavaFiles(src,
"module m { provides p.A with p.B; }",
@@ -200,7 +200,7 @@
}
@Test
- void testMissingImplementation(Path base) throws Exception {
+ public void testMissingImplementation(Path base) throws Exception {
Path src = base.resolve("src");
tb.writeJavaFiles(src,
"module m { provides p.C with p.Impl; }",
@@ -222,7 +222,7 @@
}
@Test
- void testSeveralImplementations(Path base) throws Exception {
+ public void testSeveralImplementations(Path base) throws Exception {
Path src = base.resolve("src");
tb.writeJavaFiles(src,
"module m { provides p.C with p.Impl1; provides p.C with p.Impl2; }",
@@ -238,7 +238,7 @@
}
@Test
- void testOneImplementationsForServices(Path base) throws Exception {
+ public void testOneImplementationsForServices(Path base) throws Exception {
Path src = base.resolve("src");
tb.writeJavaFiles(src,
"module m { provides p.Service1 with p.Impl; provides p.Service2 with p.Impl; }",
@@ -254,7 +254,7 @@
}
@Test
- void testAbstractImplementation(Path base) throws Exception {
+ public void testAbstractImplementation(Path base) throws Exception {
Path src = base.resolve("src");
tb.writeJavaFiles(src,
"module m { provides p1.C1 with p2.C2; }",
@@ -277,7 +277,7 @@
}
@Test
- void testInterfaceImplementation(Path base) throws Exception {
+ public void testInterfaceImplementation(Path base) throws Exception {
Path src = base.resolve("src");
tb.writeJavaFiles(src,
"module m { provides p1.Service with p2.Impl; }",
@@ -300,7 +300,7 @@
}
@Test
- void testProtectedImplementation(Path base) throws Exception {
+ public void testProtectedImplementation(Path base) throws Exception {
Path src = base.resolve("src");
tb.writeJavaFiles(src,
"module m { provides p1.C1 with p2.C2; }",
@@ -323,7 +323,7 @@
}
@Test
- void testNoNoArgConstructor(Path base) throws Exception {
+ public void testNoNoArgConstructor(Path base) throws Exception {
Path src = base.resolve("src");
tb.writeJavaFiles(src,
"module m { uses p1.C1; provides p1.C1 with p2.C2; }",
@@ -346,7 +346,7 @@
}
@Test
- void testPrivateNoArgConstructor(Path base) throws Exception {
+ public void testPrivateNoArgConstructor(Path base) throws Exception {
Path src = base.resolve("src");
tb.writeJavaFiles(src,
"module m { uses p1.C1; provides p1.C1 with p2.C2; }",
@@ -369,7 +369,7 @@
}
@Test
- void testServiceIndirectlyImplemented(Path base) throws Exception {
+ public void testServiceIndirectlyImplemented(Path base) throws Exception {
Path src = base.resolve("src");
tb.writeJavaFiles(src,
"module m { provides p1.C1 with p2.C3; }",
@@ -385,7 +385,7 @@
}
@Test
- void testServiceImplementationInnerClass(Path base) throws Exception {
+ public void testServiceImplementationInnerClass(Path base) throws Exception {
Path src = base.resolve("src");
tb.writeJavaFiles(src,
"module m { provides p1.C1 with p2.C2.Inner; }",
@@ -408,7 +408,7 @@
}
@Test
- void testServiceDefinitionInnerClass(Path base) throws Exception {
+ public void testServiceDefinitionInnerClass(Path base) throws Exception {
Path src = base.resolve("src");
tb.writeJavaFiles(src,
"module m { provides p1.C1.InnerDefinition with p2.C2; }",
--- a/langtools/test/tools/javac/modules/QueryBeforeEnter.java Mon May 02 15:01:54 2016 -0700
+++ b/langtools/test/tools/javac/modules/QueryBeforeEnter.java Mon May 02 16:17:39 2016 -0700
@@ -65,7 +65,7 @@
}
@Test
- void testEmpty(Path base) throws Exception {
+ public void testEmpty(Path base) throws Exception {
JavaCompiler javaCompiler = ToolProvider.getSystemJavaCompiler();
com.sun.source.util.JavacTask task =
(com.sun.source.util.JavacTask) javaCompiler.getTask(null, null, null, null, null, null);
@@ -75,7 +75,7 @@
}
@Test
- void testUnnamed(Path base) throws Exception {
+ public void testUnnamed(Path base) throws Exception {
Path moduleSrc = base.resolve("module-src");
Path m1 = moduleSrc.resolve("m1");
@@ -151,7 +151,7 @@
}
@Test
- void testSingleNamed(Path base) throws Exception {
+ public void testSingleNamed(Path base) throws Exception {
Path moduleSrc = base.resolve("module-src");
Path m1 = moduleSrc.resolve("m1");
@@ -226,7 +226,7 @@
}
@Test
- void testMultiModule(Path base) throws Exception {
+ public void testMultiModule(Path base) throws Exception {
Path modulePathSrc = base.resolve("module-path-src");
Path m1 = modulePathSrc.resolve("m1");
@@ -311,7 +311,7 @@
}
@Test
- void testTooSoon(Path base) throws Exception {
+ public void testTooSoon(Path base) throws Exception {
Path src = base.resolve("src");
tb.writeJavaFiles(src,
--- a/langtools/test/tools/javac/modules/RepeatedUsesAndProvidesTest.java Mon May 02 15:01:54 2016 -0700
+++ b/langtools/test/tools/javac/modules/RepeatedUsesAndProvidesTest.java Mon May 02 16:17:39 2016 -0700
@@ -46,7 +46,7 @@
}
@Test
- void testDuplicateUses(Path base) throws Exception {
+ public void testDuplicateUses(Path base) throws Exception {
Path src = base.resolve("src");
tb.writeJavaFiles(src,
"module m { uses p1.C1; uses p1.C1; }",
@@ -66,7 +66,7 @@
}
@Test
- void testDuplicateProvides(Path base) throws Exception {
+ public void testDuplicateProvides(Path base) throws Exception {
Path src = base.resolve("src");
tb.writeJavaFiles(src,
"module m { provides p1.C1 with p2.C2; provides p1.C1 with p2.C2; }",
--- a/langtools/test/tools/javac/modules/ReportNonExistentPackageTest.java Mon May 02 15:01:54 2016 -0700
+++ b/langtools/test/tools/javac/modules/ReportNonExistentPackageTest.java Mon May 02 16:17:39 2016 -0700
@@ -46,7 +46,7 @@
}
@Test
- void testExportUnknownPackage(Path base) throws Exception {
+ public void testExportUnknownPackage(Path base) throws Exception {
Path src = base.resolve("src");
tb.writeJavaFiles(src, "module m { exports p1; }");
Path classes = base.resolve("classes");
@@ -64,7 +64,7 @@
}
@Test
- void testExportEmptyPackage(Path base) throws Exception {
+ public void testExportEmptyPackage(Path base) throws Exception {
Path src = base.resolve("src");
tb.writeJavaFiles(src,
"module m { exports p1; }",
@@ -84,7 +84,7 @@
}
@Test
- void testPackageWithMemberWOPackageDeclaration(Path base) throws Exception {
+ public void testPackageWithMemberWOPackageDeclaration(Path base) throws Exception {
Path src = base.resolve("src");
tb.writeJavaFiles(src, "module m { exports p1; }");
Path p1 = src.resolve("p1");
--- a/langtools/test/tools/javac/modules/RequiresPublicTest.java Mon May 02 15:01:54 2016 -0700
+++ b/langtools/test/tools/javac/modules/RequiresPublicTest.java Mon May 02 16:17:39 2016 -0700
@@ -47,7 +47,7 @@
}
@Test
- void testJavaSE_OK(Path base) throws Exception {
+ public void testJavaSE_OK(Path base) throws Exception {
Path src = base.resolve("src");
tb.writeJavaFiles(src,
"module m { requires java.se; }",
@@ -66,7 +66,7 @@
}
@Test
- void testJavaSE_Fail(Path base) throws Exception {
+ public void testJavaSE_Fail(Path base) throws Exception {
Path src = base.resolve("src");
tb.writeJavaFiles(src,
"module m { requires java.se; }",
@@ -90,7 +90,7 @@
}
@Test
- void testComplex_OK(Path base) throws Exception {
+ public void testComplex_OK(Path base) throws Exception {
Path src = getComplexSrc(base, "", "");
Path classes = base.resolve("classes");
Files.createDirectories(classes);
@@ -104,7 +104,7 @@
}
@Test
- void testComplex_Fail(Path base) throws Exception {
+ public void testComplex_Fail(Path base) throws Exception {
Path src = getComplexSrc(base,
"import p5.C5; import p6.C6; import p7.C7;\n",
"C5 c5; C6 c6; C7 c7;\n");
--- a/langtools/test/tools/javac/modules/ResolveTest.java Mon May 02 15:01:54 2016 -0700
+++ b/langtools/test/tools/javac/modules/ResolveTest.java Mon May 02 16:17:39 2016 -0700
@@ -45,7 +45,7 @@
}
@Test
- void testMissingSimpleTypeUnnamedModule(Path base) throws Exception {
+ public void testMissingSimpleTypeUnnamedModule(Path base) throws Exception {
Path src = base.resolve("src");
tb.writeJavaFiles(src, "class C { D d; }");
@@ -62,7 +62,7 @@
}
@Test
- void testMissingSimpleTypeNamedModule(Path base) throws Exception {
+ public void testMissingSimpleTypeNamedModule(Path base) throws Exception {
Path src = base.resolve("src");
tb.writeJavaFiles(src,
"module m { }",
@@ -81,7 +81,7 @@
}
@Test
- void testUnexportedTypeUnreadableModule(Path base) throws Exception {
+ public void testUnexportedTypeUnreadableModule(Path base) throws Exception {
Path src = base.resolve("src");
tb.writeJavaFiles(src.resolve("m1"),
"module m1 { }",
@@ -105,7 +105,7 @@
}
@Test
- void testUnexportedTypeReadableModule(Path base) throws Exception {
+ public void testUnexportedTypeReadableModule(Path base) throws Exception {
Path src = base.resolve("src");
tb.writeJavaFiles(src.resolve("m1"),
"module m1 { }",
@@ -129,7 +129,7 @@
}
@Test
- void testQualifiedExportedTypeReadableModule(Path base) throws Exception {
+ public void testQualifiedExportedTypeReadableModule(Path base) throws Exception {
Path src = base.resolve("src");
tb.writeJavaFiles(src.resolve("m1"),
"module m1 { exports p1 to m3; }",
@@ -155,7 +155,7 @@
}
@Test
- void testExportedTypeUnreadableModule(Path base) throws Exception {
+ public void testExportedTypeUnreadableModule(Path base) throws Exception {
Path src = base.resolve("src");
tb.writeJavaFiles(src.resolve("m1"),
"module m1 { exports p1; }",
@@ -179,7 +179,7 @@
}
@Test
- void testExportedTypeReadableModule(Path base) throws Exception {
+ public void testExportedTypeReadableModule(Path base) throws Exception {
Path src = base.resolve("src");
tb.writeJavaFiles(src.resolve("m1"),
"module m1 { exports p1; }",
@@ -199,7 +199,7 @@
}
@Test
- void testExportedTypeReadableModule2(Path base) throws Exception {
+ public void testExportedTypeReadableModule2(Path base) throws Exception {
Path src = base.resolve("src");
tb.writeJavaFiles(src.resolve("m1"),
"module m1 { exports p1 to m2; }",
--- a/langtools/test/tools/javac/modules/ServiceInStaticClassErrorTest.java Mon May 02 15:01:54 2016 -0700
+++ b/langtools/test/tools/javac/modules/ServiceInStaticClassErrorTest.java Mon May 02 16:17:39 2016 -0700
@@ -48,7 +48,7 @@
}
@Test
- void testError(Path base) throws Exception {
+ public void testError(Path base) throws Exception {
Path src = base.resolve("src");
tb.writeJavaFiles(src,
"module m { provides p1.I with p1.Outer.A; }",
--- a/langtools/test/tools/javac/modules/ServiceProvidedButNotExportedOrUsedTest.java Mon May 02 15:01:54 2016 -0700
+++ b/langtools/test/tools/javac/modules/ServiceProvidedButNotExportedOrUsedTest.java Mon May 02 16:17:39 2016 -0700
@@ -49,7 +49,7 @@
}
@Test
- void testWarning(Path base) throws Exception {
+ public void testWarning(Path base) throws Exception {
Path src = base.resolve("src");
tb.writeJavaFiles(src,
"module m { provides p1.C1 with p2.C2; }",
@@ -76,7 +76,7 @@
}
@Test
- void testImplementationMustBeInSameModuleAsProvidesDirective(Path base) throws Exception {
+ public void testImplementationMustBeInSameModuleAsProvidesDirective(Path base) throws Exception {
Path src = base.resolve("src");
tb.writeJavaFiles(src.resolve("m1"),
"module m1 { exports p1; }",
--- a/langtools/test/tools/javac/modules/SingleModuleModeTest.java Mon May 02 15:01:54 2016 -0700
+++ b/langtools/test/tools/javac/modules/SingleModuleModeTest.java Mon May 02 16:17:39 2016 -0700
@@ -59,7 +59,7 @@
}
@Test
- void testTooManyModules(Path base) throws Exception {
+ public void testTooManyModules(Path base) throws Exception {
Path src = base.resolve("src");
tb.writeJavaFiles(src.resolve("m1"), "module m1 { }");
tb.writeJavaFiles(src.resolve("m2"), "module m2 { }");
@@ -76,7 +76,7 @@
}
@Test
- void testImplicitModuleSource(Path base) throws Exception {
+ public void testImplicitModuleSource(Path base) throws Exception {
Path src = base.resolve("src");
tb.writeJavaFiles(src,
"module m { }",
@@ -90,7 +90,7 @@
}
@Test
- void testImplicitModuleClass(Path base) throws Exception {
+ public void testImplicitModuleClass(Path base) throws Exception {
Path src = base.resolve("src");
tb.writeJavaFiles(src,
"module m { }",
@@ -112,7 +112,7 @@
}
@Test
- void testImplicitModuleClassAP(Path base) throws Exception {
+ public void testImplicitModuleClassAP(Path base) throws Exception {
Path src = base.resolve("src");
tb.writeJavaFiles(src,
"module m { uses java.lang.Runnable; }",
@@ -137,7 +137,7 @@
}
@Test
- void testImplicitModuleSourceAP(Path base) throws Exception {
+ public void testImplicitModuleSourceAP(Path base) throws Exception {
Path src = base.resolve("src");
tb.writeJavaFiles(src,
"module m { uses java.lang.Runnable; }",
--- a/langtools/test/tools/javac/modules/SubpackageTest.java Mon May 02 15:01:54 2016 -0700
+++ b/langtools/test/tools/javac/modules/SubpackageTest.java Mon May 02 16:17:39 2016 -0700
@@ -52,7 +52,7 @@
}
@Test // based on JDK-8075435
- void testUnnamedModule(Path base) throws Exception {
+ public void testUnnamedModule(Path base) throws Exception {
Path libsrc = base.resolve("lib/src");
tb.writeJavaFiles(libsrc,
"package p; public class E extends Error { }");
@@ -83,7 +83,7 @@
}
@Test
- void testSimpleMulti(Path base) throws Exception {
+ public void testSimpleMulti(Path base) throws Exception {
Path src = base.resolve("src");
tb.writeJavaFiles(src.resolve("mp"),
"module mp { exports p; }",
--- a/langtools/test/tools/javac/modules/UpgradeModulePathTest.java Mon May 02 15:01:54 2016 -0700
+++ b/langtools/test/tools/javac/modules/UpgradeModulePathTest.java Mon May 02 16:17:39 2016 -0700
@@ -28,7 +28,7 @@
* @modules
* jdk.compiler/com.sun.tools.javac.api
* jdk.compiler/com.sun.tools.javac.main
- * @build toolbox.ToolBox toolbox.JavacTask ModuleTestBase
+ * @build toolbox.ToolBox toolbox.JavacTask toolbox.ModuleBuilder ModuleTestBase
* @run main UpgradeModulePathTest
*/
@@ -36,6 +36,7 @@
import java.nio.file.Path;
import toolbox.JavacTask;
+import toolbox.ModuleBuilder;
import toolbox.Task;
import toolbox.ToolBox;
@@ -47,15 +48,15 @@
}
@Test
- void simpleUsage(Path base) throws Exception {
+ public void simpleUsage(Path base) throws Exception {
final Path module = base.resolve("modules");
- new ModuleBuilder("m1")
+ new ModuleBuilder(tb, "m1")
.exports("pkg1")
.classes("package pkg1; public class E { }")
.build(module);
final Path upgradeModule = base.resolve("upgradeModule");
- new ModuleBuilder("m1")
+ new ModuleBuilder(tb, "m1")
.exports("pkg2")
.classes("package pkg2; public class E { }")
.build(upgradeModule);
@@ -73,15 +74,15 @@
}
@Test
- void onlyUpgradeModulePath(Path base) throws Exception {
+ public void onlyUpgradeModulePath(Path base) throws Exception {
final Path module = base.resolve("modules");
- new ModuleBuilder("m1")
+ new ModuleBuilder(tb, "m1")
.exports("pkg1")
.classes("package pkg1; public class E { }")
.build(module);
final Path upgradeModule = base.resolve("upgradeModule");
- new ModuleBuilder("m1")
+ new ModuleBuilder(tb, "m1")
.exports("pkg2")
.classes("package pkg2; public class E { }")
.build(upgradeModule);
@@ -98,15 +99,15 @@
}
@Test
- void withModuleSourcePath(Path base) throws Exception {
+ public void withModuleSourcePath(Path base) throws Exception {
final Path module = base.resolve("modules");
- new ModuleBuilder("m1")
+ new ModuleBuilder(tb, "m1")
.exports("pkg1")
.classes("package pkg1; public class E { }")
.build(module);
final Path upgradeModule = base.resolve("upgradeModule");
- new ModuleBuilder("m1")
+ new ModuleBuilder(tb, "m1")
.exports("pkg2")
.classes("package pkg2; public class E { }")
.build(upgradeModule);
@@ -115,7 +116,7 @@
tb.writeJavaFiles(s.resolve("m3"), "module m3 { }");
final Path upgradeModule3 = base.resolve("upgradeModule");
- new ModuleBuilder("m3")
+ new ModuleBuilder(tb, "m3")
.exports("pkg3")
.classes("package pkg3; public class E { }")
.build(upgradeModule);
@@ -135,15 +136,15 @@
}
@Test
- void sameUpgradeAndModulePath(Path base) throws Exception {
+ public void sameUpgradeAndModulePath(Path base) throws Exception {
final Path module = base.resolve("modules");
- new ModuleBuilder("m1")
+ new ModuleBuilder(tb, "m1")
.exports("pkg1")
.classes("package pkg1; public class E { }")
.build(module);
final Path upgradeModule = base.resolve("upgradeModule");
- new ModuleBuilder("m1")
+ new ModuleBuilder(tb, "m1")
.exports("pkg2")
.classes("package pkg2; public class E { }")
.build(upgradeModule);
@@ -161,9 +162,9 @@
}
@Test
- void dummyFileInUpgradeModulePath(Path base) throws Exception {
+ public void dummyFileInUpgradeModulePath(Path base) throws Exception {
final Path module = base.resolve("modules");
- new ModuleBuilder("m1")
+ new ModuleBuilder(tb, "m1")
.exports("pkg1")
.classes("package pkg1; public class E { }")
.build(module);
@@ -189,24 +190,24 @@
}
@Test
- void severalUpgradeModules(Path base) throws Exception {
+ public void severalUpgradeModules(Path base) throws Exception {
final Path module = base.resolve("modules");
- new ModuleBuilder("m1")
+ new ModuleBuilder(tb, "m1")
.exports("pkg1")
.classes("package pkg1; public class A { }")
.build(module);
- new ModuleBuilder("m2")
+ new ModuleBuilder(tb, "m2")
.exports("pkg2")
.classes("package pkg2; public class B { }")
.build(module);
Path upgradeModule = base.resolve("upgradeModule");
- new ModuleBuilder("m2")
+ new ModuleBuilder(tb, "m2")
.exports("pkg2")
.classes("package pkg2; public class BC { }")
.build(upgradeModule);
- new ModuleBuilder("m3")
+ new ModuleBuilder(tb, "m3")
.exports("pkg3")
.classes("package pkg3; public class DC { }")
.build(upgradeModule);
@@ -240,21 +241,21 @@
}
@Test
- void severalUpgradeModulePathsLastWin(Path base) throws Exception {
+ public void severalUpgradeModulePathsLastWin(Path base) throws Exception {
final Path module = base.resolve("modules");
- new ModuleBuilder("m1")
+ new ModuleBuilder(tb, "m1")
.exports("pkg1")
.classes("package pkg1; public class E { }")
.build(module);
final Path upgradeModule1 = base.resolve("upgradeModule1");
- new ModuleBuilder("m1")
+ new ModuleBuilder(tb, "m1")
.exports("pkg2")
.classes("package pkg2; public class EC1 { }")
.build(upgradeModule1);
final Path upgradeModule2 = base.resolve("upgradeModule2");
- new ModuleBuilder("m1")
+ new ModuleBuilder(tb, "m1")
.exports("pkg2")
.classes("package pkg2; public class EC2 { }")
.build(upgradeModule2);
--- a/langtools/test/tools/javac/modules/UsesTest.java Mon May 02 15:01:54 2016 -0700
+++ b/langtools/test/tools/javac/modules/UsesTest.java Mon May 02 16:17:39 2016 -0700
@@ -28,7 +28,7 @@
* @modules
* jdk.compiler/com.sun.tools.javac.api
* jdk.compiler/com.sun.tools.javac.main
- * @build toolbox.ToolBox toolbox.JavacTask ModuleTestBase
+ * @build toolbox.ToolBox toolbox.JavacTask toolbox.ModuleBuilder ModuleTestBase
* @run main UsesTest
*/
@@ -39,6 +39,7 @@
import java.util.List;
import toolbox.JavacTask;
+import toolbox.ModuleBuilder;
import toolbox.Task;
import toolbox.ToolBox;
@@ -49,7 +50,7 @@
}
@Test
- void testSimple(Path base) throws Exception {
+ public void testSimple(Path base) throws Exception {
Path src = base.resolve("src");
tb.writeJavaFiles(src,
"module m { uses p.C; }",
@@ -65,7 +66,7 @@
}
@Test
- void testSimpleInner(Path base) throws Exception {
+ public void testSimpleInner(Path base) throws Exception {
Path src = base.resolve("src");
tb.writeJavaFiles(src,
"module m { uses p.C.Inner; }",
@@ -81,7 +82,7 @@
}
@Test
- void testSimpleAnnotation(Path base) throws Exception {
+ public void testSimpleAnnotation(Path base) throws Exception {
Path src = base.resolve("src");
tb.writeJavaFiles(src,
"module m { uses p.C; }",
@@ -97,7 +98,7 @@
}
@Test
- void testPrivateService(Path base) throws Exception {
+ public void testPrivateService(Path base) throws Exception {
Path src = base.resolve("src");
tb.writeJavaFiles(src,
"module m { uses p.C.A; uses p.C; }",
@@ -119,7 +120,7 @@
}
@Test
- void testMulti(Path base) throws Exception {
+ public void testMulti(Path base) throws Exception {
Path src = base.resolve("src");
tb.writeJavaFiles(src.resolve("m1"),
"module m1 { exports p; }",
@@ -138,13 +139,13 @@
}
@Test
- void testMultiOnModulePath(Path base) throws Exception {
+ public void testMultiOnModulePath(Path base) throws Exception {
Path modules = base.resolve("modules");
- new ModuleBuilder("m1")
+ new ModuleBuilder(tb, "m1")
.exports("p")
.classes("package p; public class C { }")
.build(modules);
- new ModuleBuilder("m2")
+ new ModuleBuilder(tb, "m2")
.requires("m1")
.uses("p.C")
.write(modules);
@@ -158,13 +159,13 @@
}
@Test
- void testMultiOnModulePathInner(Path base) throws Exception {
+ public void testMultiOnModulePathInner(Path base) throws Exception {
Path modules = base.resolve("modules");
- new ModuleBuilder("m1")
+ new ModuleBuilder(tb, "m1")
.exports("p")
.classes("package p; public class C { public class Inner { } }")
.build(modules);
- new ModuleBuilder("m2")
+ new ModuleBuilder(tb, "m2")
.requires("m1")
.uses("p.C.Inner")
.write(modules);
@@ -178,7 +179,7 @@
}
@Test
- void testDuplicateUses(Path base) throws Exception {
+ public void testDuplicateUses(Path base) throws Exception {
Path src = base.resolve("src");
tb.writeJavaFiles(src.resolve("m"),
"module m { uses p.C; uses p.C; }",
@@ -199,7 +200,7 @@
}
@Test
- void testServiceNotExist(Path base) throws Exception {
+ public void testServiceNotExist(Path base) throws Exception {
Path src = base.resolve("src");
tb.writeJavaFiles(src,
"module m { uses p.NotExist; }",
@@ -220,7 +221,7 @@
}
@Test
- void testUsesUnexportedService(Path base) throws Exception {
+ public void testUsesUnexportedService(Path base) throws Exception {
Path src = base.resolve("src");
tb.writeJavaFiles(src.resolve("m1"),
"module m1 { }",
@@ -244,7 +245,7 @@
}
@Test
- void testUsesUnexportedButProvidedService(Path base) throws Exception {
+ public void testUsesUnexportedButProvidedService(Path base) throws Exception {
Path src = base.resolve("src");
tb.writeJavaFiles(src.resolve("m1"),
"module m1 { provides p.C with p.C; }",
--- a/langtools/test/tools/javac/modules/XModuleTest.java Mon May 02 15:01:54 2016 -0700
+++ b/langtools/test/tools/javac/modules/XModuleTest.java Mon May 02 16:17:39 2016 -0700
@@ -28,7 +28,7 @@
* @modules
* jdk.compiler/com.sun.tools.javac.api
* jdk.compiler/com.sun.tools.javac.main
- * @build toolbox.ToolBox toolbox.JavacTask ModuleTestBase
+ * @build toolbox.ToolBox toolbox.JavacTask toolbox.ModuleBuilder ModuleTestBase
* @run main XModuleTest
*/
@@ -37,7 +37,9 @@
import java.util.List;
import toolbox.JavacTask;
+import toolbox.ModuleBuilder;
import toolbox.Task;
+import toolbox.TestRunner;
import toolbox.ToolBox;
public class XModuleTest extends ModuleTestBase {
@@ -47,7 +49,7 @@
}
@Test
- void testCorrectXModule(Path base) throws Exception {
+ public void testCorrectXModule(Path base) throws Exception {
//note: avoiding use of java.base, as that gets special handling on some places:
Path src = base.resolve("src");
tb.writeJavaFiles(src, "package javax.lang.model.element; public interface Extra extends Element { }");
@@ -67,7 +69,7 @@
}
@Test
- void testSourcePath(Path base) throws Exception {
+ public void testSourcePath(Path base) throws Exception {
//note: avoiding use of java.base, as that gets special handling on some places:
Path src = base.resolve("src");
tb.writeJavaFiles(src, "package javax.lang.model.element; public interface Extra extends Element, Other { }", "package javax.lang.model.element; interface Other { }");
@@ -87,7 +89,7 @@
}
@Test
- void testClassPath(Path base) throws Exception {
+ public void testClassPath(Path base) throws Exception {
Path cpSrc = base.resolve("cpSrc");
tb.writeJavaFiles(cpSrc, "package p; public interface Other { }");
Path cpClasses = base.resolve("cpClasses");
@@ -122,7 +124,7 @@
}
@Test
- void testNoModuleInfoOnSourcePath(Path base) throws Exception {
+ public void testNoModuleInfoOnSourcePath(Path base) throws Exception {
//note: avoiding use of java.base, as that gets special handling on some places:
Path src = base.resolve("src");
tb.writeJavaFiles(src,
@@ -147,7 +149,7 @@
}
@Test
- void testNoModuleInfoInClassOutput(Path base) throws Exception {
+ public void testNoModuleInfoInClassOutput(Path base) throws Exception {
//note: avoiding use of java.base, as that gets special handling on some places:
Path srcMod = base.resolve("src-mod");
tb.writeJavaFiles(srcMod,
@@ -187,7 +189,7 @@
}
@Test
- void testModuleSourcePathXModule(Path base) throws Exception {
+ public void testModuleSourcePathXModule(Path base) throws Exception {
//note: avoiding use of java.base, as that gets special handling on some places:
Path src = base.resolve("src");
tb.writeJavaFiles(src, "package javax.lang.model.element; public interface Extra extends Element { }");
@@ -210,7 +212,7 @@
}
@Test
- void testXModuleTooMany(Path base) throws Exception {
+ public void testXModuleTooMany(Path base) throws Exception {
//note: avoiding use of java.base, as that gets special handling on some places:
Path src = base.resolve("src");
tb.writeJavaFiles(src, "package javax.lang.model.element; public interface Extra extends Element { }");
@@ -234,9 +236,9 @@
}
@Test
- void testWithModulePath(Path base) throws Exception {
+ public void testWithModulePath(Path base) throws Exception {
Path module = base.resolve("modules");
- new ModuleBuilder("m1")
+ new ModuleBuilder(tb, "m1")
.classes("package pkg1; public interface E { }")
.build(module);
@@ -251,7 +253,7 @@
.writeAll();
//checks module bounds still exist
- new ModuleBuilder("m2")
+ new ModuleBuilder(tb, "m2")
.classes("package pkg2; public interface D { }")
.build(module);
@@ -275,14 +277,14 @@
}
@Test
- void testWithUpgradeModulePath(Path base) throws Exception {
+ public void testWithUpgradeModulePath(Path base) throws Exception {
Path module = base.resolve("modules");
- new ModuleBuilder("m1")
+ new ModuleBuilder(tb, "m1")
.classes("package pkg1; public interface E { }")
.build(module);
Path upgrade = base.resolve("upgrade");
- new ModuleBuilder("m1")
+ new ModuleBuilder(tb, "m1")
.classes("package pkg1; public interface D { }")
.build(upgrade);
--- a/langtools/test/tools/lib/toolbox/JavacTask.java Mon May 02 15:01:54 2016 -0700
+++ b/langtools/test/tools/lib/toolbox/JavacTask.java Mon May 02 16:17:39 2016 -0700
@@ -103,6 +103,16 @@
}
/**
+ * Sets the classpath.
+ * @param classpath the classpath
+ * @return this task object
+ */
+ public JavacTask classpath(List<Path> classpath) {
+ this.classpath = classpath;
+ return this;
+ }
+
+ /**
* Sets the sourcepath.
* @param sourcepath the sourcepath
* @return this task object
@@ -126,6 +136,16 @@
}
/**
+ * Sets the sourcepath.
+ * @param sourcepath the sourcepath
+ * @return this task object
+ */
+ public JavacTask sourcepath(List<Path> sourcepath) {
+ this.sourcepath = sourcepath;
+ return this;
+ }
+
+ /**
* Sets the output directory.
* @param outdir the output directory
* @return this task object
@@ -188,6 +208,18 @@
}
/**
+ * Sets the files to be compiled or analyzed.
+ * @param files the files
+ * @return this task object
+ */
+ public JavacTask files(List<Path> files) {
+ this.files = files.stream()
+ .map(Path::toString)
+ .collect(Collectors.toList());
+ return this;
+ }
+
+ /**
* Sets the sources to be compiled or analyzed.
* Each source string is converted into an in-memory object that
* can be passed directly to the compiler.
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/lib/toolbox/ModuleBuilder.java Mon May 02 16:17:39 2016 -0700
@@ -0,0 +1,111 @@
+/*
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package toolbox;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.stream.Collectors;
+
+public class ModuleBuilder {
+
+ private final ToolBox tb;
+ private final String name;
+ private String requires = "";
+ private String exports = "";
+ private String uses = "";
+ private String provides = "";
+ private String modulePath = "";
+ private List<String> content = new ArrayList<>();
+
+ public ModuleBuilder(ToolBox tb, String name) {
+ this.tb = tb;
+ this.name = name;
+ }
+
+ public ModuleBuilder requiresPublic(String requires, Path... modulePath) {
+ return requires("public " + requires, modulePath);
+ }
+
+ public ModuleBuilder requires(String requires, Path... modulePath) {
+ this.requires += " requires " + requires + ";\n";
+ this.modulePath += Arrays.stream(modulePath)
+ .map(Path::toString)
+ .collect(Collectors.joining(File.pathSeparator));
+ return this;
+ }
+
+ public ModuleBuilder exportsTo(String pkg, String module) {
+ return exports(pkg + " to " + module);
+ }
+
+ public ModuleBuilder exports(String pkg) {
+ this.exports += " exports " + pkg + ";\n";
+ return this;
+ }
+
+ public ModuleBuilder uses(String uses) {
+ this.uses += " uses " + uses + ";\n";
+ return this;
+ }
+
+ public ModuleBuilder provides(String service, String implementation) {
+ this.provides += " provides " + service + " with " + implementation + ";\n";
+ return this;
+ }
+
+ public ModuleBuilder classes(String... content) {
+ this.content.addAll(Arrays.asList(content));
+ return this;
+ }
+
+ public Path write(Path where) throws IOException {
+ Files.createDirectories(where);
+ List<String> sources = new ArrayList<>();
+ sources.add("module " + name + "{"
+ + requires
+ + exports
+ + uses
+ + provides
+ + "}");
+ sources.addAll(content);
+ Path moduleSrc = where.resolve(name + "/src");
+ tb.writeJavaFiles(moduleSrc, sources.toArray(new String[]{}));
+ return moduleSrc;
+ }
+
+ public void build(Path where) throws IOException {
+ Path moduleSrc = write(where);
+ new JavacTask(tb)
+ .outdir(where.resolve(name))
+ .options("-mp", modulePath)
+ .files(tb.findJavaFiles(moduleSrc))
+ .run()
+ .writeAll();
+ }
+}
--- a/langtools/test/tools/lib/toolbox/TestRunner.java Mon May 02 15:01:54 2016 -0700
+++ b/langtools/test/tools/lib/toolbox/TestRunner.java Mon May 02 16:17:39 2016 -0700
@@ -35,15 +35,16 @@
* Utility class to manage and execute sub-tests within a test.
*
* This class does the following:
- * i. invokes those test methods annotated with @Test
- * ii. keeps track of successful and failed tests
- * iii. throws an Exception if any test fails.
- * iv. provides a test summary at the end of the run.
- *
+ * <ul>
+ * <li> invokes those test methods annotated with @Test
+ * <li> keeps track of successful and failed tests
+ * <li> throws an Exception if any test fails.
+ * <li> provides a test summary at the end of the run.
+ * </ul>
+
* Tests must extend this class, annotate the test methods
* with @Test and call one of the runTests method.
*/
-
public abstract class TestRunner {
/** Marker annotation for test cases. */
@Retention(RetentionPolicy.RUNTIME)
@@ -54,7 +55,7 @@
public String testName = null;
- final PrintStream out;
+ protected PrintStream out;
/**
* Constructs the Object.
@@ -66,18 +67,18 @@
/**
* Invoke all methods annotated with @Test.
- * @throws java.lang.Exception
+ * @throws java.lang.Exception if any errors occur
*/
- public void runTests() throws Exception {
+ protected void runTests() throws Exception {
runTests(f -> new Object[0]);
}
/**
* Invoke all methods annotated with @Test.
- * @param f a lambda expression to specify arguments.
- * @throws java.lang.Exception
+ * @param f a lambda expression to specify arguments for the test method
+ * @throws java.lang.Exception if any errors occur
*/
- public void runTests(Function<Method, Object[]> f) throws Exception {
+ protected void runTests(Function<Method, Object[]> f) throws Exception {
for (Method m : getClass().getDeclaredMethods()) {
Annotation a = m.getAnnotation(Test.class);
if (a != null) {
--- a/langtools/test/tools/lib/toolbox/ToolBox.java Mon May 02 15:01:54 2016 -0700
+++ b/langtools/test/tools/lib/toolbox/ToolBox.java Mon May 02 16:17:39 2016 -0700
@@ -41,6 +41,7 @@
import java.nio.file.SimpleFileVisitor;
import java.nio.file.StandardCopyOption;
import java.nio.file.attribute.BasicFileAttributes;
+import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
@@ -49,6 +50,7 @@
import java.util.Map;
import java.util.Objects;
import java.util.Set;
+import java.util.TreeSet;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
@@ -315,7 +317,7 @@
* Reads the lines of a file.
* The file is read using the default character encoding.
* @param path the file to be read
- * @return the lines of the file.
+ * @return the lines of the file
* @throws IOException if an error occurred while reading the file
*/
public List<String> readAllLines(String path) throws IOException {
@@ -326,7 +328,7 @@
* Reads the lines of a file.
* The file is read using the default character encoding.
* @param path the file to be read
- * @return the lines of the file.
+ * @return the lines of the file
* @throws IOException if an error occurred while reading the file
*/
public List<String> readAllLines(Path path) throws IOException {
@@ -348,7 +350,7 @@
* Reads the lines of a file using the given encoding.
* @param path the file to be read
* @param encoding the encoding to be used to read the file
- * @return the lines of the file.
+ * @return the lines of the file
* @throws IOException if an error occurred while reading the file
*/
public List<String> readAllLines(Path path, String encoding) throws IOException {
@@ -360,6 +362,30 @@
}
/**
+ * Find .java files in one or more directories.
+ * <p>Similar to the shell "find" command: {@code find paths -name \*.java}.
+ * @param paths the directories in which to search for .java files
+ * @return the .java files found
+ * @throws IOException if an error occurred while searching for files
+ */
+ public Path[] findJavaFiles(Path... paths) throws IOException {
+ Set<Path> files = new TreeSet<>(); // use TreeSet to force a consistent order
+ for (Path p : paths) {
+ Files.walkFileTree(p, new SimpleFileVisitor<Path>() {
+ @Override
+ public FileVisitResult visitFile(Path file, BasicFileAttributes attrs)
+ throws IOException {
+ if (file.getFileName().toString().endsWith(".java")) {
+ files.add(file);
+ }
+ return FileVisitResult.CONTINUE;
+ }
+ });
+ }
+ return files.toArray(new Path[files.size()]);
+ }
+
+ /**
* Writes a file containing the given content.
* Any necessary directories for the file will be created.
* @param path where to write the file