canonical method to check for jruby

View: New views
2 Messages — Rating Filter:   Alert me  

canonical method to check for jruby

by matt mcknight :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I have:

if RUBY_PLATFORM =~ /java/
    #do jruby specific thing here
else
    #do mri specific thing here
end

in my code in a couple of places, so that it can run on mongrel or Glassfish.  I was wondering if that's the best way to do it?

-Matt McKnight-
LMN Solutions, Inc.
matt.mcknight@...
www.lmnsolutions.com

Re: canonical method to check for jruby

by Vladimir Sizikov-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Matthew,

Yes, this is one of the most wildly used methods, but it has one
drawback -- it's not guaranteed to work forever, since one day the
RUBY_PLATFORM value might change (unlikely, but possible). Not to
mention that  any other java-based implementation of Ruby might also
satisfy that check.

The canonical and 100% reliable way to detect JRuby is:
if defined? JRUBY_VERSION

Thanks,
  --Vladimir

On Thu, Jul 24, 2008 at 7:23 PM, Matthew McKnight
<matt.mcknight@...> wrote:

> I have:
>
> if RUBY_PLATFORM =~ /java/
>     #do jruby specific thing here
> else
>     #do mri specific thing here
> end
>
> in my code in a couple of places, so that it can run on mongrel or
> Glassfish.  I was wondering if that's the best way to do it?
>
> -Matt McKnight-
> LMN Solutions, Inc.
> matt.mcknight@...
> www.lmnsolutions.com

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


LightInTheBox - Buy quality products at wholesale price