Skip to content

Commit

Permalink
Fix for JRUBY-702: no, we can't marshal Java objects, but we should p…
Browse files Browse the repository at this point in the history
…resent a reasonable error rather than blow stack.

git-svn-id: http://svn.codehaus.org/jruby/trunk/jruby@3720 961051c9-f516-0410-bf72-c9f7e237a7b7
  • Loading branch information
headius committed May 22, 2007
1 parent b31b395 commit 6019092
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/org/jruby/javasupport/JavaObject.java
Expand Up @@ -42,6 +42,7 @@
import org.jruby.runtime.Block;
import org.jruby.runtime.CallbackFactory;
import org.jruby.runtime.ObjectAllocator;
import org.jruby.runtime.ObjectMarshal;
import org.jruby.runtime.builtin.IRubyObject;

/**
Expand Down Expand Up @@ -99,6 +100,8 @@ public static RubyClass createJavaObjectClass(Ruby runtime, RubyModule javaModul

result.getMetaClass().undefineMethod("new");
result.getMetaClass().undefineMethod("allocate");

result.setMarshal(ObjectMarshal.NOT_MARSHALABLE_MARSHAL);

return result;
}
Expand Down
4 changes: 4 additions & 0 deletions test/test_higher_javasupport.rb
Expand Up @@ -632,5 +632,9 @@ def test_lowercase_colon_package_syntax
ci.addInterface1(LCTestB.new)
ci.addInterface2(LCTestB.new)
end

def test_marsal_java_object_fails
assert_raises(TypeError) { Marshal.dump(java::lang::Object.new) }
end
end

0 comments on commit 6019092

Please sign in to comment.