Browse Source

JavaNativeModule: Fixed Method selection for Functional interfaces

Background: We only checked public nondefault, that matched for public statics as well.
Now checks for public nodefault abstract

Also TODO: Functional Type may not be part of functional Method's signature
kindlich 4 years ago
parent
commit
710d29a45a
No known key found for this signature in database

+ 2
- 1
JavaIntegration/src/main/java/org/openzen/zencode/java/JavaNativeModule.java View File

@@ -967,6 +967,7 @@ public class JavaNativeModule {
967 967
 	private StoredType loadFunctionalInterface(TypeVariableContext loadContext, Class<?> cls, AnnotatedElement[] parameters) {
968 968
 		Method functionalInterfaceMethod = getFunctionalInterfaceMethod(cls);
969 969
 		TypeVariableContext context = convertTypeParameters(cls);
970
+		//TODO: This breaks if the functional interface type appears in the method's signature
970 971
 		FunctionHeader header = getHeader(context, functionalInterfaceMethod);
971 972
 
972 973
 		Map<TypeParameter, StoredType> mapping = new HashMap<>();
@@ -1011,7 +1012,7 @@ public class JavaNativeModule {
1011 1012
 
1012 1013
 	private Method getFunctionalInterfaceMethod(Class<?> functionalInterface) {
1013 1014
 		for (Method method : functionalInterface.getDeclaredMethods()) {
1014
-			if (Modifier.isPublic(method.getModifiers()) && !method.isDefault())
1015
+			if (Modifier.isPublic(method.getModifiers()) && Modifier.isAbstract(method.getModifiers()) && !method.isDefault())
1015 1016
 				return method;
1016 1017
 		}
1017 1018
 

Loading…
Cancel
Save