Skip to content
asarih edited this page Jan 6, 2011 · 8 revisions

JRuby 1.2 was the first release of JRuby to officially include large portions of Ruby 1.9's feature set. There's still work to be done to get JRuby fully 1.9 compliant. There are two areas people really could pitch in: writing specs and helping with implementation.

Table of Contents

Writing Specs

The new features in Ruby 1.9 are very lightly specified. The RubySpec project has some specs, but there's a lot missing, especially in API areas like String M17N support.

If you're interested in contributing RubySpecs, check out http://www.rubyspec.org for information on how to help out.

Code conventions

Sometimes we just need to change some code of a method to get it 1.9 compliant. There are a few conventions we have to follow to adapt those methods.

  • We should avoid to check runtime mode by wrapping 1.9 methods around 1.8 ones:
  '''bad'''
  @JRubyMethod
  public IRubyObject collect(ThreadContext context, Block block) {
    if (block.isGiven()) {
      //do some cool
    }  else if (context.getRuntime().is1_9()) {
      // return Enumerator
    } else {
      // return Array
    }
  }
  '''good'''
  @JRubyMethod(name = "collect", compat = CompatVersion.RUBY1_8)
  public IRubyObject collect(ThreadContext context, Block block) {
    return block.isGiven() ? collectCommon(context, block) : newArray();
  }
  @JRubyMethod(name = "collect", compat = CompatVersion.RUBY1_9)
  public IRubyObject collect19(ThreadContext context, Block block) {
    return block.isGiven() ? collectCommon(context, block) : newEnumerator();
  }
  • When we have two methods for different modes, ie Ruby 1.8 and 1.9, we have to add the version number without punctuations, dashes or underscores as the suffix of the method name for 1.9 mode. I.e: collect and collect19.

Implementation

Here's the status of Ruby 1.9 feature support and work remaining:

Done

These are done but need more testing. Where noted, pieces are missing.

  • Array
    • missing encoding aware pack (JRUBY-3426)
    • sort should obey modified Fixnum and String class (but 1.9 still optimizes these case) (JRUBY-3427)
  • Hash
  • String
    • missing encoding aware % (JRUBY-3428), unpack (JRUBY-3429), crypt (JRUBY-3430)
    • missing encode/decode (via Encoding::Converter) (JRUBY-3431)
    • possible gotchas with to_sym
    • String#hash is not encoding aware yet (JRUBY-3432)
    • string constructions in multiple places in core should taint/set coderanges and encoding
  • Symbol
    • intern gotchas due to encoding information in symbols (needs to be done)
    • might loose encodings in some cases
  • Regexp
  • Encoding
  • Enumerable
  • Enumerator
    • missing next/rewind/with_index (fibers) (JRUBY-3435)
  • Complex
  • Rational
  • Numeric
  • Integer
  • Fixnum
  • Float
  • Math
  • Range
  • Struct
  • Kernel (mostly)
  • some (most?) of Object, Method, Module, Class
  • Thread?
  • Fiber?

Missing

These are entire areas that need to be worked on.

  • Encoding::Converter
  • Yielder/Generator
  • key Marshal changes
  • cli options
  • some RubyBignum changes
  • possible other changes in Numerics
  • changes in Dir/IO/File (some obvious things are done, like enumeratorize)
  • mathn (JRUBY-4008 JRUBY-4072)
  • encoding information in exception messages (now passed via java String)
  • BigDecimal changes ?
Clone this wiki locally