Exemple #1
0
extern "C" void
rb_define_alloc_func(VALUE klass, VALUE (*fn)(VALUE))
{
    JLocalEnv env;

    jobject allocator = env->NewObject(NativeObjectAllocator_class,
            getMethodID(env, NativeObjectAllocator_class, "<init>", "(J)V"),
            p2j((void *) fn));
    checkExceptions(env);

    env->CallVoidMethod(valueToObject(env, klass), RubyClass_setAllocator_method, allocator);
}
Exemple #2
0
extern "C" void
rb_exc_raise(VALUE exc)
{
    using namespace jruby;
    JLocalEnv env;

    jmethodID ctor = getCachedMethodID(env, RaiseException_class, "<init>", "(Lorg/jruby/RubyException;)V");
    jthrowable jException = (jthrowable) env->NewObject(RaiseException_class, ctor, valueToObject(env, exc));
    checkExceptions(env);

    throw JavaException(env, jException);
}