diff --git a/README.md b/README.md index 720f36c..11d81b3 100644 --- a/README.md +++ b/README.md @@ -88,7 +88,7 @@ Import as a Gradle dependency: ```groovy dependencies { - implementation("io.github.over-run:marshal:0.1.0-alpha.31-jdk23") + implementation("io.github.over-run:marshal:0.1.0-alpha.32-jdk23") } ``` diff --git a/gradle.properties b/gradle.properties index 98c0864..ad8e9eb 100644 --- a/gradle.properties +++ b/gradle.properties @@ -12,7 +12,7 @@ projGroupId=io.github.over-run projArtifactId=marshal # The project name should only contain lowercase letters, numbers and hyphen. projName=marshal -projVersion=0.1.0-alpha.31-jdk23 +projVersion=0.1.0-alpha.32-jdk23 projDesc=Marshaler of native libraries # Uncomment them if you want to publish to maven repository. projUrl=https://github.com/Over-Run/marshal diff --git a/src/main/java/overrun/marshal/Downcall.java b/src/main/java/overrun/marshal/Downcall.java index 192a036..c0d402c 100644 --- a/src/main/java/overrun/marshal/Downcall.java +++ b/src/main/java/overrun/marshal/Downcall.java @@ -647,29 +647,31 @@ private static DowncallData generateData( } descriptorMap1.put(entrypoint, descriptor); - final Optional optional = lookup.find(entrypoint); - MethodHandle handle; - if (optional.isPresent()) { - // linker options - final Linker.Option[] options; - final Critical critical = method.getDeclaredAnnotation(Critical.class); - if (critical != null) { - options = critical.allowHeapAccess() ? OPTION_CRITICAL_TRUE : OPTION_CRITICAL_FALSE; - } else { - options = NO_OPTION; - } + if (descriptor != null) { + final Optional optional = lookup.find(entrypoint); + MethodHandle handle; + if (optional.isPresent()) { + // linker options + final Linker.Option[] options; + final Critical critical = method.getDeclaredAnnotation(Critical.class); + if (critical != null) { + options = critical.allowHeapAccess() ? OPTION_CRITICAL_TRUE : OPTION_CRITICAL_FALSE; + } else { + options = NO_OPTION; + } - handle = transform.apply(LINKER.downcallHandle(optional.get(), descriptor, options)); - } else { - MethodHandle apply = transform.apply(null); - if (apply != null || method.isDefault()) { - handle = apply; + handle = transform.apply(LINKER.downcallHandle(optional.get(), descriptor, options)); } else { - throw new NoSuchElementException("Symbol not found: " + entrypoint + " (" + descriptor + "): " + methodData.signatureString()); + MethodHandle apply = transform.apply(null); + if (apply != null || method.isDefault()) { + handle = apply; + } else { + throw new NoSuchElementException("Symbol not found: " + entrypoint + " (" + descriptor + "): " + methodData.signatureString()); + } + } + if (!map.containsKey(entrypoint) || map.get(entrypoint) == null) { + map.putIfAbsent(entrypoint, handle); } - } - if (!map.containsKey(entrypoint) || map.get(entrypoint) == null) { - map.put(entrypoint, handle); } } return new DowncallData(Collections.unmodifiableMap(descriptorMap1), diff --git a/src/test/java/overrun/marshal/test/downcall/IDowncall.java b/src/test/java/overrun/marshal/test/downcall/IDowncall.java index 1e41182..17d60e4 100644 --- a/src/test/java/overrun/marshal/test/downcall/IDowncall.java +++ b/src/test/java/overrun/marshal/test/downcall/IDowncall.java @@ -38,10 +38,7 @@ * @since 0.1.0 */ public interface IDowncall { - Map MAP = Map.of( - "testDefault", FunctionDescriptor.of(ValueLayout.JAVA_INT), - "testReturnInt", FunctionDescriptor.of(ValueLayout.JAVA_INT) - ); + Map MAP = Map.of("testDefault", FunctionDescriptor.of(ValueLayout.JAVA_INT)); static IDowncall getInstance(boolean testDefaultNull) { ProcessorTypes.registerStruct(Vector3.class, Vector3.OF);