diff --git a/src/de.hpi.swa.trufflesqueak/src/de/hpi/swa/trufflesqueak/nodes/plugins/ffi/PrimExternalCallNode.java b/src/de.hpi.swa.trufflesqueak/src/de/hpi/swa/trufflesqueak/nodes/plugins/ffi/PrimExternalCallNode.java index 368c2131c..eb9779842 100644 --- a/src/de.hpi.swa.trufflesqueak/src/de/hpi/swa/trufflesqueak/nodes/plugins/ffi/PrimExternalCallNode.java +++ b/src/de.hpi.swa.trufflesqueak/src/de/hpi/swa/trufflesqueak/nodes/plugins/ffi/PrimExternalCallNode.java @@ -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; }"); @@ -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;