Overriding methods in anonymous Java classes

I’m trying to consume a Java library in JRuby (Akka to be specific). It
requires that I do something like this:

https://gist.github.com/846707#file_atomic.java
new Atomic() {
public Void atomically() {
ref.set(refs.get() + 1);
return null;
}
}.execute();

I have tried implementing this in JRuby as follows:

https://gist.github.com/846707#file_jruby.rb
a = Class.new(Atomic) do
def init(ref)
@ref = ref
self
end
def atomically
ref.set(ref.get + 1)
end
end.new.init(refs).execute

But the JRuby example results in errors that suggest I am running
outside of a Transaction (i.e. I am not ACTUALLY executing my code in
the Atomic.atomically method.

Is that possible? Is there a better way to replicate the java code show
above?

Thanks!

-Joe

I thought of a more abstract way to phrase this question: Given the
following code:

Class.new do
def foo
raise ‘bar’
end
end.new.foo

How can i determine the java stacktrace for the third line (raise
‘bar’)?

thanks,

-joe

I answered my own question. You can disregard all this. The solution
was - of course:

Class.new do
def foo
Thread.currentThread().getStackTrace().each do |ste|
puts ste.to_s
end
end
end.new.foo