return lookupMethod(receiverClass, selector);
}
public MethodHandle lookupMethod(Class receiverClass, String selector) {
Reference reference = Reference.factory.value_(lookupStart);
AbstractMethodMapping mapping = ImageBootstrapper.systemMapping
.superMethodMappingFor_methodName_(reference, selector);
if (mapping == null) {
if (selector.equals("doesNotUnderstand_"))
throw new RuntimeException("Can't find DNU method");
return wrapDNUHandle(lookupMethod(receiverClass,
"doesNotUnderstand_"));
}
MethodHandle methodHandle;
try {
Method method = MethodTools.searchForMethod(
mapping.definingClass(), selector, type.parameterArray(),
true);
if (method != null) {
return mapping.methodHandle().asType(type);
}
methodHandle = lookup.findSpecial(mapping.definingClass(),
selector, type.dropParameterTypes(0, 1), lookup.lookupClass());
} catch (NoSuchMethodException | IllegalAccessException r) {
try {
methodHandle = lookup.findStatic(mapping.definingClass(),
selector, type);
} catch (NoSuchMethodException | IllegalAccessException e) {
throw new RuntimeException(e);
}