8219721: jcmd from earlier release will hang attaching to VM with JDK-8215622 applied
Fix compatibility issue caused by jmap update of 8215622 Reviewed-by: dholmes, ysuenaga, phh, sspitsyn
This commit is contained in:
parent
cf09431450
commit
144d81caf6
@ -257,13 +257,22 @@ jint dump_heap(AttachOperation* op, outputStream* out) {
|
||||
// See also: ClassHistogramDCmd class
|
||||
//
|
||||
// Input arguments :-
|
||||
// arg0: Name of the dump file or NULL
|
||||
// arg1: "-live" or "-all"
|
||||
// arg0: "-live" or "-all"
|
||||
// arg1: Name of the dump file or NULL
|
||||
static jint heap_inspection(AttachOperation* op, outputStream* out) {
|
||||
bool live_objects_only = true; // default is true to retain the behavior before this change is made
|
||||
outputStream* os = out; // if path not specified or path is NULL, use out
|
||||
fileStream* fs = NULL;
|
||||
const char* path = op->arg(0);
|
||||
const char* arg0 = op->arg(0);
|
||||
if (arg0 != NULL && (strlen(arg0) > 0)) {
|
||||
if (strcmp(arg0, "-all") != 0 && strcmp(arg0, "-live") != 0) {
|
||||
out->print_cr("Invalid argument to inspectheap operation: %s", arg0);
|
||||
return JNI_ERR;
|
||||
}
|
||||
live_objects_only = strcmp(arg0, "-live") == 0;
|
||||
}
|
||||
|
||||
const char* path = op->arg(1);
|
||||
if (path != NULL) {
|
||||
if (path[0] == '\0') {
|
||||
out->print_cr("No dump file specified");
|
||||
@ -277,14 +286,7 @@ static jint heap_inspection(AttachOperation* op, outputStream* out) {
|
||||
os = fs;
|
||||
}
|
||||
}
|
||||
const char* arg1 = op->arg(1);
|
||||
if (arg1 != NULL && (strlen(arg1) > 0)) {
|
||||
if (strcmp(arg1, "-all") != 0 && strcmp(arg1, "-live") != 0) {
|
||||
out->print_cr("Invalid argument to inspectheap operation: %s", arg1);
|
||||
return JNI_ERR;
|
||||
}
|
||||
live_objects_only = strcmp(arg1, "-live") == 0;
|
||||
}
|
||||
|
||||
VM_GC_HeapInspection heapop(os, live_objects_only /* request full gc */);
|
||||
VMThread::execute(&heapop);
|
||||
if (os != NULL && os != out) {
|
||||
|
@ -106,7 +106,7 @@ class AttachOperation: public CHeapObj<mtInternal> {
|
||||
enum {
|
||||
name_length_max = 16, // maximum length of name
|
||||
arg_length_max = 1024, // maximum length of argument
|
||||
arg_count_max = 4 // maximum number of arguments
|
||||
arg_count_max = 3 // maximum number of arguments
|
||||
};
|
||||
|
||||
// name of special operation that can be enqueued when all
|
||||
|
@ -138,7 +138,7 @@ public class VirtualMachineImpl extends HotSpotVirtualMachine {
|
||||
* Execute the given command in the target VM.
|
||||
*/
|
||||
InputStream execute(String cmd, Object ... args) throws AgentLoadException, IOException {
|
||||
assert args.length <= 4; // includes null
|
||||
assert args.length <= 3; // includes null
|
||||
|
||||
// did we detach?
|
||||
synchronized (this) {
|
||||
@ -166,7 +166,7 @@ public class VirtualMachineImpl extends HotSpotVirtualMachine {
|
||||
writeString(s, PROTOCOL_VERSION);
|
||||
writeString(s, cmd);
|
||||
|
||||
for (int i = 0; i < 4; i++) {
|
||||
for (int i = 0; i < 3; i++) {
|
||||
if (i < args.length && args[i] != null) {
|
||||
writeString(s, (String)args[i]);
|
||||
} else {
|
||||
|
@ -143,7 +143,7 @@ public class VirtualMachineImpl extends HotSpotVirtualMachine {
|
||||
* Execute the given command in the target VM.
|
||||
*/
|
||||
InputStream execute(String cmd, Object ... args) throws AgentLoadException, IOException {
|
||||
assert args.length <= 4; // includes null
|
||||
assert args.length <= 3; // includes null
|
||||
|
||||
// did we detach?
|
||||
synchronized (this) {
|
||||
@ -171,7 +171,7 @@ public class VirtualMachineImpl extends HotSpotVirtualMachine {
|
||||
writeString(s, PROTOCOL_VERSION);
|
||||
writeString(s, cmd);
|
||||
|
||||
for (int i = 0; i < 4; i++) {
|
||||
for (int i = 0; i < 3; i++) {
|
||||
if (i < args.length && args[i] != null) {
|
||||
writeString(s, (String)args[i]);
|
||||
} else {
|
||||
|
@ -139,7 +139,7 @@ public class VirtualMachineImpl extends HotSpotVirtualMachine {
|
||||
* Execute the given command in the target VM.
|
||||
*/
|
||||
InputStream execute(String cmd, Object ... args) throws AgentLoadException, IOException {
|
||||
assert args.length <= 4; // includes null
|
||||
assert args.length <= 3; // includes null
|
||||
|
||||
// did we detach?
|
||||
synchronized (this) {
|
||||
@ -167,7 +167,7 @@ public class VirtualMachineImpl extends HotSpotVirtualMachine {
|
||||
writeString(s, PROTOCOL_VERSION);
|
||||
writeString(s, cmd);
|
||||
|
||||
for (int i = 0; i < 4; i++) {
|
||||
for (int i = 0; i < 3; i++) {
|
||||
if (i < args.length && args[i] != null) {
|
||||
writeString(s, (String)args[i]);
|
||||
} else {
|
||||
|
@ -126,7 +126,7 @@ public class VirtualMachineImpl extends HotSpotVirtualMachine {
|
||||
* Execute the given command in the target VM.
|
||||
*/
|
||||
InputStream execute(String cmd, Object ... args) throws AgentLoadException, IOException {
|
||||
assert args.length <= 4; // includes null
|
||||
assert args.length <= 3; // includes null
|
||||
|
||||
// first check that we are still attached
|
||||
int door;
|
||||
|
@ -77,7 +77,7 @@ public class VirtualMachineImpl extends HotSpotVirtualMachine {
|
||||
InputStream execute(String cmd, Object ... args)
|
||||
throws AgentLoadException, IOException
|
||||
{
|
||||
assert args.length <= 4; // includes null
|
||||
assert args.length <= 3; // includes null
|
||||
|
||||
// create a pipe using a random name
|
||||
Random rnd = new Random();
|
||||
|
@ -190,7 +190,7 @@ public class JMap {
|
||||
System.out.flush();
|
||||
|
||||
// inspectHeap is not the same as jcmd GC.class_histogram
|
||||
executeCommandForPid(pid, "inspectheap", filename, liveopt);
|
||||
executeCommandForPid(pid, "inspectheap", liveopt, filename);
|
||||
}
|
||||
|
||||
private static void dump(String pid, String options)
|
||||
|
@ -123,7 +123,7 @@ public class TestLoggerWeakRefLeak {
|
||||
}
|
||||
|
||||
/**
|
||||
* 'vm.heapHisto("", "-live")' will request a full GC
|
||||
* 'vm.heapHisto("-live")' will request a full GC
|
||||
*/
|
||||
private static int getInstanceCountFromHeapHisto() throws AttachNotSupportedException, Exception {
|
||||
int instanceCount = 0;
|
||||
@ -131,7 +131,7 @@ public class TestLoggerWeakRefLeak {
|
||||
HotSpotVirtualMachine vm = (HotSpotVirtualMachine) VirtualMachine
|
||||
.attach(Long.toString(ProcessTools.getProcessId()));
|
||||
try {
|
||||
try (InputStream heapHistoStream = vm.heapHisto("", "-live");
|
||||
try (InputStream heapHistoStream = vm.heapHisto("-live");
|
||||
BufferedReader in = new BufferedReader(new InputStreamReader(heapHistoStream))) {
|
||||
String inputLine;
|
||||
while ((inputLine = in.readLine()) != null) {
|
||||
|
Loading…
Reference in New Issue
Block a user