}
public static Object coerceJavaObjectToType(ThreadContext context, Object javaObject, Class target) {
if (javaObject != null && isDuckTypeConvertable(javaObject.getClass(), target)) {
RubyObject rubyObject = (RubyObject) javaObject;
if (!rubyObject.respondsTo("java_object")) {
return convertProcToInterface(context, rubyObject, target);
}
// can't be converted any more, return it
return javaObject;