mirror of
https://github.com/openjdk/jdk.git
synced 2026-05-12 14:39:49 +00:00
8212045: Add back tests removed from HashesTest.java and AddExportsTest.java
Reviewed-by: rriggs
This commit is contained in:
parent
24fb839864
commit
1226dcbcfe
@ -237,6 +237,28 @@ public class HashesTest {
|
||||
.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 {
|
||||
|
||||
@ -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 @@ public class AddExportsTest {
|
||||
|
||||
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 @@ public class AddExportsTest {
|
||||
"--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 @@ public class AddExportsTest {
|
||||
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
|
||||
|
||||
@ -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 {
|
||||
|
||||
|
||||
}
|
||||
@ -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 {
|
||||
}
|
||||
@ -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 {
|
||||
}
|
||||
@ -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;
|
||||
}
|
||||
@ -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();
|
||||
}
|
||||
}
|
||||
@ -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;
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user