jdantonio/concurrent-ruby — pull request #24 by jdantonio (2014-03-01 14:41:15+00:00)
Title: Updated JRuby optimizations in AtomicLong.

@chrisseaton I wanted to understand Java integration in JRuby better so I started playing with AtomicLong. The `if defined? java...` statement didn't work as expected on my machine (OS X 10.9.2, rvm 1.25.18, jruby 1.7.11 (1.9.3p392), ruby 2.1.0p0). These updates work on my machine with the aforementioned versions of Ruby and the new test passes. Please take a look and let me know if this seems right.

I don't know why `if defined? java.util` works but `if defined? java.util.concurrent.atomic.AtomicLong` does not. My best guess is late binding. To experiment I put `puts java.util.concurrent.atomic.AtomicLong` in atomic.rb just prior to the `if defined? ...` statement and that caused `if defined? java.util.concurrent.atomic.AtomicLong` to work, as thought `puts` forced bindings all the way down to `AtomicLong`.

I'm working off the assumption that if `java.util` is defined then `java.util.concurrent.atomic.AtomicLong` will *also* be defined. I'm not familiar enough with JRuby to know if this is a valid assumption.