From 1282d6d50f425884f7d733d86c31108f47633ba3 Mon Sep 17 00:00:00 2001 From: andxu Date: Thu, 5 Jul 2018 09:38:07 +0800 Subject: [PATCH] Fix attach connector in java 10 error: cannot attach in java 10 --- .../java/com/microsoft/java/debug/core/DebugUtility.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/com.microsoft.java.debug.core/src/main/java/com/microsoft/java/debug/core/DebugUtility.java b/com.microsoft.java.debug.core/src/main/java/com/microsoft/java/debug/core/DebugUtility.java index e3e38e6d1..d802551e0 100644 --- a/com.microsoft.java.debug.core/src/main/java/com/microsoft/java/debug/core/DebugUtility.java +++ b/com.microsoft.java.debug.core/src/main/java/com/microsoft/java/debug/core/DebugUtility.java @@ -194,6 +194,14 @@ public static IDebugSession attach(VirtualMachineManager vmManager, String hostN throws IOException, IllegalConnectorArgumentsException { List connectors = vmManager.attachingConnectors(); AttachingConnector connector = connectors.get(0); + // in JDK 10, the first AttachingConnector is not the one we want + final String SUN_ATTACH_CONNECTOR = "com.sun.tools.jdi.SocketAttachingConnector"; + for (AttachingConnector con : connectors) { + if (con.getClass().getName().equals(SUN_ATTACH_CONNECTOR)) { + connector = con; + break; + } + } Map arguments = connector.defaultArguments(); arguments.get(HOSTNAME).setValue(hostName); arguments.get(PORT).setValue(String.valueOf(port));