33import static java .lang .String .format ;
44import static org .eclipse .core .runtime .IPath .forPosix ;
55
6+ import java .io .File ;
67import java .io .IOException ;
78import java .nio .file .Path ;
89
910import org .eclipse .core .runtime .CoreException ;
1011import org .eclipse .core .runtime .IPath ;
12+ import org .eclipse .core .runtime .Platform ;
1113import org .eclipse .jdt .core .IClasspathEntry ;
1214import org .slf4j .Logger ;
1315import org .slf4j .LoggerFactory ;
@@ -101,6 +103,15 @@ public ArtifactLocationDecoder getLocationDecoder() {
101103 return locationDecoder ;
102104 }
103105
106+ private IPath getPath (String path ) throws IOException {
107+ if (Platform .OS_WIN32 .equals (Platform .getOS ())) {
108+ var file = new File (path );
109+ var canonicalPath = file .getCanonicalPath ();
110+ return org .eclipse .core .runtime .Path .fromOSString (canonicalPath );
111+ }
112+ return forPosix (path );
113+ }
114+
104115 public WorkspaceRoot getWorkspaceRoot () {
105116 return workspaceRoot ;
106117 }
@@ -129,7 +140,13 @@ public ClasspathEntry resolveJar(LibraryArtifact jar) {
129140 // prefer the class jar because this is much better in Eclipse when debugging/stepping through code/code navigation/etc.
130141 var jarArtifactForIde = jar .getClassJar () != null ? jar .getClassJar () : jar .jarForIntellijLibrary ();
131142 if (jarArtifactForIde .isMainWorkspaceSourceArtifact ()) {
132- var jarPath = forPosix (locationDecoder .resolveSource (jarArtifactForIde ).toString ());
143+ IPath jarPath ;
144+ try {
145+ jarPath = getPath (locationDecoder .resolveSource (jarArtifactForIde ).toString ());
146+ } catch (IOException e ) {
147+ LOG .error (e .getMessage (), e );
148+ return null ;
149+ }
133150 var sourceJar = jar .getSourceJars ().stream ().findFirst ();
134151 if (!sourceJar .isPresent ()) {
135152 if (LOG .isDebugEnabled ()) {
@@ -140,8 +157,13 @@ public ClasspathEntry resolveJar(LibraryArtifact jar) {
140157 }
141158 return ClasspathEntry .newLibraryEntry (jarPath , null , null , false /* test only */ );
142159 }
143-
144- var srcJarPath = forPosix (locationDecoder .resolveSource (sourceJar .get ()).toString ());
160+ IPath srcJarPath ;
161+ try {
162+ srcJarPath = getPath (locationDecoder .resolveSource (sourceJar .get ()).toString ());
163+ } catch (IOException e ) {
164+ LOG .error (e .getMessage (), e );
165+ srcJarPath = null ;
166+ }
145167 if (LOG .isDebugEnabled ()) {
146168 LOG .debug (
147169 "Found jar for '{}': {} (source {})" ,
@@ -153,7 +175,13 @@ public ClasspathEntry resolveJar(LibraryArtifact jar) {
153175 }
154176 var jarArtifact = locationDecoder .resolveOutput (jarArtifactForIde );
155177 if (jarArtifact instanceof LocalFileArtifact localJar ) {
156- var jarPath = forPosix (localJar .getPath ().toString ());
178+ IPath jarPath ;
179+ try {
180+ jarPath = getPath (localJar .getPath ().toString ());
181+ } catch (IOException e ) {
182+ LOG .error (e .getMessage (), e );
183+ return null ;
184+ }
157185 var sourceJar = jar .getSourceJars ().stream ().findFirst ();
158186 if (!sourceJar .isPresent ()) {
159187 if (LOG .isDebugEnabled ()) {
@@ -163,7 +191,14 @@ public ClasspathEntry resolveJar(LibraryArtifact jar) {
163191 }
164192 var srcJarArtifact = locationDecoder .resolveOutput (sourceJar .get ());
165193 if (srcJarArtifact instanceof LocalFileArtifact localSrcJar ) {
166- var srcJarPath = forPosix (localSrcJar .getPath ().toString ());
194+ var pathStr = org .eclipse .core .runtime .Path .fromOSString (localSrcJar .getPath ().toString ()).toString ();
195+ IPath srcJarPath ;
196+ try {
197+ srcJarPath = getPath (localSrcJar .getPath ().toString ());
198+ } catch (IOException e ) {
199+ LOG .error (e .getMessage (), e );
200+ srcJarPath = null ;
201+ }
167202 if (LOG .isDebugEnabled ()) {
168203 LOG .debug (
169204 "Found jar for '{}': {} (source {})" ,
0 commit comments