final void setupNativeCall() { // if it's not overloaded, set up a NativeCall if (javaCallable != null) { // no constructor support yet if (javaCallable instanceof org.jruby.javasupport.JavaMethod) { setNativeCallIfPublic(((org.jruby.javasupport.JavaMethod) javaCallable).getValue()); } } else { // use the lowest-arity non-overload for ( int i = 0; i< javaCallables.length; i++ ) { final JavaCallable[] callablesForArity = javaCallables[i]; if ( callablesForArity == null || callablesForArity.length != 1 ) continue; if ( callablesForArity[0] instanceof org.jruby.javasupport.JavaMethod ) { final Method method = ((org.jruby.javasupport.JavaMethod) callablesForArity[0]).getValue(); if ( setNativeCallIfPublic( method ) ) break; } } } }
final void setupNativeCall() { // if it's not overloaded, set up a NativeCall if (javaCallable != null) { // no constructor support yet if (javaCallable instanceof org.jruby.javasupport.JavaMethod) { setNativeCallIfPublic(((org.jruby.javasupport.JavaMethod) javaCallable).getValue()); } } else { // use the lowest-arity non-overload for ( int i = 0; i< javaCallables.length; i++ ) { final JavaCallable[] callablesForArity = javaCallables[i]; if ( callablesForArity == null || callablesForArity.length != 1 ) continue; if ( callablesForArity[0] instanceof org.jruby.javasupport.JavaMethod ) { final Method method = ((org.jruby.javasupport.JavaMethod) callablesForArity[0]).getValue(); if ( setNativeCallIfPublic( method ) ) break; } } } }
RaiseException newErrorDueArgumentTypeMismatch(final IRubyObject receiver, final T[] methods, IRubyObject... args) { final Class[] argTypes = new Class[args.length]; for (int i = 0; i < args.length; i++) { argTypes[i] = getClass( args[i] ); } final StringBuilder error = new StringBuilder(64); error.append("no "); if ( isConstructor() ) error.append("constructor"); else { org.jruby.javasupport.JavaMethod method = (org.jruby.javasupport.JavaMethod) methods[0]; error.append("method '").append( method.getValue().getName() ).append("'"); } error.append(" for arguments "); prettyParams(error, argTypes); error.append(" on ").append( formatReceiver(receiver) ); if ( methods.length > 1 ) { error.append("\n available overloads:"); for (ParameterTypes method : methods) { Class<?>[] paramTypes = method.getParameterTypes(); error.append("\n "); prettyParams( error, paramTypes ); } } // TODO should have been ArgumentError - might break users to refactor at this point return runtime.newNameError(error.toString(), null); }
RaiseException newErrorDueArgumentTypeMismatch(final IRubyObject receiver, final T[] methods, IRubyObject... args) { final Class[] argTypes = new Class[args.length]; for (int i = 0; i < args.length; i++) { argTypes[i] = getClass( args[i] ); } final StringBuilder error = new StringBuilder(64); error.append("no "); if ( isConstructor() ) error.append("constructor"); else { org.jruby.javasupport.JavaMethod method = (org.jruby.javasupport.JavaMethod) methods[0]; error.append("method '").append( method.getValue().getName() ).append("'"); } error.append(" for arguments "); prettyParams(error, argTypes); error.append(" on ").append( formatReceiver(receiver) ); if ( methods.length > 1 ) { error.append("\n available overloads:"); for (ParameterTypes method : methods) { Class<?>[] paramTypes = method.getParameterTypes(); error.append("\n "); prettyParams( error, paramTypes ); } } // TODO should have been ArgumentError - might break users to refactor at this point return runtime.newNameError(error.toString(), null); }