From ca8d715d5aedc69f3b2d0a0127648bb1f3c3c37d Mon Sep 17 00:00:00 2001 From: Hubert Plociniczak Date: Wed, 29 May 2024 23:43:53 +0200 Subject: [PATCH] Hotfix for finding parser library (#10123) * Hotfix for finding parser library Since ydoc is now started by language server, parser is initialized differently and attempts to find `libenso_parser.so` in `component/runner` rather than `component` directory. * Add fallbacks * fix native image build --- .../java/org/enso/syntax2/Parser.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/rust/parser/generate-java/java/org/enso/syntax2/Parser.java b/lib/rust/parser/generate-java/java/org/enso/syntax2/Parser.java index 26fde4cc6b8..4d78e59b529 100644 --- a/lib/rust/parser/generate-java/java/org/enso/syntax2/Parser.java +++ b/lib/rust/parser/generate-java/java/org/enso/syntax2/Parser.java @@ -21,8 +21,18 @@ public final class Parser implements AutoCloseable { File parser = null; try { var whereAmI = Parser.class.getProtectionDomain().getCodeSource().getLocation(); - File dir = new File(whereAmI.toURI()).getParentFile(); - parser = new File(dir, name); + var d = new File(whereAmI.toURI()).getParentFile(); + File path = null; + while (d != null) { + path = new File(d, name); + if (path.exists()) break; + d = d.getParentFile(); + } + if (d == null) { + throw new LinkageError( + "Cannot find parser in " + new File(whereAmI.toURI()).getParentFile()); + } + parser = path; System.load(parser.getAbsolutePath()); } catch (URISyntaxException | LinkageError e) { File root = new File(".").getAbsoluteFile();