aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEgor Ushakov <egor.ushakov@jetbrains.com>2018-10-25 18:35:53 +0300
committerEgor Ushakov <egor.ushakov@jetbrains.com>2018-10-25 18:36:11 +0300
commit01a8d1d4a843cafe15e9ec41a6dd8696cfae08c6 (patch)
tree20633efb4a40042b7be45a387c48195ced4e5fc5
parent5c800481a3e6292c2041b0c4605298d4e5fb91d7 (diff)
downloadjdk8u_jdk-jb8u152-b1370.tar.gz
JRE-1007 Read exception details in jdwp error packetsjb8u152-b1370
-rw-r--r--src/share/classes/com/sun/tools/jdi/JDWPException.java6
-rw-r--r--src/share/classes/com/sun/tools/jdi/PacketStream.java20
2 files changed, 24 insertions, 2 deletions
diff --git a/src/share/classes/com/sun/tools/jdi/JDWPException.java b/src/share/classes/com/sun/tools/jdi/JDWPException.java
index 6f3fdb5a80..45384b9f7d 100644
--- a/src/share/classes/com/sun/tools/jdi/JDWPException.java
+++ b/src/share/classes/com/sun/tools/jdi/JDWPException.java
@@ -62,7 +62,11 @@ class JDWPException extends Exception {
case JDWP.Error.INVALID_THREAD:
return new IllegalThreadStateException();
default:
- return new InternalException("Unexpected JDWP Error: " + errorCode, errorCode);
+ InternalException internalException = new InternalException("Unexpected JDWP Error: " + errorCode, errorCode);
+ if (errorCode == JDWP.Error.INTERNAL) {
+ internalException.initCause(getCause());
+ }
+ return internalException;
}
}
}
diff --git a/src/share/classes/com/sun/tools/jdi/PacketStream.java b/src/share/classes/com/sun/tools/jdi/PacketStream.java
index a0cd2f35ba..1fa27fcccc 100644
--- a/src/share/classes/com/sun/tools/jdi/PacketStream.java
+++ b/src/share/classes/com/sun/tools/jdi/PacketStream.java
@@ -69,7 +69,25 @@ class PacketStream {
vm.waitForTargetReply(pkt);
if (pkt.errorCode != Packet.ReplyNoError) {
- throw new JDWPException(pkt.errorCode);
+ JDWPException e = new JDWPException(pkt.errorCode);
+ if (pkt.errorCode == JDWP.Error.INTERNAL && pkt.data.length > 0) {
+ // try to read the internal exception cause if any
+ try {
+ e.initCause(new Throwable("(remote exception) " + readString()) {
+ @Override
+ public synchronized Throwable fillInStackTrace() {
+ return this;
+ }
+
+ @Override
+ public String toString() {
+ return getMessage();
+ }
+ });
+ } catch (Exception ignored) {
+ }
+ }
+ throw e;
}
}