# HG changeset patch # User iignatyev # Date 1508365183 25200 # Wed Oct 18 15:19:43 2017 -0700 # Node ID e4fddaa51c41a48da4e3876b493a5ff26b4e4489 # Parent 1c21c60f51bf7c9743b52e0831f17d6b8017bd3f 8186618: [TESTBUG] Test applications/ctw/Modules.java doesn't have timeout and hang on windows Reviewed-by: duke diff --git a/test/hotspot/jtreg/ProblemList.txt b/test/hotspot/jtreg/ProblemList.txt --- a/test/hotspot/jtreg/ProblemList.txt +++ b/test/hotspot/jtreg/ProblemList.txt @@ -54,6 +54,9 @@ # aot test intermittently failing in jprt 8175791 compiler/aot/DeoptimizationTest.java 8175791 windows-all +applications/ctw/modules/java_desktop.java 8189604 windows-all +applications/ctw/modules/jdk_jconsole.java 8189604 windows-all + ############################################################################# # :hotspot_gc diff --git a/test/hotspot/jtreg/applications/ctw/modules/generate.bash b/test/hotspot/jtreg/applications/ctw/modules/generate.bash new file mode 100644 --- /dev/null +++ b/test/hotspot/jtreg/applications/ctw/modules/generate.bash @@ -0,0 +1,72 @@ +#!/bin/bash +# +# Copyright (c) 2017, 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. +# + +# generates CTW tests for modules passed as argument + +for module in $@ +do + file=${module//./_}.java + echo creating $file for $module... + cat > $file < { diff --git a/test/hotspot/jtreg/testlibrary/ctw/src/sun/hotspot/tools/ctw/CtwRunner.java b/test/hotspot/jtreg/testlibrary/ctw/src/sun/hotspot/tools/ctw/CtwRunner.java --- a/test/hotspot/jtreg/testlibrary/ctw/src/sun/hotspot/tools/ctw/CtwRunner.java +++ b/test/hotspot/jtreg/testlibrary/ctw/src/sun/hotspot/tools/ctw/CtwRunner.java @@ -35,8 +35,6 @@ import java.nio.file.Paths; import java.util.ArrayList; import java.util.List; -import java.util.concurrent.Executor; -import java.util.concurrent.ExecutorService; import java.util.concurrent.TimeUnit; import java.util.function.Predicate; import java.util.regex.Pattern; @@ -62,19 +60,27 @@ } private final List errors; + private final String target; private final Path targetPath; private final String targetName; private CtwRunner(String target) { - if (target.equals("modules")) { + if (target.startsWith("modules")) { targetPath = Paths .get(Utils.TEST_JDK) .resolve("lib") - .resolve(target); + .resolve("modules"); + if (target.equals("modules")){ + target = targetPath.toString(); + } + targetName = target.replace(':', '_') + .replace('.', '_') + .replace(',', '_'); } else { targetPath = Paths.get(target).toAbsolutePath(); + targetName = targetPath.getFileName().toString(); } - targetName = targetPath.getFileName().toString(); + this.target = target; errors = new ArrayList<>(); } @@ -104,7 +110,7 @@ long classStart = 0L; long classCount = classCount(); Asserts.assertGreaterThan(classCount, 0L, - targetPath + " does not have any classes"); + target + "(at " + targetPath + ") does not have any classes"); boolean done = false; while (!done) { String[] cmd = cmd(classStart); @@ -138,7 +144,7 @@ + "] != classCount[" + classCount + "]")); } else { System.out.println("Executed CTW for all " + classCount - + " classes in " + targetPath); + + " classes in " + target + "(at " + targetPath + ")"); } done = true; } else { @@ -162,7 +168,7 @@ } private long classCount() { - List phs = PathHandler.create(targetPath.toString()); + List phs = PathHandler.create(target); long result = phs.stream() .mapToLong(PathHandler::classCount) .sum(); @@ -215,7 +221,7 @@ "-XX:CompileCommand=exclude,java/lang/invoke/MethodHandle.*", // CTW entry point CompileTheWorld.class.getName(), - targetPath.toString(), + target, }; } diff --git a/test/hotspot/jtreg/testlibrary/ctw/src/sun/hotspot/tools/ctw/PathHandler.java b/test/hotspot/jtreg/testlibrary/ctw/src/sun/hotspot/tools/ctw/PathHandler.java --- a/test/hotspot/jtreg/testlibrary/ctw/src/sun/hotspot/tools/ctw/PathHandler.java +++ b/test/hotspot/jtreg/testlibrary/ctw/src/sun/hotspot/tools/ctw/PathHandler.java @@ -24,9 +24,12 @@ package sun.hotspot.tools.ctw; import java.io.Closeable; +import java.net.URI; +import java.nio.file.FileSystems; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; +import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.Objects; @@ -35,6 +38,7 @@ import java.util.function.Function; import java.util.regex.Matcher; import java.util.regex.Pattern; +import java.util.stream.Collectors; import java.util.stream.Stream; /** @@ -121,6 +125,15 @@ path = matcher.group(1); path = path.isEmpty() ? "." : path; return ClassPathJarInDirEntry.create(Paths.get(path)); + } else if (path.startsWith("modules:")) { + Path modules = FileSystems.getFileSystem(URI.create("jrt:/")) + .getPath("modules"); + return Arrays.stream(path.substring("modules:".length()) + .split(",")) + .map(modules::resolve) + .map(ClassPathDirEntry::new) + .map(PathHandler::new) + .collect(Collectors.toList()); } else { path = path.isEmpty() ? "." : path; Path p = Paths.get(path); @@ -180,7 +193,9 @@ */ public final void process(Executor executor) { CompileTheWorld.OUT.println(entry.description()); - entry.classes().forEach(s -> processClass(s, executor)); + entry.classes() + .distinct() + .forEach(s -> processClass(s, executor)); } /** @@ -209,12 +224,12 @@ Class aClass; Thread.currentThread().setContextClassLoader(entry.loader()); try { - CompileTheWorld.OUT.printf("[%d]\t%s%n", id, name); + CompileTheWorld.OUT.print(String.format("[%d]\t%s%n", id, name)); aClass = entry.loader().loadClass(name); Compiler.compileClass(aClass, id, executor); } catch (Throwable e) { - CompileTheWorld.OUT.printf("[%d]\t%s\tWARNING skipped: %s%n", - id, name, e); + CompileTheWorld.OUT.println(String.format("[%d]\t%s\tWARNING skipped: %s%n", + id, name, e)); e.printStackTrace(CompileTheWorld.ERR); } } diff --git a/test/hotspot/jtreg/testlibrary/ctw/src/sun/hotspot/tools/ctw/Utils.java b/test/hotspot/jtreg/testlibrary/ctw/src/sun/hotspot/tools/ctw/Utils.java --- a/test/hotspot/jtreg/testlibrary/ctw/src/sun/hotspot/tools/ctw/Utils.java +++ b/test/hotspot/jtreg/testlibrary/ctw/src/sun/hotspot/tools/ctw/Utils.java @@ -193,10 +193,11 @@ * @param filename tested filename */ public static boolean isClassFile(String filename) { - // If the filename has a period after removing '.class', it's not valid class file return endsWithIgnoreCase(filename, CLASSFILE_EXT) - && (filename.indexOf('.') - == (filename.length() - CLASSFILE_EXT.length())); + // skip all module-info.class files + && !(filename.substring(filename.lastIndexOf('/') + 1, + filename.lastIndexOf('.')) + .equals("module-info")); } /**