提交 69619abc 编写于 作者: S simonis

8071687: AIX port of "8039173: Propagate errors from Diagnostic Commands as...

8071687: AIX port of "8039173: Propagate errors from Diagnostic Commands as exceptions in the attach framework"
Reviewed-by: sla
上级 16ee95b0
/* /*
* Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright 2013 SAP AG. All rights reserved. * Copyright 2015 SAP AG. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -25,14 +25,14 @@ ...@@ -25,14 +25,14 @@
*/ */
package sun.tools.attach; package sun.tools.attach;
import com.sun.tools.attach.VirtualMachine; import com.sun.tools.attach.AttachOperationFailedException;
import com.sun.tools.attach.AgentLoadException; import com.sun.tools.attach.AgentLoadException;
import com.sun.tools.attach.AttachNotSupportedException; import com.sun.tools.attach.AttachNotSupportedException;
import com.sun.tools.attach.spi.AttachProvider; import com.sun.tools.attach.spi.AttachProvider;
import java.io.InputStream; import java.io.InputStream;
import java.io.IOException; import java.io.IOException;
import java.io.File; import java.io.File;
import java.util.Properties;
// Based on 'LinuxVirtualMachine.java'. All occurrences of the string // Based on 'LinuxVirtualMachine.java'. All occurrences of the string
// "Linux" have been textually replaced by "Aix" to avoid confusion. // "Linux" have been textually replaced by "Aix" to avoid confusion.
...@@ -192,6 +192,8 @@ public class AixVirtualMachine extends HotSpotVirtualMachine { ...@@ -192,6 +192,8 @@ public class AixVirtualMachine extends HotSpotVirtualMachine {
} }
if (completionStatus != 0) { if (completionStatus != 0) {
// read from the stream and use that as the error message
String message = readErrorMessage(sis);
sis.close(); sis.close();
// In the event of a protocol mismatch then the target VM // In the event of a protocol mismatch then the target VM
...@@ -206,7 +208,11 @@ public class AixVirtualMachine extends HotSpotVirtualMachine { ...@@ -206,7 +208,11 @@ public class AixVirtualMachine extends HotSpotVirtualMachine {
if (cmd.equals("load")) { if (cmd.equals("load")) {
throw new AgentLoadException("Failed to load agent library"); throw new AgentLoadException("Failed to load agent library");
} else { } 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);
}
} }
} }
......
/* /*
* Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright 2013 SAP AG. All rights reserved. * Copyright 2015 SAP AG. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -238,14 +238,14 @@ JNIEXPORT jint JNICALL Java_sun_tools_attach_AixVirtualMachine_read ...@@ -238,14 +238,14 @@ JNIEXPORT jint JNICALL Java_sun_tools_attach_AixVirtualMachine_read
len = remaining; len = remaining;
} }
RESTARTABLE(read(fd, buf+off, len), n); RESTARTABLE(read(fd, buf, len), n);
if (n == -1) { if (n == -1) {
JNU_ThrowIOExceptionWithLastError(env, "read"); JNU_ThrowIOExceptionWithLastError(env, "read");
} else { } else {
if (n == 0) { if (n == 0) {
n = -1; // EOF n = -1; // EOF
} else { } else {
(*env)->SetByteArrayRegion(env, ba, off, (jint)n, (jbyte *)(buf+off)); (*env)->SetByteArrayRegion(env, ba, off, (jint)n, (jbyte *)(buf));
} }
} }
return n; return n;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册