headius/cloby — Issue #3: cannot store Clojure::Object in Ref?
Author: tlossen
Created: 2012-02-23 13:45:46+00:00
State: open

given the following code:

```ruby

require 'rubygems'
require 'cloby'

Ref = Java::clojure.lang.Ref

class Foo < Clojure::Object
attr_accessor :count

def initialize(count = 1)
@count = count
end

def to_s
"[Foo #{count}]"
end
end
```

i get this:

```
jruby-1.6.6 :002 > foo = dosync { Foo.new }
=> [Foo 1]
jruby-1.6.6 :003 > ref = Ref.new(foo)
Java::JavaLang::IndexOutOfBoundsException:
from clojure.lang.PersistentVector.arrayFor(PersistentVector.java:106)
from clojure.lang.PersistentVector.nth(PersistentVector.java:110)
from org.jruby.clojure.ClojureLibrary$ClojureObject.getVariable(ClojureLibrary.java:46)
from org.jruby.RubyClass$VariableAccessor.get(RubyClass.java:253)
from org.jruby.RubyBasicObject.variableTableFetch(RubyBasicObject.java:1346)
from org.jruby.RubyBasicObject.variableTableFastFetch(RubyBasicObject.java:1356)
from org.jruby.RubyBasicObject.fastGetInternalVariable(RubyBasicObject.java:1447)
from org.jruby.RubyBasicObject.dataGetStruct(RubyBasicObject.java:978)
from org.jruby.RubyBasicObject.getJavaClass(RubyBasicObject.java:660)
from org.jruby.java.dispatch.CallableSelector.classHashCode(CallableSelector.java:418)
from org.jruby.java.dispatch.CallableSelector.argsHashCode(CallableSelector.java:388)
from org.jruby.java.dispatch.CallableSelector.matchingCallableArityOne(CallableSelector.java:50)
from org.jruby.java.invokers.RubyToJavaInvoker.findCallableArityOne(RubyToJavaInvoker.java:226)
from org.jruby.java.invokers.ConstructorInvoker.call(ConstructorInvoker.java:88)
from org.jruby.java.invokers.ConstructorInvoker.call(ConstructorInvoker.java:178)
from org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:322)
... 138 levels...
from org.jruby.evaluator.ASTInterpreter.INTERPRET_METHOD(ASTInterpreter.java:75)
from org.jruby.internal.runtime.methods.InterpretedMethod.call(InterpretedMethod.java:190)
from org.jruby.internal.runtime.methods.DefaultMethod.call(DefaultMethod.java:199)
from org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:312)
from org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:169)
from Users.tim.$_dot_rvm.rubies.jruby_minus_1_dot_6_dot_6.bin.irb.__file__(/Users/tim/.rvm/rubies/jruby-1.6.6/bin/irb:17)
from Users.tim.$_dot_rvm.rubies.jruby_minus_1_dot_6_dot_6.bin.irb.load(/Users/tim/.rvm/rubies/jruby-1.6.6/bin/irb)
from org.jruby.Ruby.runScript(Ruby.java:695)
from org.jruby.Ruby.runScript(Ruby.java:688)
from org.jruby.Ruby.runNormally(Ruby.java:595)
from org.jruby.Ruby.runFromMain(Ruby.java:444)
from org.jruby.Main.doRunFromMain(Main.java:344)
from org.jruby.Main.internalRun(Main.java:256)
from org.jruby.Main.run(Main.java:222)
from org.jruby.Main.run(Main.java:206)
from org.jruby.Main.main(Main.java:186)
jruby-1.6.6 :004 >
```