8211287: ClassPathTests.java fails due to "Unable to map MiscData shared space at required address."

Catch the InvocationTargetException and rethrow exception based on the cause

Reviewed-by: jiangli, iklam
This commit is contained in:
Calvin Cheung 2018-10-02 20:52:40 -07:00
parent 1cca59019b
commit 40b75053e4

@ -52,6 +52,7 @@
* same name and package.
*/
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.nio.file.Path;
import java.nio.file.Paths;
@ -62,6 +63,8 @@ import jdk.test.lib.cds.CDSTestUtils;
import jdk.test.lib.process.ProcessTools;
import jdk.test.lib.process.OutputAnalyzer;
import jtreg.SkippedException;
public class ClassPathTests {
private static final String TEST_SRC = System.getProperty("test.src");
@ -83,7 +86,7 @@ public class ClassPathTests {
private static String testArchiveName;
public static void main(String[] args) throws Exception {
public static void main(String[] args) throws Throwable {
ClassPathTests tests = new ClassPathTests();
tests.dumpArchive();
@ -92,7 +95,16 @@ public class ClassPathTests {
for (Method m : methods) {
if (m.getName().startsWith("test")) {
System.out.println("About to run test method: " + m.getName());
m.invoke(tests);
try {
m.invoke(tests);
} catch (InvocationTargetException ite) {
Throwable throwable = ite.getCause();
if (throwable instanceof SkippedException) {
throw throwable;
} else {
throw ite;
}
}
numOfTestMethodsRun++;
}
}