@Deprecated // not used - should go away in >= 9.2 // not intended to be called directly by users (private) // OLD TODO from Ruby code: // This should be implemented in JavaClass.java, where we can // check for reserved Ruby names, conflicting methods, etc. @JRubyMethod(visibility = Visibility.PRIVATE) public static IRubyObject implement(ThreadContext context, IRubyObject self, IRubyObject clazz) { if ( ! (clazz instanceof RubyModule) ) { final Ruby runtime = context.runtime; throw runtime.newTypeError(clazz, runtime.getModule()); } final RubyModule targetModule = (RubyModule) clazz; final JavaClass javaClass = getJavaClassForInterface(self); final Method[] javaInstanceMethods = javaClass.javaClass().getMethods(); final DynamicMethod dummyMethodImpl = new DummyMethodImpl(targetModule); for (int i = 0; i < javaInstanceMethods.length; i++) { final Method javaMethod = javaInstanceMethods[i]; final String name = javaMethod.getName(); if ( targetModule.searchMethod(name).isUndefined() ) { targetModule.addMethod(name, dummyMethodImpl); // only those not-defined } } return context.nil; }
@Deprecated // not used - should go away in >= 9.2 // not intended to be called directly by users (private) // OLD TODO from Ruby code: // This should be implemented in JavaClass.java, where we can // check for reserved Ruby names, conflicting methods, etc. @JRubyMethod(visibility = Visibility.PRIVATE) public static IRubyObject implement(ThreadContext context, IRubyObject self, IRubyObject clazz) { if ( ! (clazz instanceof RubyModule) ) { final Ruby runtime = context.runtime; throw runtime.newTypeError(clazz, runtime.getModule()); } final RubyModule targetModule = (RubyModule) clazz; final JavaClass javaClass = getJavaClassForInterface(self); final Method[] javaInstanceMethods = javaClass.javaClass().getMethods(); final DynamicMethod dummyMethodImpl = new DummyMethodImpl(targetModule); for (int i = 0; i < javaInstanceMethods.length; i++) { final Method javaMethod = javaInstanceMethods[i]; final String name = javaMethod.getName(); if ( targetModule.searchMethod(name).isUndefined() ) { targetModule.addMethod(name, dummyMethodImpl); // only those not-defined } } return context.nil; }