Skip to content

Commit

Permalink
Fix for JRUBY-3112: Some Ruby instances are not roundtripping from Ru…
Browse files Browse the repository at this point in the history
…by to Java and back

Patch submitted by Michael S. Allman.

git-svn-id: http://svn.codehaus.org/jruby/trunk/jruby@8254 961051c9-f516-0410-bf72-c9f7e237a7b7
  • Loading branch information
headius committed Dec 3, 2008
1 parent 966baa2 commit e4f6078
Show file tree
Hide file tree
Showing 4 changed files with 1,255 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/org/jruby/javasupport/JavaUtil.java
Expand Up @@ -62,6 +62,8 @@
import org.jruby.internal.runtime.methods.CallConfiguration;
import org.jruby.internal.runtime.methods.DynamicMethod;
import org.jruby.java.proxies.JavaProxy;
import org.jruby.javasupport.proxy.InternalJavaProxy;
import org.jruby.javasupport.proxy.JavaProxyInvocationHandler;
import org.jruby.javasupport.util.RuntimeHelpers;
import org.jruby.runtime.Block;
import org.jruby.runtime.ClassIndex;
Expand Down Expand Up @@ -744,6 +746,15 @@ public static IRubyObject convertJavaToUsableRubyObject(Ruby runtime, Object obj
return (IRubyObject)object;
}

if (object instanceof InternalJavaProxy) {
InternalJavaProxy internalJavaProxy = (InternalJavaProxy) object;
IRubyObject orig = internalJavaProxy.___getInvocationHandler().getOrig();

if (orig != null) {
return orig;
}
}

JavaConverter converter = JAVA_CONVERTERS.get(object.getClass());
if (converter == null || converter == JAVA_DEFAULT_CONVERTER) {
return Java.getInstance(runtime, object);
Expand Down

0 comments on commit e4f6078

Please sign in to comment.