From 6f18b7da8f0decc7c0eeddb74d7ff186c09dddde Mon Sep 17 00:00:00 2001 From: Katja Kantserova Date: Tue, 28 Apr 2015 14:39:21 +0200 Subject: [PATCH] 8076524: Remove jhat tests and help library from JDK Reviewed-by: sla, alanb --- jdk/test/sun/tools/common/ApplicationSetup.sh | 210 ------------------ jdk/test/sun/tools/common/CommonSetup.sh | 131 ----------- .../common/ShutdownSimpleApplication.java | 76 ------- .../sun/tools/common/SimpleApplication.java | 120 ---------- .../sun/tools/common/SleeperApplication.java | 59 ----- jdk/test/sun/tools/jhat/HatHeapDump1Test.java | 88 -------- jdk/test/sun/tools/jhat/HelloWorld.java | 51 ----- jdk/test/sun/tools/jhat/ParseTest.sh | 69 ------ jdk/test/sun/tools/jhat/README.TXT | 16 -- 9 files changed, 820 deletions(-) delete mode 100644 jdk/test/sun/tools/common/ApplicationSetup.sh delete mode 100644 jdk/test/sun/tools/common/CommonSetup.sh delete mode 100644 jdk/test/sun/tools/common/ShutdownSimpleApplication.java delete mode 100644 jdk/test/sun/tools/common/SimpleApplication.java delete mode 100644 jdk/test/sun/tools/common/SleeperApplication.java delete mode 100644 jdk/test/sun/tools/jhat/HatHeapDump1Test.java delete mode 100644 jdk/test/sun/tools/jhat/HelloWorld.java delete mode 100644 jdk/test/sun/tools/jhat/ParseTest.sh delete mode 100644 jdk/test/sun/tools/jhat/README.TXT diff --git a/jdk/test/sun/tools/common/ApplicationSetup.sh b/jdk/test/sun/tools/common/ApplicationSetup.sh deleted file mode 100644 index 64da8b969be..00000000000 --- a/jdk/test/sun/tools/common/ApplicationSetup.sh +++ /dev/null @@ -1,210 +0,0 @@ -#!/bin/sh - -# -# Copyright (c) 2005, 2012, 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. -# - - -# Support functions to start, stop, wait for or kill a given SimpleApplication - -# Starts a given app as background process, usage: -# startApplication port-file [args...] -# -# The following variables are set: -# -# appJavaPid - application's Java pid -# appOtherPid - pid associated with the app other than appJavaPid -# appPidList - all pids associated with the app -# appOutput - file containing stdout and stderr from the app -# -# Waits for at least one line of output from the app to indicate -# that it is up and running. -# -startApplication() -{ - appOutput="${TESTCLASSES}/Application.out" - - ${JAVA} -XX:+UsePerfData -classpath "${TESTCLASSPATH:-${TESTCLASSES}}" "$@" > "$appOutput" 2>&1 & - appJavaPid="$!" - appOtherPid= - appPidList="$appJavaPid" - - echo "INFO: waiting for $1 to initialize..." - _cnt=0 - while true; do - # if the app doesn't start then the JavaTest/JTREG timeout will - # kick in so this isn't really a endless loop - sleep 1 - out=`tail -1 "$appOutput"` - if [ -n "$out" ]; then - # we got some output from the app so it's running - break - fi - _cnt=`expr $_cnt + 1` - echo "INFO: waited $_cnt second(s) ..." - done - unset _cnt - - if $isWindows; then - # Windows requires special handling - appOtherPid="$appJavaPid" - - if $isCygwin; then - appJavaPid=`ps -p "$appOtherPid" \ - | sed -n ' - # See if $appOtherPid is in PID column; there are sometimes - # non-blanks in column 1 (I and S observed so far) - /^.'"${PATTERN_WS}${PATTERN_WS}*${appOtherPid}${PATTERN_WS}"'/{ - # strip PID column - s/^.'"${PATTERN_WS}${PATTERN_WS}*${appOtherPid}${PATTERN_WS}${PATTERN_WS}"'*// - # strip PPID column - s/^[1-9][0-9]*'"${PATTERN_WS}${PATTERN_WS}"'*// - # strip PGID column - s/^[1-9][0-9]*'"${PATTERN_WS}${PATTERN_WS}"'*// - # strip everything after WINPID column - s/'"${PATTERN_WS}"'.*// - p - q - } - '` - echo "INFO: Cygwin pid=$appOtherPid maps to Windows pid=$appJavaPid" - else - # show PID, PPID and COMM columns only - appJavaPid=`ps -o pid,ppid,comm \ - | sed -n ' - # see if appOtherPid is in either PID or PPID columns - /'"${PATTERN_WS}${appOtherPid}${PATTERN_WS}"'/{ - # see if this is a java command - /java'"${PATTERN_EOL}"'/{ - # strip leading white space - s/^'"${PATTERN_WS}${PATTERN_WS}"'*// - # strip everything after the first word - s/'"${PATTERN_WS}"'.*// - # print the pid and we are done - p - q - } - } - '` - echo "INFO: MKS shell pid=$appOtherPid; Java pid=$appJavaPid" - fi - - if [ -z "$appJavaPid" ]; then - echo "ERROR: could not find app's Java pid." >&2 - killApplication - exit 2 - fi - appPidList="$appOtherPid $appJavaPid" - fi - - echo "INFO: $1 is process $appJavaPid" - echo "INFO: $1 output is in $appOutput" -} - - -# Stops a simple application by invoking ShutdownSimpleApplication -# class with a specific port-file, usage: -# stopApplication port-file -# -# Note: When this function returns, the SimpleApplication (or a subclass) -# may still be running because the application has not yet reached the -# shutdown check. -# -stopApplication() -{ - $JAVA -XX:+UsePerfData -classpath "${TESTCLASSPATH:-${TESTCLASSES}}" ShutdownSimpleApplication $1 -} - - -# Wait for a simple application to stop running. -# -waitForApplication() { - if [ $isWindows = false ]; then - # non-Windows is easy; just one process - echo "INFO: waiting for $appJavaPid" - set +e - wait "$appJavaPid" - set -e - - elif $isCygwin; then - # Cygwin pid and not the Windows pid - echo "INFO: waiting for $appOtherPid" - set +e - wait "$appOtherPid" - set -e - - else # implied isMKS - # MKS has intermediate shell and Java process - echo "INFO: waiting for $appJavaPid" - - # appJavaPid can be empty if pid search in startApplication() failed - if [ -n "$appJavaPid" ]; then - # only need to wait for the Java process - set +e - wait "$appJavaPid" - set -e - fi - fi -} - - -# Kills a simple application by sending a SIGTERM to the appropriate -# process(es); on Windows SIGQUIT (-9) is used. -# -killApplication() -{ - if [ $isWindows = false ]; then - # non-Windows is easy; just one process - echo "INFO: killing $appJavaPid" - set +e - kill -TERM "$appJavaPid" # try a polite SIGTERM first - sleep 2 - # send SIGQUIT (-9) just in case SIGTERM didn't do it - # but don't show any complaints - kill -QUIT "$appJavaPid" > /dev/null 2>&1 - wait "$appJavaPid" - set -e - - elif $isCygwin; then - # Cygwin pid and not the Windows pid - echo "INFO: killing $appOtherPid" - set +e - kill -9 "$appOtherPid" - wait "$appOtherPid" - set -e - - else # implied isMKS - # MKS has intermediate shell and Java process - echo "INFO: killing $appPidList" - set +e - kill -9 $appPidList - set -e - - # appJavaPid can be empty if pid search in startApplication() failed - if [ -n "$appJavaPid" ]; then - # only need to wait for the Java process - set +e - wait "$appJavaPid" - set -e - fi - fi -} diff --git a/jdk/test/sun/tools/common/CommonSetup.sh b/jdk/test/sun/tools/common/CommonSetup.sh deleted file mode 100644 index f4401a7f6f2..00000000000 --- a/jdk/test/sun/tools/common/CommonSetup.sh +++ /dev/null @@ -1,131 +0,0 @@ -#!/bin/sh - -# -# Copyright (c) 2005, 2012, 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. -# - - -# Common setup for tool tests and other tests that use jtools. -# Checks that TESTJAVA, TESTSRC, and TESTCLASSES environment variables are set. -# -# Creates the following constants for use by the caller: -# JAVA - java launcher -# JHAT - jhat utility -# JINFO - jinfo utility -# JMAP - jmap utility -# JPS - jps utility -# JSTACK - jstack utility -# JCMD - jcmd utility -# OS - operating system name -# PATTERN_EOL - grep or sed end-of-line pattern -# PATTERN_WS - grep or sed whitespace pattern -# PS - path separator (";" or ":") -# -# Sets the following variables: -# -# isCygwin - true if environment is Cygwin -# isMKS - true if environment is MKS -# isLinux - true if OS is Linux -# isSolaris - true if OS is Solaris -# isWindows - true if OS is Windows -# isMacos - true if OS is Macos X -# isAIX - true if OS is AIX - - -if [ -z "${TESTJAVA}" ]; then - echo "ERROR: TESTJAVA not set. Test cannot execute. Failed." - exit 1 -fi - -if [ -z "${TESTSRC}" ]; then - echo "ERROR: TESTSRC not set. Test cannot execute. Failed." - exit 1 -fi - -if [ -z "${TESTCLASSES}" ]; then - echo "ERROR: TESTCLASSES not set. Test cannot execute. Failed." - exit 1 -fi - -# only enable these after checking the expected incoming env variables -set -eu - -JAVA="${TESTJAVA}/bin/java" -JHAT="${TESTJAVA}/bin/jhat" -JINFO="${TESTJAVA}/bin/jinfo" -JMAP="${TESTJAVA}/bin/jmap" -JPS="${TESTJAVA}/bin/jps" -JSTACK="${TESTJAVA}/bin/jstack" -JCMD="${TESTJAVA}/bin/jcmd" - -isCygwin=false -isMKS=false -isLinux=false -isSolaris=false -isUnknownOS=false -isWindows=false -isMacos=false -isAIX=false - -OS=`uname -s` - -# start with some UNIX like defaults -PATTERN_EOL='$' -# blank and tab -PATTERN_WS='[ ]' -PS=":" - -case "$OS" in - CYGWIN* ) - OS="Windows" - PATTERN_EOL='[ ]*$' - # blank and tab - PATTERN_WS='[ \t]' - isCygwin=true - isWindows=true - ;; - Linux ) - OS="Linux" - isLinux=true - ;; - Darwin ) - OS="Mac OS X" - isMacos=true - ;; - SunOS ) - OS="Solaris" - isSolaris=true - ;; - AIX ) - OS="AIX" - isAIX=true - ;; - Windows* ) - OS="Windows" - PATTERN_EOL='[ ]*$' - PS=";" - isWindows=true - ;; - * ) - isUnknownOS=true - ;; -esac diff --git a/jdk/test/sun/tools/common/ShutdownSimpleApplication.java b/jdk/test/sun/tools/common/ShutdownSimpleApplication.java deleted file mode 100644 index 314bb579bad..00000000000 --- a/jdk/test/sun/tools/common/ShutdownSimpleApplication.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (c) 2005, 2010, 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. - */ - -/* - * Used to shutdown SimpleApplication (or a subclass). The argument to - * this class is the name of a file that contains the TCP port number - * on which SimpleApplication (or a subclass) is listening. - * - * Note: When this program returns, the SimpleApplication (or a subclass) - * may still be running because the application has not yet reached the - * shutdown check. - */ -import java.net.Socket; -import java.net.InetSocketAddress; -import java.io.File; -import java.io.FileInputStream; - -public class ShutdownSimpleApplication { - public static void main(String args[]) throws Exception { - - if (args.length != 1) { - throw new RuntimeException("Usage: ShutdownSimpleApplication" + - " port-file"); - } - - // read the (TCP) port number from the given file - - File f = new File(args[0]); - FileInputStream fis = new FileInputStream(f); - byte b[] = new byte[8]; - int n = fis.read(b); - if (n < 1) { - throw new RuntimeException("Empty port-file"); - } - fis.close(); - - String str = new String(b, 0, n, "UTF-8"); - System.out.println("INFO: Port number of SimpleApplication: " + str); - int port = Integer.parseInt(str); - - // Now connect to the port (which will shutdown application) - - System.out.println("INFO: Connecting to port " + port + - " to shutdown SimpleApplication ..."); - System.out.flush(); - - Socket s = new Socket(); - s.connect( new InetSocketAddress(port) ); - s.close(); - - System.out.println("INFO: done connecting to SimpleApplication."); - System.out.flush(); - - System.exit(0); - } -} diff --git a/jdk/test/sun/tools/common/SimpleApplication.java b/jdk/test/sun/tools/common/SimpleApplication.java deleted file mode 100644 index c7e6b0bdac4..00000000000 --- a/jdk/test/sun/tools/common/SimpleApplication.java +++ /dev/null @@ -1,120 +0,0 @@ -/* - * Copyright (c) 2005, 2010, 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. - */ - -/* - * A simple application used by unit tests. The first argument to this - * class is the name of a file to which a TCP port number can be written. - * - * By default, this class does nothing other than bind to a TCP port, - * write the TCP port number to a file, and wait for an incoming connection - * in order to complete the application shutdown protocol. - */ -import java.net.Socket; -import java.net.ServerSocket; -import java.io.File; -import java.io.FileOutputStream; - -public class SimpleApplication { - private static SimpleApplication myApp; // simple app or a subclass - private static String myAppName; // simple app name - private static int myPort; // coordination port # - private static ServerSocket mySS; // coordination socket - - // protected so a subclass can extend it; not public so creation is - // limited. - protected SimpleApplication() { - // save simple app (or subclass) name for messages - myAppName = getClass().getName(); - } - - // return the simple application (or a subclass) - final public static SimpleApplication getMyApp() { - return myApp; - } - - // set the simple application (for use by a subclass) - final public static void setMyApp(SimpleApplication _myApp) { - myApp = _myApp; - } - - // execute the application finish protocol - final public void doMyAppFinish(String[] args) throws Exception { - System.out.println("INFO: " + myAppName + " is waiting on port: " + - myPort); - System.out.flush(); - - // wait for test harness to connect - Socket s = mySS.accept(); - s.close(); - mySS.close(); - - System.out.println("INFO: " + myAppName + " is shutting down."); - System.out.flush(); - } - - // execute the application start protocol - final public void doMyAppStart(String[] args) throws Exception { - if (args.length < 1) { - throw new RuntimeException("Usage: " + myAppName + - " port-file [arg(s)]"); - } - - // bind to a random port - mySS = new ServerSocket(0); - myPort = mySS.getLocalPort(); - - // Write the port number to the given file - File f = new File(args[0]); - FileOutputStream fos = new FileOutputStream(f); - fos.write( Integer.toString(myPort).getBytes("UTF-8") ); - fos.close(); - - System.out.println("INFO: " + myAppName + " created socket on port: " + - myPort); - System.out.flush(); - } - - // execute the app work (subclass can override this) - public void doMyAppWork(String[] args) throws Exception { - } - - public static void main(String[] args) throws Exception { - if (myApp == null) { - // create myApp since a subclass hasn't done so - myApp = new SimpleApplication(); - } - - myApp.doMyAppStart(args); // do the app start protocol - - System.out.println("INFO: " + myAppName + " is calling doMyAppWork()"); - System.out.flush(); - myApp.doMyAppWork(args); // do the app work - System.out.println("INFO: " + myAppName + " returned from" + - " doMyAppWork()"); - System.out.flush(); - - myApp.doMyAppFinish(args); // do the app finish protocol - - System.exit(0); - } -} diff --git a/jdk/test/sun/tools/common/SleeperApplication.java b/jdk/test/sun/tools/common/SleeperApplication.java deleted file mode 100644 index b96d9b07ac3..00000000000 --- a/jdk/test/sun/tools/common/SleeperApplication.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (c) 2010, 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. - */ - -/* - * An example subclass of SimpleApplication that illustrates how to - * override the doMyAppWork() method. - */ - -public class SleeperApplication extends SimpleApplication { - public static int DEFAULT_SLEEP_TIME = 60; // time is in seconds - - // execute the sleeper app work - public void doMyAppWork(String[] args) throws Exception { - int sleep_time = DEFAULT_SLEEP_TIME; - - // args[0] is the port-file - if (args.length < 2) { - System.out.println("INFO: using default sleep time of " - + sleep_time + " seconds."); - } else { - try { - sleep_time = Integer.parseInt(args[1]); - } catch (NumberFormatException nfe) { - throw new RuntimeException("Error: '" + args[1] + - "': is not a valid seconds value."); - } - } - - Thread.sleep(sleep_time * 1000); // our "work" is to sleep - } - - public static void main(String[] args) throws Exception { - SleeperApplication myApp = new SleeperApplication(); - - SimpleApplication.setMyApp(myApp); - - SimpleApplication.main(args); - } -} diff --git a/jdk/test/sun/tools/jhat/HatHeapDump1Test.java b/jdk/test/sun/tools/jhat/HatHeapDump1Test.java deleted file mode 100644 index eab353e7249..00000000000 --- a/jdk/test/sun/tools/jhat/HatHeapDump1Test.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright (c) 2005, 2014, 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. - */ - -import java.io.File; -import java.util.Arrays; - -import jdk.testlibrary.Asserts; -import jdk.testlibrary.JDKToolLauncher; -import jdk.testlibrary.OutputAnalyzer; -import jdk.testlibrary.ProcessTools; - -/* @test - * @bug 5102009 - * @summary Sanity test of jhat functionality - * @library /lib/testlibrary - * @build jdk.testlibarary.* - * @compile -g HelloWorld.java - * @run main HatHeapDump1Test - */ -public class HatHeapDump1Test { - - private static final String TEST_CLASSES = System.getProperty("test.classes", "."); - - public static void main(String args[]) throws Exception { - String className = "HelloWorld"; - File dumpFile = new File(className + ".hdump"); - - // Generate a heap dump - ProcessBuilder processBuilder = ProcessTools.createJavaProcessBuilder("-cp", - TEST_CLASSES, - "-Xcheck:jni", - "-Xverify:all", - "-agentlib:hprof=heap=dump,format=b,file=" + dumpFile.getAbsolutePath(), - className); - OutputAnalyzer output = ProcessTools.executeProcess(processBuilder); - System.out.println(output.getOutput()); - output.shouldHaveExitValue(0); - output.shouldContain("Dumping Java heap ... done"); - Asserts.assertTrue(dumpFile.exists() && dumpFile.isFile(), "Invalid dump file " + dumpFile.getAbsolutePath()); - - // Run jhat to analyze the heap dump - output = jhat("-debug", "2", dumpFile.getAbsolutePath()); - output.shouldHaveExitValue(0); - output.shouldContain("Snapshot resolved"); - output.shouldContain("-debug 2 was used"); - output.shouldNotContain("ERROR"); - - dumpFile.delete(); - } - - private static OutputAnalyzer jhat(String... toolArgs) throws Exception { - JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK("jhat"); - if (toolArgs != null) { - for (String toolArg : toolArgs) { - launcher.addToolArg(toolArg); - } - } - - ProcessBuilder processBuilder = new ProcessBuilder(); - processBuilder.command(launcher.getCommand()); - System.out.println(Arrays.toString(processBuilder.command().toArray()).replace(",", "")); - OutputAnalyzer output = ProcessTools.executeProcess(processBuilder); - System.out.println(output.getOutput()); - - return output; - } - -} diff --git a/jdk/test/sun/tools/jhat/HelloWorld.java b/jdk/test/sun/tools/jhat/HelloWorld.java deleted file mode 100644 index f4d30157b8c..00000000000 --- a/jdk/test/sun/tools/jhat/HelloWorld.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2005, 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. - */ - - -/* - * - * Sample target application. - * - */ - -public class HelloWorld { - public static void main(String args[]) { - - /* Use a generic type */ - java.util.List l = new java.util.ArrayList(); - String.format("%s", ""); - - /* Just some code with branches */ - try { - if ( args.length == 0 ) { - System.out.println("No arguments passed in"); - } else { - System.out.println("Some arguments passed in"); - } - } catch ( Throwable e ) { - System.out.println("ERROR: System.out.println() did a throw"); - } finally { - System.out.println("Hello, world!"); - } - } -} diff --git a/jdk/test/sun/tools/jhat/ParseTest.sh b/jdk/test/sun/tools/jhat/ParseTest.sh deleted file mode 100644 index 9bc9294eb71..00000000000 --- a/jdk/test/sun/tools/jhat/ParseTest.sh +++ /dev/null @@ -1,69 +0,0 @@ -#!/bin/sh - -# -# Copyright (c) 2006, 2010, 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. -# - - -# @test -# @summary Testing jhat parsing against pre-created dump files. -# see also: README.TXT - -# @library ../common -# @run shell ParseTest.sh - -. ${TESTSRC}/../common/CommonSetup.sh - -# all return statuses are checked in this test -set +e - -failed=0 - -DUMPFILE="minimal.bin" - -${JHAT} -parseonly true ${TESTSRC}/${DUMPFILE} -if [ $? != 0 ]; then failed=1; fi - -DUMPFILE="jmap.bin" - -${JHAT} -parseonly true ${TESTSRC}/${DUMPFILE} -if [ $? != 0 ]; then failed=1; fi - -DUMPFILE="hprof.bin" - -${JHAT} -parseonly true ${TESTSRC}/${DUMPFILE} -if [ $? != 0 ]; then failed=1; fi - -# try something that is not heapdump and expect to fail! -DUMPFILE="ParseTest.sh" - -${JHAT} -parseonly true ${TESTSRC}/${DUMPFILE} -if [ $? = 0 ]; then failed=1; fi - -# try something that does not exist and expect to fail! -DUMPFILE="FileThatDoesNotExist" - -${JHAT} -parseonly true ${TESTSRC}/${DUMPFILE} -if [ $? = 0 ]; then failed=1; fi - -exit $failed - diff --git a/jdk/test/sun/tools/jhat/README.TXT b/jdk/test/sun/tools/jhat/README.TXT deleted file mode 100644 index ea852e32a80..00000000000 --- a/jdk/test/sun/tools/jhat/README.TXT +++ /dev/null @@ -1,16 +0,0 @@ -# - -jhat heap dump parsing tests: - -There are three hprof binary format dump files in this directory. -These dumps were created by jmap and hprof profiler against a -simple infinite looping Java program. - -1. minimal.bin - minimal dump that has nothing! - not even java.lang.Class! - - This was created by java -Xrunhprof:format=b,heap=sites MainClass. - -2. jmap.bin - created by jmap -dump option - -3. hprof.bin - created by java -Xrunhprof:heap=all,format=b MainClass - -We can run jhat -parseonly true against these dumps.