# HG changeset patch # User jjg # Date 1477006302 25200 # Node ID 7b8819e2255136d49027a724af0b05d6b3ee8d43 # Parent 7b24b4c32ee6fac0bda5af005937ded4b982ddba 8168343: 3 javac tests fail when run on an exploded image Reviewed-by: darcy diff -r 7b24b4c32ee6 -r 7b8819e22551 langtools/test/tools/javac/Paths/MineField.sh --- a/langtools/test/tools/javac/Paths/MineField.sh Thu Oct 20 13:44:51 2016 -0700 +++ b/langtools/test/tools/javac/Paths/MineField.sh Thu Oct 20 16:31:42 2016 -0700 @@ -109,9 +109,15 @@ echo 'public class Main {public static void main(String[] a) {Lib.f();}}' > Main.java # Create a jar file that is good enough to put on the javac boot class path (i.e. contains java.lang.**) -Sys "$jimage" extract --dir modules ${TESTJAVA}/lib/modules -Sys "$jar" cf java-lang.jar -C modules/java.base java/lang -Sys rm -rf modules +if [ -r ${TESTJAVA}/lib/modules ]; then + Sys "$jimage" extract --dir modules ${TESTJAVA}/lib/modules + Sys "$jar" cf java-lang.jar -C modules/java.base java/lang + Sys rm -rf modules +elif [ -d ${TESTJAVA}/modules ]; then + Sys "$jar" cf java-lang.jar -C ${TESTJAVA}/modules/java.base java/lang +else + echo 'cannot create java-lang.jar' ; exit 1 +fi #---------------------------------------------------------------- # Verify that javac class search order is the same as java's diff -r 7b24b4c32ee6 -r 7b8819e22551 langtools/test/tools/javac/api/ToolProvider/ToolProviderTest.java --- a/langtools/test/tools/javac/api/ToolProvider/ToolProviderTest.java Thu Oct 20 13:44:51 2016 -0700 +++ b/langtools/test/tools/javac/api/ToolProvider/ToolProviderTest.java Thu Oct 20 16:31:42 2016 -0700 @@ -21,8 +21,11 @@ * questions. */ +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.Objects; import javax.tools.ToolProvider; -import java.util.Objects; /** * @test @@ -36,6 +39,18 @@ // run in other vm to ensure the initialization code path is exercised. public class ToolProviderTest { public static void main(String... args) { + // The following code allows the test to be skipped when run on + // an exploded image. + // See https://bugs.openjdk.java.net/browse/JDK-8155858 + Path javaHome = Paths.get(System.getProperty("java.home")); + Path image = javaHome.resolve("lib").resolve("modules"); + Path modules = javaHome.resolve("modules"); + if (!Files.exists(image) && Files.exists(modules)) { + System.err.println("Test running on exploded image"); + System.err.println("Test skipped!"); + return; + } + System.setSecurityManager(new SecurityManager()); Objects.requireNonNull(ToolProvider.getSystemDocumentationTool()); diff -r 7b24b4c32ee6 -r 7b8819e22551 langtools/test/tools/javac/processing/model/testgetallmembers/Main.java --- a/langtools/test/tools/javac/processing/model/testgetallmembers/Main.java Thu Oct 20 13:44:51 2016 -0700 +++ b/langtools/test/tools/javac/processing/model/testgetallmembers/Main.java Thu Oct 20 16:31:42 2016 -0700 @@ -31,6 +31,7 @@ */ import java.io.File; +import java.nio.file.Path; import java.util.*; import java.util.Map.Entry; @@ -84,7 +85,9 @@ continue; if (type.endsWith("module-info")) continue; - String moduleName = fm.asPath(file).getName(1).toString(); + Path path = fm.asPath(file); + int moduleIndex = path.getNameCount() - type.split("\\Q.\\E").length - 1; + String moduleName = path.getName(moduleIndex).toString(); try { ModuleElement me = elements.getModuleElement(moduleName); me.getClass();