From 51ff0628073e7c547b42f9c5705505e2ce4536a0 Mon Sep 17 00:00:00 2001 From: Malte Stellmacher Date: Mon, 5 Feb 2024 18:26:47 +0100 Subject: [PATCH] Fix null libraries not entered into map --- .../nodes/plugins/ffi/PrimExternalCallNode.java | 6 ++++++ 1 file changed, 6 insertions(+) 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;