Browse Source

JavaNativeModule: Don't add methods whose signature was overriden to child class

Background: Javac creates an ACC_BRIDGE method to deal with the signature change (either a covariant parameter or contravariant return type change).
Hence there are two declared methods, one that is the old one, one that is new. For Signatures where only the return type changed this caused both to be registered and an ambiguity later where ZC could not determine which to choose
kindlich 4 years ago
parent
commit
8773d157ac
No known key found for this signature in database

+ 11
- 0
JavaIntegration/src/main/java/org/openzen/zencode/java/JavaNativeModule.java View File

385
 		for (Method method : cls.getDeclaredMethods()) {
385
 		for (Method method : cls.getDeclaredMethods()) {
386
 			ZenCodeType.Method methodAnnotation = method.getAnnotation(ZenCodeType.Method.class);
386
 			ZenCodeType.Method methodAnnotation = method.getAnnotation(ZenCodeType.Method.class);
387
 			if (methodAnnotation != null) {
387
 			if (methodAnnotation != null) {
388
+
389
+				//Simple check if the method was overwritten
390
+				try {
391
+					if(!cls.getDeclaredMethod(method.getName(), method.getParameterTypes()).equals(method)) {
392
+						continue;
393
+					}
394
+				} catch (NoSuchMethodException e) {
395
+					e.printStackTrace();
396
+					continue;
397
+				}
398
+
388
 				MethodMember member = asMethod(context, definition, method, methodAnnotation);
399
 				MethodMember member = asMethod(context, definition, method, methodAnnotation);
389
 				definition.addMember(member);
400
 				definition.addMember(member);
390
 				compiled.setMethodInfo(member, getMethod(javaClass, method, member.header.getReturnType()));
401
 				compiled.setMethodInfo(member, getMethod(javaClass, method, member.header.getReturnType()));

Loading…
Cancel
Save