NativeExtensionApiNeeds

enebo edited this page May 24, 2012 · 1 revision
Clone this wiki locally

For JRuby.x we want to make native extensions work well against a stable API. Our current native extension API is not bad, but it hits our internals too much and the risk of breaking is too large with a major release. Additionally, a stable isolated API will also provide a better way to document how to make native extensions.

Use-cases

  • Defining modules/classes:
 RubyModule mHitimes = runtime.defineModule("Hitimes");
 RubyClass  cHitimesError  = mHitimes.defineClassUnder("Error", cStandardError, cStandardError.getAllocator());
  • Accessing constants:
 RubyClass errorClass = runtime.fastGetModule("Hitimes").fastGetClass( "Error" );
  • Defining methods:
 cHitimesInterval.defineAnnotatedMethods( HitimesInterval.class );

I suspect this usage is perfectly fine. Perhaps we should put an annotation for stable native extension APIs.