From 8e4dcdf57baf88f0267be3662b63b59ab60224e4 Mon Sep 17 00:00:00 2001 From: jbergthold <92237063+Jabe03@users.noreply.github.com> Date: Tue, 15 Sep 2026 14:03:12 -0500 Subject: [PATCH 1/3] Use a Windows-compatible method of retrieving filepaths from interpreter input files. --- src/main/java/edu/uiowa/cs/clc/kind2/api/Kind2Api.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main/java/edu/uiowa/cs/clc/kind2/api/Kind2Api.java b/src/main/java/edu/uiowa/cs/clc/kind2/api/Kind2Api.java index b1c163f..2a33416 100644 --- a/src/main/java/edu/uiowa/cs/clc/kind2/api/Kind2Api.java +++ b/src/main/java/edu/uiowa/cs/clc/kind2/api/Kind2Api.java @@ -11,6 +11,7 @@ import java.io.IOException; import java.io.InputStreamReader; import java.net.URI; +import java.nio.file.Paths; import java.util.ArrayList; import java.util.HashSet; import java.util.List; @@ -288,8 +289,8 @@ public String interpret(URI uri, String main, String json) { options.add("--enable"); options.add("interpreter"); options.add("--interpreter_input_file"); - options.add(ApiUtil.writeInterpreterFile(json).toURI().getPath()); - options.add(uri.getPath()); + options.add(ApiUtil.writeInterpreterFile(json).getAbsolutePath()); + options.add(Paths.get(uri).toString()); ProcessBuilder builder = new ProcessBuilder(options); try { Process process = builder.start(); @@ -326,7 +327,7 @@ public String interpret(String program, String main, String json) { options.add("--enable"); options.add("interpreter"); options.add("--interpreter_input_file"); - options.add(ApiUtil.writeInterpreterFile(json).toURI().getPath()); + options.add(ApiUtil.writeInterpreterFile(json).getAbsolutePath()); ProcessBuilder builder = new ProcessBuilder(options); try { Process process = builder.start(); @@ -981,7 +982,7 @@ public void setInterpreterInputFile(String interpreterInputFile) { */ public void setInterpreterInput(String json) { File interpreterFile = ApiUtil.writeInterpreterFile(json); - this.interpreterInputFile = interpreterFile.toURI().getPath(); + this.interpreterInputFile = interpreterFile.getAbsolutePath(); } /** From 2ce4aec8fab3f0697611bafeec732bb57e6cd99a Mon Sep 17 00:00:00 2001 From: jbergthold <92237063+Jabe03@users.noreply.github.com> Date: Tue, 15 Sep 2026 14:44:44 -0500 Subject: [PATCH 2/3] Improve file path handling for interpreter input to support various URI schemes --- .../java/edu/uiowa/cs/clc/kind2/api/Kind2Api.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/main/java/edu/uiowa/cs/clc/kind2/api/Kind2Api.java b/src/main/java/edu/uiowa/cs/clc/kind2/api/Kind2Api.java index 2a33416..b835522 100644 --- a/src/main/java/edu/uiowa/cs/clc/kind2/api/Kind2Api.java +++ b/src/main/java/edu/uiowa/cs/clc/kind2/api/Kind2Api.java @@ -290,7 +290,16 @@ public String interpret(URI uri, String main, String json) { options.add("interpreter"); options.add("--interpreter_input_file"); options.add(ApiUtil.writeInterpreterFile(json).getAbsolutePath()); - options.add(Paths.get(uri).toString()); + try { + // Paths.get(uri) requires a file: URI with no query/fragment/authority; + // fall back to the raw path for anything else (e.g. platform:/resource/...). + String filePath = "file".equalsIgnoreCase(uri.getScheme()) + ? Paths.get(uri).toString() + : uri.getPath(); + options.add(filePath); + } catch (IllegalArgumentException | java.nio.file.FileSystemNotFoundException e) { + throw new Kind2Exception(e.getMessage(), e); + } ProcessBuilder builder = new ProcessBuilder(options); try { Process process = builder.start(); From 50399afa72dbd96238199128ab38d425cf1b2dcd Mon Sep 17 00:00:00 2001 From: Daniel Larraz Date: Tue, 15 Sep 2026 15:16:21 -0500 Subject: [PATCH 3/3] Resolve interpreter URIs to local paths with clear errors Kind 2 can only read local files, so interpret(URI, ...) now converts its argument with a toLocalPath helper: scheme-less URIs are used as plain paths, file: URIs have their query and fragment dropped before Paths.get, and anything else (other schemes, opaque or invalid paths) raises a Kind2Exception instead of passing Kind 2 a nonexistent path. Co-Authored-By: Claude Opus 5 (1M context) --- .../edu/uiowa/cs/clc/kind2/api/Kind2Api.java | 37 +++++++++++++------ 1 file changed, 25 insertions(+), 12 deletions(-) diff --git a/src/main/java/edu/uiowa/cs/clc/kind2/api/Kind2Api.java b/src/main/java/edu/uiowa/cs/clc/kind2/api/Kind2Api.java index b835522..ae4432c 100644 --- a/src/main/java/edu/uiowa/cs/clc/kind2/api/Kind2Api.java +++ b/src/main/java/edu/uiowa/cs/clc/kind2/api/Kind2Api.java @@ -11,6 +11,8 @@ import java.io.IOException; import java.io.InputStreamReader; import java.net.URI; +import java.net.URISyntaxException; +import java.nio.file.Path; import java.nio.file.Paths; import java.util.ArrayList; import java.util.HashSet; @@ -274,11 +276,11 @@ public void done() {} /** * Runs the Kind 2 interpreter on a Lustre file. * - * @param uri the Lustre file to interpret + * @param uri the Lustre file to interpret, as a scheme-less path or a {@code file:} URI * @param main the main node to interpret * @param json the input values, as a json string * @return the interpreter output - * @throws Kind2Exception if Kind 2 fails to run + * @throws Kind2Exception if {@code uri} is not a local file or Kind 2 fails to run */ public String interpret(URI uri, String main, String json) { List options = new ArrayList<>(); @@ -290,16 +292,7 @@ public String interpret(URI uri, String main, String json) { options.add("interpreter"); options.add("--interpreter_input_file"); options.add(ApiUtil.writeInterpreterFile(json).getAbsolutePath()); - try { - // Paths.get(uri) requires a file: URI with no query/fragment/authority; - // fall back to the raw path for anything else (e.g. platform:/resource/...). - String filePath = "file".equalsIgnoreCase(uri.getScheme()) - ? Paths.get(uri).toString() - : uri.getPath(); - options.add(filePath); - } catch (IllegalArgumentException | java.nio.file.FileSystemNotFoundException e) { - throw new Kind2Exception(e.getMessage(), e); - } + options.add(toLocalPath(uri).toString()); ProcessBuilder builder = new ProcessBuilder(options); try { Process process = builder.start(); @@ -318,6 +311,26 @@ public String interpret(URI uri, String main, String json) { } } + /** + * Converts a URI to a path on the local file system, since Kind 2 can only read local files. + * Scheme-less URIs are treated as plain paths; the query and fragment of a file: URI are ignored. + */ + private static Path toLocalPath(URI uri) { + String scheme = uri.getScheme(); + if ((scheme != null && !"file".equalsIgnoreCase(scheme)) || uri.getPath() == null) { + throw new Kind2Exception("Not a local file URI: " + uri); + } + try { + if (scheme == null) { + return Paths.get(uri.getPath()); + } + // Keep the authority so Windows UNC paths (file://server/share/...) still resolve. + return Paths.get(new URI("file", uri.getAuthority(), uri.getPath(), null, null)); + } catch (URISyntaxException | IllegalArgumentException e) { + throw new Kind2Exception("Not a local file URI: " + uri, e); + } + } + /** * Runs the Kind 2 interpreter on a Lustre program. *