Skip to content

Commit

Permalink
Another follow up to parser library loading issue
Browse files Browse the repository at this point in the history
Parser is present in both `runtime.jar` and `runner.jar` jars, leading
to shared library loading issues:
```
Caused by: java.lang.UnsatisfiedLinkError: Native Library <...>/component/libenso_parser.so already loaded in another classloader
    at java.base/jdk.internal.loader.NativeLibraries.loadLibrary(NativeLibraries.java:167)
    at java.base/jdk.internal.loader.NativeLibraries.loadLibrary(NativeLibraries.java:139)
    at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2418)
    at java.base/java.lang.Runtime.load0(Runtime.java:852)
    at java.base/java.lang.System.load(System.java:2025)
    at org.enso.runtime/org.enso.syntax2.Parser.initializeLibraries(Parser.java:36)
    ... 43 common frames omitted
Caused by: java.lang.UnsatisfiedLinkError: Can't load library: <...>/target/rust/debug/libenso_parser.so
    at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2422)
```

This change ensures that library is only loaded once.
  • Loading branch information
hubertp committed May 30, 2024
1 parent c94507d commit 4835c95
Showing 1 changed file with 1 addition and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import java.nio.charset.StandardCharsets;

public final class Parser implements AutoCloseable {
private static void initializeLibraries() {
static {
String os = System.getProperty("os.name");
String name;
if (os.startsWith("Mac")) {
Expand Down Expand Up @@ -87,7 +87,6 @@ private Parser(long stateIn) {
static native long getUuidLow(long metadata, long codeOffset, long codeLength);

public static Parser create() {
initializeLibraries();
var state = allocState();
return new Parser(state);
}
Expand Down

0 comments on commit 4835c95

Please sign in to comment.