diff --git a/substratevm/src/com.oracle.svm.hosted.foreign/src/com/oracle/svm/hosted/foreign/ForeignFunctionsConfigurationParser.java b/substratevm/src/com.oracle.svm.hosted.foreign/src/com/oracle/svm/hosted/foreign/ForeignFunctionsConfigurationParser.java index b927c7fda6f6..cd3b2b260faa 100644 --- a/substratevm/src/com.oracle.svm.hosted.foreign/src/com/oracle/svm/hosted/foreign/ForeignFunctionsConfigurationParser.java +++ b/substratevm/src/com.oracle.svm.hosted.foreign/src/com/oracle/svm/hosted/foreign/ForeignFunctionsConfigurationParser.java @@ -26,10 +26,12 @@ import java.lang.foreign.FunctionDescriptor; import java.lang.foreign.Linker; +import java.lang.foreign.Linker.Option; import java.net.URI; import java.util.ArrayList; import java.util.List; import java.util.function.BiConsumer; +import java.util.function.Function; import org.graalvm.collections.EconomicMap; import org.graalvm.nativeimage.Platform; @@ -38,9 +40,11 @@ import org.graalvm.nativeimage.impl.RuntimeForeignAccessSupport; import com.oracle.svm.core.configure.ConfigurationParser; +import com.oracle.svm.core.util.BasedOnJDKFile; import jdk.graal.compiler.util.json.JsonParserException; +@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-24+23/src/java.base/share/classes/jdk/internal/foreign/abi/LinkerOptions.java") @Platforms(Platform.HOSTED_ONLY.class) public class ForeignFunctionsConfigurationParser extends ConfigurationParser { private static final String DOWNCALL_OPTION_CAPTURE_CALL_STATE = "captureCallState"; @@ -58,25 +62,26 @@ public ForeignFunctionsConfigurationParser(RuntimeForeignAccessSupport access) { @Override public void parseAndRegister(Object json, URI origin) { var topLevel = asMap(json, "first level of document must be a map"); - checkAttributes(topLevel, "foreign methods categories", List.of(), List.of("downcalls")); + checkAttributes(topLevel, "foreign methods categories", List.of(), List.of("downcalls", "upcalls")); var downcalls = asList(topLevel.get("downcalls", List.of()), "downcalls must be an array of method signatures"); for (Object downcall : downcalls) { - parseAndRegisterForeignCall(downcall, (descriptor, options) -> accessSupport.registerForDowncall(ConfigurationCondition.alwaysTrue(), descriptor, options)); + parseAndRegisterForeignCall(downcall, this::parseDowncallOptions, (descriptor, options) -> accessSupport.registerForDowncall(ConfigurationCondition.alwaysTrue(), descriptor, options)); } var upcalls = asList(topLevel.get("upcalls", List.of()), "upcalls must be an array of method signatures"); for (Object upcall : upcalls) { - parseAndRegisterForeignCall(upcall, (descriptor, options) -> accessSupport.registerForUpcall(ConfigurationCondition.alwaysTrue(), descriptor, options)); + parseAndRegisterForeignCall(upcall, this::parseUpcallOptions, (descriptor, options) -> accessSupport.registerForUpcall(ConfigurationCondition.alwaysTrue(), descriptor, options)); } } - private void parseAndRegisterForeignCall(Object call, BiConsumer register) { + private void parseAndRegisterForeignCall(Object call, Function, List