diff --git a/libraryInterface/Common/src/java/lang/Class.java b/libraryInterface/Common/src/java/lang/Class.java index 8c10785c3..d6c9d1863 100644 --- a/libraryInterface/Common/src/java/lang/Class.java +++ b/libraryInterface/Common/src/java/lang/Class.java @@ -877,7 +877,7 @@ public T newInstance() throws IllegalAccessException, InstantiationException, @Pure private RVMMethod getMethodInternal1(Atom aName, Class... parameterTypes) { RVMMethod answer = null; - for (RVMClass current = type.asClass(); current != null; current = current.getSuperClass()) { + for (RVMClass current = type.asClass(); current != null && answer == null; current = current.getSuperClass()) { RVMMethod[] methods = current.getDeclaredMethods(); for (RVMMethod meth : methods) { if (meth.getName() == aName && meth.isPublic() && @@ -886,6 +886,8 @@ private RVMMethod getMethodInternal1(Atom aName, Class... parameterTypes) { answer = meth; } else { RVMMethod m2 = meth; + // make answer have the weakest return type of the methods declared + // in this class if (answer.getReturnType().resolve().isAssignableFrom(m2.getReturnType().resolve())) { answer = m2; }