Mercurial > hg > openjdk > aarch64-port > jdk
changeset 10684:1472ef5e1416
8071687: AIX port of "8039173: Propagate errors from Diagnostic Commands as exceptions in the attach framework"
Reviewed-by: sla
author | simonis |
---|---|
date | Wed, 18 Mar 2015 09:13:11 +0100 |
parents | 293cb6865e64 |
children | c898f6979067 |
files | src/aix/classes/sun/tools/attach/AixVirtualMachine.java src/aix/native/sun/tools/attach/AixVirtualMachine.c |
diffstat | 2 files changed, 15 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/src/aix/classes/sun/tools/attach/AixVirtualMachine.java Mon Mar 16 20:55:08 2015 +0300 +++ b/src/aix/classes/sun/tools/attach/AixVirtualMachine.java Wed Mar 18 09:13:11 2015 +0100 @@ -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,14 +25,14 @@ */ 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.AttachNotSupportedException; import com.sun.tools.attach.spi.AttachProvider; + import java.io.InputStream; import java.io.IOException; import java.io.File; -import java.util.Properties; // Based on 'LinuxVirtualMachine.java'. All occurrences of the string // "Linux" have been textually replaced by "Aix" to avoid confusion. @@ -192,6 +192,8 @@ } 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 @@ -206,7 +208,11 @@ 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); + } } }
--- a/src/aix/native/sun/tools/attach/AixVirtualMachine.c Mon Mar 16 20:55:08 2015 +0300 +++ b/src/aix/native/sun/tools/attach/AixVirtualMachine.c Wed Mar 18 09:13:11 2015 +0100 @@ -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 @@ -238,14 +238,14 @@ 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;