8212045: Add back tests removed from HashesTest.java and AddExportsTest.java
Reviewed-by: rriggs
--- a/test/jdk/tools/jmod/hashes/HashesTest.java Fri Oct 12 10:08:11 2018 -0700
+++ b/test/jdk/tools/jmod/hashes/HashesTest.java Fri Oct 12 14:16:24 2018 -0400
@@ -237,6 +237,28 @@
.forEach(mn -> assertTrue(ht.hashes(mn) == null));
}
+ @Test
+ public static void upgradeableModule() throws IOException {
+ Path mpath = Paths.get(System.getProperty("java.home"), "jmods");
+ if (!Files.exists(mpath)) {
+ return;
+ }
+
+ Path dest = Paths.get("test4");
+ HashesTest ht = new HashesTest(dest);
+ ht.makeModule("m1");
+ ht.makeModule("java.compiler", "m1");
+ ht.makeModule("m2", "java.compiler");
+
+ ht.makeJmod("m1");
+ ht.makeJmod("m2");
+ ht.makeJmod("java.compiler",
+ "--module-path",
+ ht.lib.toString() + File.pathSeparator + mpath,
+ "--hash-modules", "java\\.(?!se)|^m.*");
+
+ ht.checkHashes("java.compiler", "m2");
+ }
@Test
public static void testImageJmods() throws IOException {
--- a/test/jdk/tools/launcher/modules/addexports/AddExportsTest.java Fri Oct 12 10:08:11 2018 -0700
+++ b/test/jdk/tools/launcher/modules/addexports/AddExportsTest.java Fri Oct 12 14:16:24 2018 -0400
@@ -24,7 +24,8 @@
/**
* @test
* @library /test/lib
- * @modules jdk.compiler
+ * @modules java.compiler
+ * jdk.compiler
* @build AddExportsTest jdk.test.lib.compiler.CompilerUtils
* @run testng AddExportsTest
* @summary Basic tests for java --add-exports
@@ -51,12 +52,15 @@
private static final Path SRC_DIR = Paths.get(TEST_SRC, "src");
private static final Path MODS_DIR = Paths.get("mods");
+ private static final Path UPGRADE_MODS_DIRS = Paths.get("upgrademods");
// test module m1 that uses Unsafe
private static final String TEST1_MODULE = "m1";
private static final String TEST1_MAIN_CLASS = "jdk.test1.Main";
-
+ // test module m2 uses java.compiler internals
+ private static final String TEST2_MODULE = "m2";
+ private static final String TEST2_MAIN_CLASS = "jdk.test2.Main";
// test module m3 uses m4 internals
private static final String TEST3_MODULE = "m3";
@@ -74,7 +78,19 @@
"--add-exports", "java.base/jdk.internal.misc=m1");
assertTrue(compiled, "module " + TEST1_MODULE + " did not compile");
+ // javac -d upgrademods/java.compiler src/java.compiler/**
+ compiled = CompilerUtils.compile(
+ SRC_DIR.resolve("java.compiler"),
+ UPGRADE_MODS_DIRS.resolve("java.compiler"));
+ assertTrue(compiled, "module java.compiler did not compile");
+ // javac --upgrade-module-path upgrademods -d mods/m2 src/m2/**
+ compiled = CompilerUtils.compile(
+ SRC_DIR.resolve(TEST2_MODULE),
+ MODS_DIR.resolve(TEST2_MODULE),
+ "--upgrade-module-path", UPGRADE_MODS_DIRS.toString(),
+ "--add-exports", "java.compiler/javax.tools.internal=m2");
+ assertTrue(compiled, "module " + TEST2_MODULE + " did not compile");
// javac -d mods/m3 src/m3/**
compiled = CompilerUtils.compile(
@@ -146,7 +162,25 @@
assertTrue(exitValue == 0);
}
+ /**
+ * Test --add-exports with upgraded module
+ */
+ public void testWithUpgradedModule() throws Exception {
+ // java --add-exports java.compiler/javax.tools.internal=m2
+ // --upgrade-module-path upgrademods --module-path mods -m ...
+ String mid = TEST2_MODULE + "/" + TEST2_MAIN_CLASS;
+ int exitValue = executeTestJava(
+ "--add-exports", "java.compiler/javax.tools.internal=m2",
+ "--upgrade-module-path", UPGRADE_MODS_DIRS.toString(),
+ "--module-path", MODS_DIR.toString(),
+ "-m", mid)
+ .outputTo(System.out)
+ .errorTo(System.out)
+ .getExitValue();
+
+ assertTrue(exitValue == 0);
+ }
/**
* Test --add-exports with module that is added to the set of root modules
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/tools/launcher/modules/addexports/src/java.compiler/javax/annotation/processing/Generated.java Fri Oct 12 14:16:24 2018 -0400
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2018, 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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 javax.annotation.processing;
+
+public interface Generated {
+
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/tools/launcher/modules/addexports/src/java.compiler/javax/tools/ToolsHelper.java Fri Oct 12 14:16:24 2018 -0400
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2018, 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 javax.tools;
+
+public class ToolsHelper {
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/tools/launcher/modules/addexports/src/java.compiler/javax/tools/internal/Helper.java Fri Oct 12 14:16:24 2018 -0400
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2018, 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 javax.tools.internal;
+
+public class Helper {
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/tools/launcher/modules/addexports/src/java.compiler/module-info.java Fri Oct 12 14:16:24 2018 -0400
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2018, 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.
+ */
+
+module java.compiler {
+ exports javax.tools;
+ exports javax.annotation.processing;
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/tools/launcher/modules/addexports/src/m2/jdk/test2/Main.java Fri Oct 12 14:16:24 2018 -0400
@@ -0,0 +1,32 @@
+/**
+ * Copyright (c) 2015, 2018, 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 jdk.test2;
+
+import javax.tools.internal.Helper;
+
+public class Main {
+ public static void main(String[] args) {
+ Helper h = new Helper();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/tools/launcher/modules/addexports/src/m2/module-info.java Fri Oct 12 14:16:24 2018 -0400
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2015, 2018, 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.
+ */
+
+module m2 {
+ requires java.compiler;
+}