mirror of
https://github.com/openjdk/jdk.git
synced 2026-02-04 07:28:22 +00:00
8071687: AIX port of "8039173: Propagate errors from Diagnostic Commands as exceptions in the attach framework"
Reviewed-by: sla
This commit is contained in:
parent
ca08065c34
commit
40728fc162
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright 2013 SAP AG. All rights reserved.
|
||||
* Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright 2015 SAP AG. 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
|
||||
@ -25,9 +25,11 @@
|
||||
*/
|
||||
package sun.tools.attach;
|
||||
|
||||
import com.sun.tools.attach.AttachOperationFailedException;
|
||||
import com.sun.tools.attach.AgentLoadException;
|
||||
import com.sun.tools.attach.AttachNotSupportedException;
|
||||
import com.sun.tools.attach.spi.AttachProvider;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.File;
|
||||
@ -189,6 +191,8 @@ public class VirtualMachineImpl extends HotSpotVirtualMachine {
|
||||
}
|
||||
|
||||
if (completionStatus != 0) {
|
||||
// read from the stream and use that as the error message
|
||||
String message = readErrorMessage(sis);
|
||||
sis.close();
|
||||
|
||||
// In the event of a protocol mismatch then the target VM
|
||||
@ -203,7 +207,11 @@ public class VirtualMachineImpl extends HotSpotVirtualMachine {
|
||||
if (cmd.equals("load")) {
|
||||
throw new AgentLoadException("Failed to load agent library");
|
||||
} else {
|
||||
throw new IOException("Command failed in target VM");
|
||||
if (message == null) {
|
||||
throw new AttachOperationFailedException("Command failed in target VM");
|
||||
} else {
|
||||
throw new AttachOperationFailedException(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright (c) 2008, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright 2014 SAP AG. All rights reserved.
|
||||
* Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright 2015 SAP AG. 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
|
||||
@ -238,14 +238,14 @@ JNIEXPORT jint JNICALL Java_sun_tools_attach_VirtualMachineImpl_read
|
||||
len = remaining;
|
||||
}
|
||||
|
||||
RESTARTABLE(read(fd, buf+off, len), n);
|
||||
RESTARTABLE(read(fd, buf, len), n);
|
||||
if (n == -1) {
|
||||
JNU_ThrowIOExceptionWithLastError(env, "read");
|
||||
} else {
|
||||
if (n == 0) {
|
||||
n = -1; // EOF
|
||||
} else {
|
||||
(*env)->SetByteArrayRegion(env, ba, off, (jint)n, (jbyte *)(buf+off));
|
||||
(*env)->SetByteArrayRegion(env, ba, off, (jint)n, (jbyte *)(buf));
|
||||
}
|
||||
}
|
||||
return n;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user