--- old/test/java/util/logging/TestLoggerWeakRefLeak.java 2015-11-16 15:19:56.000000000 +0300 +++ new/test/java/util/logging/TestLoggerWeakRefLeak.java 2015-11-16 15:19:56.000000000 +0300 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2015, 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 @@ -128,7 +128,7 @@ int instanceCount = 0; HotSpotVirtualMachine vm = (HotSpotVirtualMachine) VirtualMachine - .attach(Integer.toString(ProcessTools.getProcessId())); + .attach(Long.toString(ProcessTools.getProcessId())); try { try (InputStream heapHistoStream = vm.heapHisto("-live"); BufferedReader in = new BufferedReader(new InputStreamReader(heapHistoStream))) { --- old/test/lib/testlibrary/jdk/testlibrary/JcmdBase.java 2015-11-16 15:19:57.000000000 +0300 +++ new/test/lib/testlibrary/jdk/testlibrary/JcmdBase.java 2015-11-16 15:19:57.000000000 +0300 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2015, 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 @@ -99,7 +99,7 @@ } } if (requestToCurrentProcess) { - launcher.addToolArg(Integer.toString(ProcessTools.getProcessId())); + launcher.addToolArg(Long.toString(ProcessTools.getProcessId())); } if (jcmdArgs != null) { for (String toolArg : jcmdArgs) { --- old/test/lib/testlibrary/jdk/testlibrary/ProcessTools.java 2015-11-16 15:19:58.000000000 +0300 +++ new/test/lib/testlibrary/jdk/testlibrary/ProcessTools.java 2015-11-16 15:19:58.000000000 +0300 @@ -27,8 +27,6 @@ import java.io.InputStream; import java.io.OutputStream; import java.io.PrintStream; -import java.lang.management.ManagementFactory; -import java.lang.management.RuntimeMXBean; import java.lang.reflect.Field; import java.lang.reflect.Method; import java.util.ArrayList; @@ -253,11 +251,8 @@ * * @return Process id */ - public static int getProcessId() throws Exception { - RuntimeMXBean runtime = ManagementFactory.getRuntimeMXBean(); - int pid = Integer.parseInt(runtime.getName().split("@")[0]); - - return pid; + public static long getProcessId() { + return ProcessHandle.current().getPid(); } /** --- old/test/lib/testlibrary/jdk/testlibrary/TestThread.java 2015-11-16 15:19:59.000000000 +0300 +++ new/test/lib/testlibrary/jdk/testlibrary/TestThread.java 2015-11-16 15:19:59.000000000 +0300 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2015, 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 @@ -23,9 +23,6 @@ package jdk.testlibrary; -import java.lang.management.ManagementFactory; -import java.lang.management.ThreadInfo; -import java.lang.management.ThreadMXBean; import java.util.concurrent.TimeoutException; /** @@ -204,46 +201,4 @@ } return null; } - - /** - * Waits until {@link TestThread} is in the certain {@link State} - * and blocking on {@code object}. - * - * @param state The thread state - * @param object The object to block on - */ - public void waitUntilBlockingOnObject(Thread.State state, Object object) { - String want = object == null ? null : object.getClass().getName() + '@' - + Integer.toHexString(System.identityHashCode(object)); - ThreadMXBean tmx = ManagementFactory.getThreadMXBean(); - while (isAlive()) { - ThreadInfo ti = tmx.getThreadInfo(getId()); - if (ti.getThreadState() == state - && (want == null || want.equals(ti.getLockName()))) { - return; - } - try { - Thread.sleep(1); - } catch (InterruptedException e) { - } - } - } - - /** - * Waits until {@link TestThread} is in native. - */ - public void waitUntilInNative() { - ThreadMXBean tmx = ManagementFactory.getThreadMXBean(); - while (isAlive()) { - ThreadInfo ti = tmx.getThreadInfo(getId()); - if (ti.isInNative()) { - return; - } - try { - Thread.sleep(1); - } catch (InterruptedException e) { - } - } - } - } --- old/test/sun/tools/jcmd/TestJcmdSanity.java 2015-11-16 15:20:00.000000000 +0300 +++ new/test/sun/tools/jcmd/TestJcmdSanity.java 2015-11-16 15:20:00.000000000 +0300 @@ -71,7 +71,7 @@ output.shouldHaveExitValue(0); output.shouldNotContain("Exception"); - output.shouldContain(Integer.toString(ProcessTools.getProcessId()) + ":"); + output.shouldContain(Long.toString(ProcessTools.getProcessId()) + ":"); matchJcmdCommands(output); output.shouldContain("For more information about a specific command use 'help '."); } --- old/test/sun/tools/jinfo/JInfoHelper.java 2015-11-16 15:20:01.000000000 +0300 +++ new/test/sun/tools/jinfo/JInfoHelper.java 2015-11-16 15:20:01.000000000 +0300 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2015, 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 @@ -60,7 +60,7 @@ } } if (toPid) { - launcher.addToolArg(Integer.toString(ProcessTools.getProcessId())); + launcher.addToolArg(Long.toString(ProcessTools.getProcessId())); } ProcessBuilder processBuilder = new ProcessBuilder(launcher.getCommand()); --- old/test/sun/tools/jmap/BasicJMapTest.java 2015-11-16 15:20:02.000000000 +0300 +++ new/test/sun/tools/jmap/BasicJMapTest.java 2015-11-16 15:20:02.000000000 +0300 @@ -111,7 +111,7 @@ launcher.addToolArg(toolArg); } } - launcher.addToolArg(Integer.toString(ProcessTools.getProcessId())); + launcher.addToolArg(Long.toString(ProcessTools.getProcessId())); processBuilder.command(launcher.getCommand()); System.out.println(Arrays.toString(processBuilder.command().toArray()).replace(",", "")); --- old/test/sun/tools/jps/JpsBase.java 2015-11-16 15:20:03.000000000 +0300 +++ new/test/sun/tools/jps/JpsBase.java 2015-11-16 15:20:03.000000000 +0300 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2015, 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 @@ -59,7 +59,7 @@ } public static void main(String[] args) throws Exception { - int pid = ProcessTools.getProcessId(); + long pid = ProcessTools.getProcessId(); List> combinations = JpsHelper.JpsArg.generateCombinations(); for (List combination : combinations) { @@ -76,7 +76,7 @@ // 30673 isQuiet = true; JpsHelper.verifyJpsOutput(output, "^\\d+$"); - output.shouldContain(Integer.toString(pid)); + output.shouldContain(Long.toString(pid)); break; case l: // If '-l' is specified output should contain the full package name for the application's main class --- old/test/sun/tools/jstack/BasicJStackTest.java 2015-11-16 15:20:04.000000000 +0300 +++ new/test/sun/tools/jstack/BasicJStackTest.java 2015-11-16 15:20:04.000000000 +0300 @@ -63,7 +63,7 @@ launcher.addToolArg(toolArg); } } - launcher.addToolArg(Integer.toString(ProcessTools.getProcessId())); + launcher.addToolArg(Long.toString(ProcessTools.getProcessId())); processBuilder.command(launcher.getCommand()); System.out.println(Arrays.toString(processBuilder.command().toArray()).replace(",", "")); --- old/test/lib/testlibrary/jdk/testlibrary/InputArguments.java 2015-11-16 15:20:05.000000000 +0300 +++ /dev/null 2015-11-16 15:20:05.000000000 +0300 @@ -1,88 +0,0 @@ -/* - * Copyright (c) 2013, 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.testlibrary; - -import java.lang.management.RuntimeMXBean; -import java.lang.management.ManagementFactory; -import java.util.List; - -/** - * This class provides access to the input arguments to the VM. - */ -public class InputArguments { - private static final List args; - - static { - RuntimeMXBean runtimeMxBean = ManagementFactory.getRuntimeMXBean(); - args = runtimeMxBean.getInputArguments(); - } - - /** - * Returns true if {@code arg} is an input argument to the VM. - * - * This is useful for checking boolean flags such as -XX:+UseSerialGC or - * -XX:-UsePerfData. - * - * @param arg The name of the argument. - * @return {@code true} if the given argument is an input argument, - * otherwise {@code false}. - */ - public static boolean contains(String arg) { - return args.contains(arg); - } - - /** - * Returns true if {@code prefix} is the start of an input argument to the - * VM. - * - * This is useful for checking if flags describing a quantity, such as - * -XX:+MaxMetaspaceSize=100m, is set without having to know the quantity. - * To check if the flag -XX:MaxMetaspaceSize is set, use - * {@code InputArguments.containsPrefix("-XX:MaxMetaspaceSize")}. - * - * @param prefix The start of the argument. - * @return {@code true} if the given argument is the start of an input - * argument, otherwise {@code false}. - */ - public static boolean containsPrefix(String prefix) { - for (String arg : args) { - if (arg.startsWith(prefix)) { - return true; - } - } - return false; - } - - /** - * Get the string containing input arguments passed to the VM - */ - public static String getInputArguments() { - StringBuilder result = new StringBuilder(); - for (String arg : args) - result.append(arg).append(' '); - - return result.toString(); - } - -} --- /dev/null 2015-11-16 15:20:05.000000000 +0300 +++ new/test/lib/testlibrary/jdk/testlibrary/management/InputArguments.java 2015-11-16 15:20:05.000000000 +0300 @@ -0,0 +1,88 @@ +/* + * Copyright (c) 2013, 2015, 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.testlibrary.management; + +import java.lang.management.RuntimeMXBean; +import java.lang.management.ManagementFactory; +import java.util.List; + +/** + * This class provides access to the input arguments to the VM. + */ +public class InputArguments { + private static final List args; + + static { + RuntimeMXBean runtimeMxBean = ManagementFactory.getRuntimeMXBean(); + args = runtimeMxBean.getInputArguments(); + } + + /** + * Returns true if {@code arg} is an input argument to the VM. + * + * This is useful for checking boolean flags such as -XX:+UseSerialGC or + * -XX:-UsePerfData. + * + * @param arg The name of the argument. + * @return {@code true} if the given argument is an input argument, + * otherwise {@code false}. + */ + public static boolean contains(String arg) { + return args.contains(arg); + } + + /** + * Returns true if {@code prefix} is the start of an input argument to the + * VM. + * + * This is useful for checking if flags describing a quantity, such as + * -XX:+MaxMetaspaceSize=100m, is set without having to know the quantity. + * To check if the flag -XX:MaxMetaspaceSize is set, use + * {@code InputArguments.containsPrefix("-XX:MaxMetaspaceSize")}. + * + * @param prefix The start of the argument. + * @return {@code true} if the given argument is the start of an input + * argument, otherwise {@code false}. + */ + public static boolean hasArgStartingWith(String prefix) { + for (String arg : args) { + if (arg.startsWith(prefix)) { + return true; + } + } + return false; + } + + /** + * Get the string containing input arguments passed to the VM + */ + public static String getInputArguments() { + StringBuilder result = new StringBuilder(); + for (String arg : args) + result.append(arg).append(' '); + + return result.toString(); + } + +} --- /dev/null 2015-11-16 15:20:06.000000000 +0300 +++ new/test/lib/testlibrary/jdk/testlibrary/management/ThreadMXBeanTool.java 2015-11-16 15:20:06.000000000 +0300 @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2015, 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.testlibrary.management; + +import java.lang.management.ManagementFactory; +import java.lang.management.ThreadInfo; +import java.lang.management.ThreadMXBean; +import java.util.concurrent.TimeoutException; + +/** + * A few utility methods to use ThreadMXBean. + */ +public final class ThreadMXBeanTool { + + /** + * Waits until {@link Thread} is in the certain {@link State} + * and blocking on {@code object}. + * + * @param state The thread state + * @param object The object to block on + */ + public static void waitUntilBlockingOnObject(Thread thread, Thread.State state, Object object) { + String want = object == null ? null : object.getClass().getName() + '@' + + Integer.toHexString(System.identityHashCode(object)); + ThreadMXBean tmx = ManagementFactory.getThreadMXBean(); + while (thread.isAlive()) { + ThreadInfo ti = tmx.getThreadInfo(thread.getId()); + if (ti.getThreadState() == state + && (want == null || want.equals(ti.getLockName()))) { + return; + } + try { + Thread.sleep(1); + } catch (InterruptedException e) { + } + } + } + + /** + * Waits until {@link Thread} is in native. + */ + public static void waitUntilInNative(Thread thread) { + ThreadMXBean tmx = ManagementFactory.getThreadMXBean(); + while (thread.isAlive()) { + ThreadInfo ti = tmx.getThreadInfo(thread.getId()); + if (ti.isInNative()) { + return; + } + try { + Thread.sleep(1); + } catch (InterruptedException e) { + } + } + } + +}