Skip to content

Commit

Permalink
Fix null libraries not entered into map
Browse files Browse the repository at this point in the history
  • Loading branch information
DieKautz committed Feb 5, 2024
1 parent 4169948 commit 51ff062
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ public PrimExternalCallNode(final Object moduleLibrary, final InteropLibrary mod
public static PrimExternalCallNode load(final String moduleName, final String functionName, final int numReceiverAndArguments) {
final SqueakImageContext context = SqueakImageContext.getSlow();
final Object moduleLibrary = loadedLibraries.computeIfAbsent(moduleName, (String s) -> {
if (loadedLibraries.containsKey(moduleName)) {
// if moduleName was associated with null
return null;
}
final Object library;
try {
library = NFIUtils.loadLibrary(context, moduleName, "{ setInterpreter(POINTER):SINT64; }");
Expand All @@ -71,6 +75,8 @@ public static PrimExternalCallNode load(final String moduleName, final String fu
}
return library;
});
// computeIfAbsent would not put null value
loadedLibraries.putIfAbsent(moduleName, moduleLibrary);
if (moduleLibrary == null) {
// module not found
return null;
Expand Down

0 comments on commit 51ff062

Please sign in to comment.