8215449: Several tests failing when jtreg run with -vmoption:--illegal-access=deny
Reviewed-by: redestad, mchung, jjg
--- a/test/jdk/java/net/URL/RacyHandler.java Thu Dec 13 11:05:40 2018 -0800
+++ b/test/jdk/java/net/URL/RacyHandler.java Tue Dec 18 10:26:15 2018 +0000
@@ -32,6 +32,7 @@
* @test
* @bug 8213942
* @summary URLStreamHandler initialization race
+ * @modules java.base/java.net:open
* @run main/othervm RacyHandler
* @run main/othervm RacyHandler
* @run main/othervm RacyHandler
@@ -110,4 +111,4 @@
return null;
}
}
-}
\ No newline at end of file
+}
--- a/test/jdk/java/util/Locale/LocaleProvidersRun.java Thu Dec 13 11:05:40 2018 -0800
+++ b/test/jdk/java/util/Locale/LocaleProvidersRun.java Tue Dec 18 10:26:15 2018 +0000
@@ -156,6 +156,7 @@
launcher.addToolArg("-cp")
.addToolArg(Utils.TEST_CLASS_PATH)
.addToolArg("-Djava.locale.providers=" + prefList)
+ .addToolArg("--add-exports=java.base/sun.util.locale.provider=ALL-UNNAMED")
.addToolArg("LocaleProviders")
.addToolArg(methodName)
.addToolArg(param1)
--- a/test/langtools/tools/javac/platform/CanHandleClassFilesTest.java Thu Dec 13 11:05:40 2018 -0800
+++ b/test/langtools/tools/javac/platform/CanHandleClassFilesTest.java Tue Dec 18 10:26:15 2018 +0000
@@ -26,8 +26,11 @@
* @bug 8207954
* @summary Verify that CreateSymbols can handle classfiles from the current release.
* @library /tools/lib /tools/javac/lib
- * @modules jdk.compiler/com.sun.tools.javac.api
+ * @modules jdk.compiler/com.sun.tools.javac.api:+open
* jdk.compiler/com.sun.tools.javac.main
+ * jdk.compiler/com.sun.tools.javac.jvm:+open
+ * jdk.compiler/com.sun.tools.javac.util:+open
+ * jdk.jdeps/com.sun.tools.classfile:+open
* @build toolbox.ToolBox toolbox.JavacTask toolbox.Task
* @run main CanHandleClassFilesTest
*/
@@ -36,6 +39,7 @@
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
+import java.util.stream.Stream;
import javax.tools.StandardLocation;
@@ -93,8 +97,16 @@
}
};
+ // open the non-exported packages needed by CreateSymbols to its module
+ Module targetModule = cl.getUnnamedModule();
+ Stream.of("jdk.compiler/com.sun.tools.javac.api",
+ "jdk.compiler/com.sun.tools.javac.jvm",
+ "jdk.compiler/com.sun.tools.javac.util",
+ "jdk.jdeps/com.sun.tools.classfile")
+ .forEach(p -> open(p, targetModule));
+
var createSymbolsClass = Class.forName("build.tools.symbolgenerator.CreateSymbols", false, cl);
- var main = createSymbolsClass.getDeclaredMethod("main", String[].class);
+ var main = createSymbolsClass.getMethod("main", String[].class);
var symbols = targetDir.resolve("symbols");
try (Writer w = Files.newBufferedWriter(symbols)) {}
@@ -112,4 +124,11 @@
}
}
+ void open(String moduleAndPackage, Module target) {
+ String[] s = moduleAndPackage.split("/");
+ var moduleName = s[0];
+ var packageName = s[1];
+ ModuleLayer.boot().findModule(moduleName).orElseThrow().addOpens(packageName, target);
+ }
+
}