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
This commit is contained in:
Hubert Plociniczak 2024-05-29 23:43:53 +02:00 committed by GitHub
parent e9452ea8ad
commit ca8d715d5a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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();