Added compatibility with JRuby