8155091: Remove SA related functions from tmtools
Summary: Remove options that enables support for non-cooperative mode
Reviewed-by: alanb, mchung, sla
--- a/hotspot/src/jdk.hotspot.agent/share/classes/module-info.java Mon May 09 17:36:13 2016 +0000
+++ b/hotspot/src/jdk.hotspot.agent/share/classes/module-info.java Mon May 09 23:41:41 2016 +0300
@@ -28,7 +28,6 @@
requires java.desktop;
requires java.rmi;
requires java.scripting;
- requires jdk.jcmd;
requires jdk.jdi;
// RMI needs to serialize types in this package
@@ -37,13 +36,4 @@
provides com.sun.jdi.connect.Connector with sun.jvm.hotspot.jdi.SADebugServerAttachingConnector;
provides com.sun.jdi.connect.Connector with sun.jvm.hotspot.jdi.SAPIDAttachingConnector;
- provides jdk.internal.vm.agent.spi.ToolProvider with sun.jvm.hotspot.tools.JStack;
- provides jdk.internal.vm.agent.spi.ToolProvider with sun.jvm.hotspot.tools.JInfo;
- provides jdk.internal.vm.agent.spi.ToolProvider with sun.jvm.hotspot.tools.ClassLoaderStats;
- provides jdk.internal.vm.agent.spi.ToolProvider with sun.jvm.hotspot.tools.FinalizerInfo;
- provides jdk.internal.vm.agent.spi.ToolProvider with sun.jvm.hotspot.tools.HeapDumper;
- provides jdk.internal.vm.agent.spi.ToolProvider with sun.jvm.hotspot.tools.HeapSummary;
- provides jdk.internal.vm.agent.spi.ToolProvider with sun.jvm.hotspot.tools.ObjectHistogram;
- provides jdk.internal.vm.agent.spi.ToolProvider with sun.jvm.hotspot.tools.PMap;
}
-
--- a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/ClassLoaderStats.java Mon May 09 17:36:13 2016 +0000
+++ b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/ClassLoaderStats.java Mon May 09 23:41:41 2016 +0300
@@ -32,13 +32,12 @@
import sun.jvm.hotspot.oops.*;
import sun.jvm.hotspot.runtime.*;
import sun.jvm.hotspot.utilities.*;
-import jdk.internal.vm.agent.spi.ToolProvider;
/**
A command line tool to print class loader statistics.
*/
-public class ClassLoaderStats extends Tool implements ToolProvider {
+public class ClassLoaderStats extends Tool {
boolean verbose = true;
public ClassLoaderStats() {
@@ -54,11 +53,6 @@
return "classLoaderStats";
}
- @Override
- public void run(String... arguments) {
- execute(arguments);
- }
-
public static void main(String[] args) {
ClassLoaderStats cls = new ClassLoaderStats();
cls.execute(args);
--- a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/FinalizerInfo.java Mon May 09 17:36:13 2016 +0000
+++ b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/FinalizerInfo.java Mon May 09 23:41:41 2016 +0300
@@ -28,7 +28,6 @@
import sun.jvm.hotspot.oops.*;
import sun.jvm.hotspot.utilities.SystemDictionaryHelper;
-import jdk.internal.vm.agent.spi.ToolProvider;
import java.util.ArrayList;
import java.util.Collections;
@@ -39,7 +38,7 @@
* Iterates over the queue of object pending finalization and prints a
* summary of these objects in the form of a histogram.
*/
-public class FinalizerInfo extends Tool implements ToolProvider {
+public class FinalizerInfo extends Tool {
public FinalizerInfo() {
super();
@@ -54,11 +53,6 @@
return "finalizerInfo";
}
- @Override
- public void run(String... arguments) {
- execute(arguments);
- }
-
public static void main(String[] args) {
FinalizerInfo finfo = new FinalizerInfo();
finfo.execute(args);
--- a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/HeapDumper.java Mon May 09 17:36:13 2016 +0000
+++ b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/HeapDumper.java Mon May 09 23:41:41 2016 +0300
@@ -26,7 +26,6 @@
import sun.jvm.hotspot.utilities.HeapHprofBinWriter;
import sun.jvm.hotspot.debugger.JVMDebugger;
-import jdk.internal.vm.agent.spi.ToolProvider;
import java.io.IOException;
@@ -35,7 +34,7 @@
* process/core as a HPROF binary file. It can also be used as a standalone
* tool if required.
*/
-public class HeapDumper extends Tool implements ToolProvider {
+public class HeapDumper extends Tool {
private static String DEFAULT_DUMP_FILE = "heap.bin";
@@ -81,11 +80,10 @@
// HeapDumper -f <file> <args...>
public static void main(String args[]) {
HeapDumper dumper = new HeapDumper();
- dumper.run(args);
+ dumper.runWithArgs(args);
}
- @Override
- public void run(String... args) {
+ public void runWithArgs(String... args) {
if (args.length > 2) {
if (args[0].equals("-f")) {
this.dumpFile = args[1];
--- a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/HeapSummary.java Mon May 09 17:36:13 2016 +0000
+++ b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/HeapSummary.java Mon May 09 23:41:41 2016 +0300
@@ -33,9 +33,8 @@
import sun.jvm.hotspot.memory.*;
import sun.jvm.hotspot.oops.*;
import sun.jvm.hotspot.runtime.*;
-import jdk.internal.vm.agent.spi.ToolProvider;
-public class HeapSummary extends Tool implements ToolProvider {
+public class HeapSummary extends Tool {
public HeapSummary() {
super();
@@ -55,11 +54,6 @@
return "heapSummary";
}
- @Override
- public void run(String... arguments) {
- execute(arguments);
- }
-
public void run() {
CollectedHeap heap = VM.getVM().getUniverse().heap();
VM.Flag[] flags = VM.getVM().getCommandLineFlags();
--- a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/JInfo.java Mon May 09 17:36:13 2016 +0000
+++ b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/JInfo.java Mon May 09 23:41:41 2016 +0300
@@ -27,9 +27,8 @@
import sun.jvm.hotspot.debugger.JVMDebugger;
import sun.jvm.hotspot.runtime.Arguments;
import sun.jvm.hotspot.runtime.VM;
-import jdk.internal.vm.agent.spi.ToolProvider;
-public class JInfo extends Tool implements ToolProvider {
+public class JInfo extends Tool {
public JInfo() {
super();
}
@@ -46,6 +45,7 @@
return false;
}
+ @Override
public String getName() {
return "jinfo";
}
@@ -95,8 +95,7 @@
tool.run();
}
- @Override
- public void run(String... args) {
+ public void runWithArgs(String... args) {
int mode = -1;
switch (args.length) {
case 1:
@@ -142,7 +141,7 @@
public static void main(String[] args) {
JInfo jinfo = new JInfo();
- jinfo.run(args);
+ jinfo.runWithArgs(args);
}
private void printVMFlags() {
--- a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/JStack.java Mon May 09 17:36:13 2016 +0000
+++ b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/JStack.java Mon May 09 23:41:41 2016 +0300
@@ -25,9 +25,8 @@
package sun.jvm.hotspot.tools;
import sun.jvm.hotspot.debugger.JVMDebugger;
-import jdk.internal.vm.agent.spi.ToolProvider;
-public class JStack extends Tool implements ToolProvider {
+public class JStack extends Tool {
public JStack(boolean mixedMode, boolean concurrentLocks) {
this.mixedMode = mixedMode;
this.concurrentLocks = concurrentLocks;
@@ -45,6 +44,7 @@
return false;
}
+ @Override
public String getName() {
return "jstack";
}
@@ -67,8 +67,7 @@
tool.run();
}
- @Override
- public void run(String... args) {
+ public void runWithArgs(String... args) {
int used = 0;
for (int i = 0; i < args.length; i++) {
if (args[i].equals("-m")) {
@@ -93,7 +92,7 @@
public static void main(String[] args) {
JStack jstack = new JStack();
- jstack.run(args);
+ jstack.runWithArgs(args);
}
private boolean mixedMode;
--- a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/ObjectHistogram.java Mon May 09 17:36:13 2016 +0000
+++ b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/ObjectHistogram.java Mon May 09 23:41:41 2016 +0300
@@ -27,52 +27,46 @@
import sun.jvm.hotspot.debugger.*;
import sun.jvm.hotspot.oops.*;
import sun.jvm.hotspot.runtime.*;
-import jdk.internal.vm.agent.spi.ToolProvider;
import java.io.PrintStream;
/** A sample tool which uses the Serviceability Agent's APIs to obtain
an object histogram from a remote or crashed VM. */
-public class ObjectHistogram extends Tool implements ToolProvider {
+public class ObjectHistogram extends Tool {
public ObjectHistogram() {
- super();
+ super();
}
public ObjectHistogram(JVMDebugger d) {
- super(d);
+ super(d);
}
@Override
public String getName() {
- return "objectHistogram";
+ return "objectHistogram";
}
- @Override
- public void run(String... arguments) {
- execute(arguments);
+ public void run() {
+ run(System.out, System.err);
}
- public void run() {
- run(System.out, System.err);
- }
-
- public void run(PrintStream out, PrintStream err) {
- // Ready to go with the database...
- ObjectHeap heap = VM.getVM().getObjectHeap();
- sun.jvm.hotspot.oops.ObjectHistogram histogram =
+ public void run(PrintStream out, PrintStream err) {
+ // Ready to go with the database...
+ ObjectHeap heap = VM.getVM().getObjectHeap();
+ sun.jvm.hotspot.oops.ObjectHistogram histogram =
new sun.jvm.hotspot.oops.ObjectHistogram();
- err.println("Iterating over heap. This may take a while...");
- long startTime = System.currentTimeMillis();
- heap.iterate(histogram);
- long endTime = System.currentTimeMillis();
- histogram.printOn(out);
- float secs = (float) (endTime - startTime) / 1000.0f;
- err.println("Heap traversal took " + secs + " seconds.");
- }
+ err.println("Iterating over heap. This may take a while...");
+ long startTime = System.currentTimeMillis();
+ heap.iterate(histogram);
+ long endTime = System.currentTimeMillis();
+ histogram.printOn(out);
+ float secs = (float) (endTime - startTime) / 1000.0f;
+ err.println("Heap traversal took " + secs + " seconds.");
+ }
- public static void main(String[] args) {
- ObjectHistogram oh = new ObjectHistogram();
- oh.execute(args);
- }
+ public static void main(String[] args) {
+ ObjectHistogram oh = new ObjectHistogram();
+ oh.execute(args);
+ }
}
--- a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/PMap.java Mon May 09 17:36:13 2016 +0000
+++ b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/PMap.java Mon May 09 23:41:41 2016 +0300
@@ -28,9 +28,8 @@
import java.util.*;
import sun.jvm.hotspot.debugger.*;
import sun.jvm.hotspot.debugger.cdbg.*;
-import jdk.internal.vm.agent.spi.ToolProvider;
-public class PMap extends Tool implements ToolProvider {
+public class PMap extends Tool {
public PMap() {
super();
@@ -45,11 +44,6 @@
return "pmap";
}
- @Override
- public void run(String... arguments) {
- execute(arguments);
- }
-
public void run() {
run(System.out);
}
--- a/hotspot/test/serviceability/sa/jmap-hashcode/Test8028623.java Mon May 09 17:36:13 2016 +0000
+++ b/hotspot/test/serviceability/sa/jmap-hashcode/Test8028623.java Mon May 09 23:41:41 2016 +0300
@@ -44,7 +44,7 @@
public class Test8028623 {
public static int \u00CB = 1;
- public static String dumpFile = "heap.out";
+ public static String dumpFile = "heap.bin";
public static void main (String[] args) {
@@ -56,9 +56,10 @@
return;
}
long pid = ProcessTools.getProcessId();
- JDKToolLauncher jmap = JDKToolLauncher.create("jmap")
- .addToolArg("-F")
- .addToolArg("-dump:live,format=b,file=" + dumpFile)
+ JDKToolLauncher jmap = JDKToolLauncher.create("jhsdb")
+ .addToolArg("jmap")
+ .addToolArg("--binaryheap")
+ .addToolArg("--pid")
.addToolArg(Long.toString(pid));
ProcessBuilder pb = new ProcessBuilder(jmap.getCommand());
OutputBuffer output = ProcessTools.getOutput(pb);
--- a/hotspot/test/serviceability/sa/jmap-hprof/JMapHProfLargeHeapTest.java Mon May 09 17:36:13 2016 +0000
+++ b/hotspot/test/serviceability/sa/jmap-hprof/JMapHProfLargeHeapTest.java Mon May 09 23:41:41 2016 +0300
@@ -53,33 +53,22 @@
*/
public class JMapHProfLargeHeapTest {
- private static final String HEAP_DUMP_FILE_NAME = "heap.hprof";
+ private static final String HEAP_DUMP_FILE_NAME = "heap.bin";
+ private static final String HPROF_HEADER_1_0_1 = "JAVA PROFILE 1.0.1";
private static final String HPROF_HEADER_1_0_2 = "JAVA PROFILE 1.0.2";
private static final long M = 1024L;
private static final long G = 1024L * M;
public static void main(String[] args) throws Exception {
- // If we are on MacOSX, test if JMap tool is signed, otherwise return
- // since test will fail with privilege error.
- if (Platform.isOSX()) {
- String jmapToolPath = JDKToolFinder.getTestJDKTool("jmap");
- ProcessBuilder codesignProcessBuilder = new ProcessBuilder(
- "codesign", "-v", jmapToolPath);
- Process codesignProcess = codesignProcessBuilder.start();
- OutputAnalyzer analyser = new OutputAnalyzer(codesignProcess);
- try {
- analyser.shouldNotContain("code object is not signed at all");
- System.out.println("Signed jmap found at: " + jmapToolPath);
- } catch (Exception e) {
- // Abort since we can't know if the test will work
- System.out
- .println("Test aborted since we are on MacOSX and the jmap tool is not signed.");
- return;
- }
+ if (!Platform.shouldSAAttach()) {
+ System.out.println("SA attach not expected to work - test skipped.");
+ return;
}
// All heap dumps should create 1.0.2 file format
- testHProfFileFormat("-Xmx1g", 22 * M, HPROF_HEADER_1_0_2);
+ // Hotspot internal heapdumper always use HPROF_HEADER_1_0_2 format,
+ // but SA heapdumper still use HPROF_HEADER_1_0_1 for small heaps
+ testHProfFileFormat("-Xmx1g", 22 * M, HPROF_HEADER_1_0_1);
/**
* This test was deliberately commented out since the test system lacks
@@ -110,9 +99,10 @@
System.out.println("Extracted pid: " + pid);
JDKToolLauncher jMapLauncher = JDKToolLauncher
- .createUsingTestJDK("jmap");
- jMapLauncher.addToolArg("-dump:format=b,file=" + pid + "-"
- + HEAP_DUMP_FILE_NAME);
+ .createUsingTestJDK("jhsdb");
+ jMapLauncher.addToolArg("jmap");
+ jMapLauncher.addToolArg("--binaryheap");
+ jMapLauncher.addToolArg("--pid");
jMapLauncher.addToolArg(String.valueOf(pid));
ProcessBuilder jMapProcessBuilder = new ProcessBuilder(
@@ -123,12 +113,11 @@
Process jMapProcess = jMapProcessBuilder.start();
OutputAnalyzer analyzer = new OutputAnalyzer(jMapProcess);
analyzer.shouldHaveExitValue(0);
- analyzer.shouldContain(pid + "-" + HEAP_DUMP_FILE_NAME);
- analyzer.shouldContain("Heap dump file created");
+ analyzer.shouldContain(HEAP_DUMP_FILE_NAME);
largeHeapProc.getOutputStream().write('\n');
- File dumpFile = new File(pid + "-" + HEAP_DUMP_FILE_NAME);
+ File dumpFile = new File(HEAP_DUMP_FILE_NAME);
Asserts.assertTrue(dumpFile.exists(), "Heap dump file not found.");
try (Reader reader = new BufferedReader(new FileReader(dumpFile))) {