Skip to content

Commit e170267

Browse files
[GR-43605] Fix: NativeImageResourcePath#toUri issue.
PullRequest: graal/13635
2 parents d55fbf6 + 740c436 commit e170267

File tree

2 files changed

+27
-3
lines changed

2 files changed

+27
-3
lines changed

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/resources/NativeImageResourcePath.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -391,9 +391,7 @@ public URI toUri() {
391391
try {
392392
return new URI(
393393
"resource",
394-
fileSystem.getResourcePath().toUri() +
395-
"!" +
396-
fileSystem.getString(toAbsolutePath().path),
394+
fileSystem.getString(toAbsolutePath().path),
397395
null);
398396
} catch (URISyntaxException e) {
399397
throw new AssertionError(e);

substratevm/src/com.oracle.svm.test/src/com/oracle/svm/test/NativeImageResourceFileSystemProviderTest.java

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,32 @@ public void githubIssue5080() {
160160
}
161161
}
162162

163+
/**
164+
* Test native implementations of {@link Path#toUri()} and {@link Path#of(URI)}. Inspired by
165+
* issue: <a href="https://github.com/oracle/graal/issues/5720">5720</a>
166+
*/
167+
@Test
168+
public void githubIssue5720() {
169+
URI uri1 = resourceNameToURI(RESOURCE_FILE_1, true);
170+
Assert.assertNotNull(uri1);
171+
172+
Path path1 = Path.of(uri1);
173+
Assert.assertNotNull(path1);
174+
175+
URI uri2 = path1.toUri();
176+
Assert.assertNotNull(uri2);
177+
178+
Path path2 = Path.of(uri2);
179+
Assert.assertNotNull(path2);
180+
181+
Assert.assertEquals(path1, path2);
182+
try {
183+
Assert.assertTrue(Files.isSameFile(path1, path2));
184+
} catch (IOException e) {
185+
Assert.fail("IOException occurred during file system operation.");
186+
}
187+
}
188+
163189
/**
164190
* Reading from file using {@link java.nio.channels.ByteChannel}.
165191
*/

0 commit comments

Comments
 (0)