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
 	private StoredType loadFunctionalInterface(TypeVariableContext loadContext, Class<?> cls, AnnotatedElement[] parameters) {
967
 	private StoredType loadFunctionalInterface(TypeVariableContext loadContext, Class<?> cls, AnnotatedElement[] parameters) {
968
 		Method functionalInterfaceMethod = getFunctionalInterfaceMethod(cls);
968
 		Method functionalInterfaceMethod = getFunctionalInterfaceMethod(cls);
969
 		TypeVariableContext context = convertTypeParameters(cls);
969
 		TypeVariableContext context = convertTypeParameters(cls);
970
+		//TODO: This breaks if the functional interface type appears in the method's signature
970
 		FunctionHeader header = getHeader(context, functionalInterfaceMethod);
971
 		FunctionHeader header = getHeader(context, functionalInterfaceMethod);
971
 
972
 
972
 		Map<TypeParameter, StoredType> mapping = new HashMap<>();
973
 		Map<TypeParameter, StoredType> mapping = new HashMap<>();
1011
 
1012
 
1012
 	private Method getFunctionalInterfaceMethod(Class<?> functionalInterface) {
1013
 	private Method getFunctionalInterfaceMethod(Class<?> functionalInterface) {
1013
 		for (Method method : functionalInterface.getDeclaredMethods()) {
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
 				return method;
1016
 				return method;
1016
 		}
1017
 		}
1017
 
1018
 

Loading…
Cancel
Save