Skip to content

Commit 3a3c2d0

Browse files
Fix the project's build errors in JDK 9/10 (#178)
* Fix the project's build errors in JDK 9/10 Signed-off-by: Jinbo Wang <[email protected]> * Fix review comments: Move constant string to a final variable
1 parent b2ce2bb commit 3a3c2d0

File tree

3 files changed

+30
-8
lines changed

3 files changed

+30
-8
lines changed

com.microsoft.java.debug.core/pom.xml

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,6 @@
3939
</plugins>
4040
</build>
4141
<dependencies>
42-
<dependency>
43-
<groupId>com.sun</groupId>
44-
<artifactId>tools</artifactId>
45-
<version>1.8</version>
46-
<scope>system</scope>
47-
<systemPath>${java.home}/../lib/tools.jar</systemPath>
48-
</dependency>
4942
<dependency>
5043
<groupId>org.apache.commons</groupId>
5144
<artifactId>commons-lang3</artifactId>
@@ -85,4 +78,21 @@
8578
<scope>test</scope>
8679
</dependency>
8780
</dependencies>
81+
<profiles>
82+
<profile>
83+
<id>default-tools.jar</id>
84+
<activation>
85+
<jdk>(,9)</jdk>
86+
</activation>
87+
<dependencies>
88+
<dependency>
89+
<groupId>com.sun</groupId>
90+
<artifactId>tools</artifactId>
91+
<version>1.8</version>
92+
<scope>system</scope>
93+
<systemPath>${java.home}/../lib/tools.jar</systemPath>
94+
</dependency>
95+
</dependencies>
96+
</profile>
97+
</profiles>
8898
</project>

com.microsoft.java.debug.core/src/main/java/com/microsoft/java/debug/core/DebugUtility.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,18 @@ public static IDebugSession launch(VirtualMachineManager vmManager,
118118
List<LaunchingConnector> connectors = vmManager.launchingConnectors();
119119
LaunchingConnector connector = connectors.get(0);
120120

121+
/** In the sun JDK 10, the first launching connector is com.sun.tools.jdi.RawCommandLineLauncher, which is not the one we want to use.
122+
* Add the logic to filter the right one from LaunchingConnector list.
123+
* This fix is only for the JDI implementation by JDK. Other JDI implementations (such as JDT) doesn't have the impact.
124+
*/
125+
final String SUN_LAUNCHING_CONNECTOR = "com.sun.tools.jdi.SunCommandLineLauncher";
126+
for (LaunchingConnector con : connectors) {
127+
if (con.getClass().getName().equals(SUN_LAUNCHING_CONNECTOR)) {
128+
connector = con;
129+
break;
130+
}
131+
}
132+
121133
Map<String, Argument> arguments = connector.defaultArguments();
122134
arguments.get(SUSPEND).setValue("true");
123135

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<properties>
1212
<base.name>Java Debug Server for Visual Studio Code</base.name>
1313
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
14-
<tycho-version>1.0.0</tycho-version>
14+
<tycho-version>1.1.0</tycho-version>
1515
</properties>
1616

1717
<licenses>

0 commit comments

Comments
 (0)