Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

java.net.URI.toURI broken #460

Merged
merged 4 commits into from
Jun 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package jdk.internal.misc;

public interface JavaNetUriAccess {
// We can add more necessary methods here
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public class SharedSecrets {
private static JavaObjectInputStreamAccess javaObjectInputStreamAccess;
private static JavaObjectInputFilterAccess javaObjectInputFilterAccess;
private static JavaObjectInputStreamReadString javaObjectInputStreamReadString;
private static JavaNetUriAccess javaNetUriAccess;

// (required for EnumSet ops)
public static JavaLangAccess getJavaLangAccess() {
Expand Down Expand Up @@ -207,4 +208,12 @@ public static JavaObjectInputStreamReadString getJavaObjectInputStreamReadString
public static void setJavaObjectInputStreamReadString(JavaObjectInputStreamReadString access) {
javaObjectInputStreamReadString = access;
}

public static void setJavaNetUriAccess(JavaNetUriAccess jnua) {
javaNetUriAccess = jnua;
}

public static JavaNetUriAccess getJavaNetUriAccess() {
return javaNetUriAccess;
}
}
20 changes: 19 additions & 1 deletion src/tests/gov/nasa/jpf/test/java/io/FileTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@

import java.io.File;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;

import org.junit.After;
import org.junit.AfterClass;
Expand Down Expand Up @@ -102,5 +104,21 @@ public void testEquals() {
assert file.equals(new Object()) == false;
}
}


@Test
public void testToURI(){
if(verifyNoPropertyViolation()){
File file = new File("testfile.txt");
URI expectedURI = null;
try {
expectedURI = new URI("file:" + file.getAbsolutePath());
} catch (URISyntaxException e) {
fail("URISyntaxException thrown while constructing expected URI");
}

URI actualURI = file.toURI();
System.out.println(actualURI);
assertEquals("The URIs should be equal",expectedURI,actualURI);
}
}
}
Loading