|
@@ -186,8 +186,23 @@ public class JavaNativeModule {
|
186
|
186
|
|
187
|
187
|
HighLevelDefinition definition = addClass(method.getDeclaringClass());
|
188
|
188
|
JavaClass jcls = JavaClass.fromInternalName(getInternalName(method.getDeclaringClass()), JavaClass.Kind.CLASS);
|
189
|
|
-
|
190
|
|
- //TypeVariableContext context = new TypeVariableContext();
|
|
189
|
+
|
|
190
|
+ if(method.isAnnotationPresent(ZenCodeType.Method.class)){
|
|
191
|
+ //The method should already have been loaded let's use that one.
|
|
192
|
+ final String methodDescriptor = org.objectweb.asm.Type.getMethodDescriptor(method);
|
|
193
|
+ final Optional<MethodMember> matchingMember = definition.members.stream()
|
|
194
|
+ .filter(m -> m instanceof MethodMember)
|
|
195
|
+ .map(m -> ((MethodMember) m))
|
|
196
|
+ .filter(m -> {
|
|
197
|
+ final JavaMethod methodInfo = compiled.optMethodInfo(m);
|
|
198
|
+ return methodInfo != null && methodDescriptor.equals(methodInfo.descriptor);
|
|
199
|
+ })
|
|
200
|
+ .findAny();
|
|
201
|
+
|
|
202
|
+ if(matchingMember.isPresent()) {
|
|
203
|
+ return matchingMember.get().ref(registry.getForDefinition(definition).stored());
|
|
204
|
+ }
|
|
205
|
+ }
|
191
|
206
|
MethodMember methodMember = new MethodMember(CodePosition.NATIVE, definition, Modifiers.PUBLIC | Modifiers.STATIC, method.getName(), getHeader(context, method), null);
|
192
|
207
|
definition.addMember(methodMember);
|
193
|
208
|
boolean isGenericResult = methodMember.header.getReturnType().isGeneric();
|