Experiments with ruby-processing (processing-2.2.1) and JRubyArt for processing-3.0

Monday 17 August 2015

Java-8-lambda and jruby extensions

Should we be getting excited about java-8-lambda for jruby extensions (working in NetBeans I got this suggestion when updating source from java-7 to java-8 having listened to Charlies talk at JVMLS2015 perhaps we should?
// Java seven

public static void createVec2(final Ruby runtime) {
    RubyClass vec2Cls = runtime.defineClass("Vec2D", runtime.getObject(), new ObjectAllocator() {
            @Override
            public IRubyObject allocate(Ruby runtime, RubyClass rubyClass) {
                return new Vec2(runtime, rubyClass);
            }
    });
    vec2Cls.defineAnnotatedMethods(Vec2.class);

}

// Java eight
public static void createVec2(final Ruby runtime) {
    RubyClass vec2Cls = runtime.defineClass("Vec2D", runtime.getObject(), (Ruby runtime1, RubyClass rubyClass) -> new Vec2(runtime1, rubyClass));
    vec2Cls.defineAnnotatedMethods(Vec2.class);
}
Update 22 August 2015 just released JRubyArt 0.5.0 featuring java8lambda in production...

No comments:

Post a Comment

Followers

About Me

My photo
I have developed JRubyArt and propane new versions of ruby-processing for JRuby-9.1.5.0 and processing-3.2.2