public IRubyObject inspect() { StringBuilder result = new StringBuilder(); result.append(nameOnInspection()); Class<?>[] parameterTypes = getParameterTypes(); for (int i = 0; i < parameterTypes.length; i++) { result.append(parameterTypes[i].getName()); if (i < parameterTypes.length - 1) { result.append(','); } } result.append(")>"); return getRuntime().newString(result.toString()); }
public IRubyObject inspect() { StringBuilder result = new StringBuilder(); result.append(nameOnInspection()); Class<?>[] parameterTypes = getParameterTypes(); for (int i = 0; i < parameterTypes.length; i++) { result.append(parameterTypes[i].getName()); if (i < parameterTypes.length - 1) { result.append(','); } } result.append(")>"); return getRuntime().newString(result.toString()); }
@Override @JRubyMethod public RubyString inspect() { StringBuilder str = new StringBuilder(); str.append("#<"); str.append( getDeclaringClass().nameOnInspection() ); inspectParameterTypes(str, this); str.append('>'); return RubyString.newString(getRuntime(), str); }
@Override @JRubyMethod public RubyString inspect() { StringBuilder str = new StringBuilder(); str.append("#<"); str.append( getDeclaringClass().nameOnInspection() ); inspectParameterTypes(str, this); str.append('>'); return RubyString.newString(getRuntime(), str); }
@JRubyMethod public RubyFixnum arity() { return getRuntime().newFixnum(getArity()); }
@JRubyMethod public RubyFixnum arity() { return getRuntime().newFixnum(getParameterTypes().length); }
@JRubyMethod public RubyFixnum arity() { return getRuntime().newFixnum(getParameterTypes().length); }
@JRubyMethod public RubyFixnum arity() { return getRuntime().newFixnum(getArity()); }
public Object invoke(Object proxy, JavaProxyMethod method, Object[] nargs) throws Throwable { int length = nargs == null ? 0 : nargs.length; IRubyObject[] rubyArgs = new IRubyObject[length + 2]; rubyArgs[0] = JavaObject.wrap(recv.getRuntime(), proxy); rubyArgs[1] = method; for (int i = 0; i < length; i++) { rubyArgs[i + 2] = JavaUtil.convertJavaToRuby(getRuntime(), nargs[i]); } IRubyObject call_result = proc.call(getRuntime().getCurrentContext(), rubyArgs); Object converted_result = call_result.toJava(method.getReturnType()); return converted_result; }
public JavaObject newInstance(final IRubyObject self, Object[] args) throws RaiseException { final Ruby runtime = getRuntime(); JavaProxyInvocationHandler handler = new MethodInvocationHandler(runtime, self); try { return JavaObject.wrap(runtime, newInstance(args, handler)); } catch (Throwable ex) { throw mapInstantiationException(runtime, ex); } }
public JavaObject newInstance(final IRubyObject self, Object[] args) throws RaiseException { final Ruby runtime = getRuntime(); JavaProxyInvocationHandler handler = new MethodInvocationHandler(runtime, self); try { return JavaObject.wrap(runtime, newInstance(args, handler)); } catch (Throwable ex) { throw mapInstantiationException(runtime, ex); } }
public Object invoke(Object proxy, JavaProxyMethod method, Object[] nargs) throws Throwable { int length = nargs == null ? 0 : nargs.length; IRubyObject[] rubyArgs = new IRubyObject[length + 2]; rubyArgs[0] = JavaObject.wrap(recv.getRuntime(), proxy); rubyArgs[1] = method; for (int i = 0; i < length; i++) { rubyArgs[i + 2] = JavaUtil.convertJavaToRuby(getRuntime(), nargs[i]); } IRubyObject call_result = proc.call(getRuntime().getCurrentContext(), rubyArgs); Object converted_result = call_result.toJava(method.getReturnType()); return converted_result; }
public final JavaObject newInstance(final IRubyObject self, IRubyObject[] args) throws RaiseException { final Ruby runtime = getRuntime(); final Object[] javaArgsPlus1 = RubyToJavaInvoker.convertArguments(this, args, +1); JavaProxyInvocationHandler handler = new MethodInvocationHandler(runtime, self); try { return JavaObject.wrap(runtime, newInstanceImpl(javaArgsPlus1, handler)); } catch (Throwable ex) { throw mapInstantiationException(runtime, ex); } }
public final JavaObject newInstance(final IRubyObject self, IRubyObject arg0) throws RaiseException { final Ruby runtime = getRuntime(); final Object[] javaArgsPlus1 = RubyToJavaInvoker.convertArguments(this, arg0, +1); JavaProxyInvocationHandler handler = new MethodInvocationHandler(runtime, self); try { return JavaObject.wrap(runtime, newInstanceImpl(javaArgsPlus1, handler)); } catch (Throwable ex) { throw mapInstantiationException(runtime, ex); } }
public final JavaObject newInstance(final IRubyObject self, IRubyObject[] args) throws RaiseException { final Ruby runtime = getRuntime(); final Object[] javaArgsPlus1 = RubyToJavaInvoker.convertArguments(this, args, +1); JavaProxyInvocationHandler handler = new MethodInvocationHandler(runtime, self); try { return JavaObject.wrap(runtime, newInstanceImpl(javaArgsPlus1, handler)); } catch (Throwable ex) { throw mapInstantiationException(runtime, ex); } }
public final JavaObject newInstance(final IRubyObject self, IRubyObject arg0) throws RaiseException { final Ruby runtime = getRuntime(); final Object[] javaArgsPlus1 = RubyToJavaInvoker.convertArguments(this, arg0, +1); JavaProxyInvocationHandler handler = new MethodInvocationHandler(runtime, self); try { return JavaObject.wrap(runtime, newInstanceImpl(javaArgsPlus1, handler)); } catch (Throwable ex) { throw mapInstantiationException(runtime, ex); } }
@JRubyMethod(rest = true) public RubyObject new_instance2(IRubyObject[] args, Block unusedBlock) { final Ruby runtime = getRuntime(); Arity.checkArgumentCount(runtime, args, 2, 2); final IRubyObject self = args[0]; final Object[] convertedArgs = convertArguments((RubyArray) args[1]); // constructor arguments JavaProxyInvocationHandler handler = new MethodInvocationHandler(runtime, self); try { return JavaObject.wrap(runtime, newInstance(convertedArgs, handler)); } catch (Exception ex) { throw mapInstantiationException(runtime, ex); } }
@JRubyMethod(rest = true) public RubyObject new_instance2(IRubyObject[] args, Block unusedBlock) { final Ruby runtime = getRuntime(); Arity.checkArgumentCount(runtime, args, 2, 2); final IRubyObject self = args[0]; final Object[] convertedArgs = convertArguments((RubyArray) args[1]); // constructor arguments JavaProxyInvocationHandler handler = new MethodInvocationHandler(runtime, self); try { return JavaObject.wrap(runtime, newInstance(convertedArgs, handler)); } catch (Exception ex) { throw mapInstantiationException(runtime, ex); } }
@JRubyMethod(required = 1, optional = 1) public RubyObject new_instance(IRubyObject[] args, Block block) { final Ruby runtime = getRuntime(); final int last = Arity.checkArgumentCount(runtime, args, 1, 2) - 1; final RubyProc proc; // Is there a supplied proc arg or do we assume a block was supplied if (args[last] instanceof RubyProc) { proc = (RubyProc) args[last]; } else { proc = runtime.newProc(Block.Type.PROC, block); } final Object[] convertedArgs = convertArguments((RubyArray) args[0]); JavaProxyInvocationHandler handler = new ProcInvocationHandler(runtime, proc); try { return JavaObject.wrap(runtime, newInstance(convertedArgs, handler)); } catch (Exception e) { RaiseException ex = runtime.newArgumentError("Constructor invocation failed: " + e.getMessage()); ex.initCause(e); throw ex; } }
@JRubyMethod(required = 1, optional = 1) public RubyObject new_instance(IRubyObject[] args, Block block) { final Ruby runtime = getRuntime(); final int last = Arity.checkArgumentCount(runtime, args, 1, 2) - 1; final RubyProc proc; // Is there a supplied proc arg or do we assume a block was supplied if (args[last] instanceof RubyProc) { proc = (RubyProc) args[last]; } else { proc = runtime.newProc(Block.Type.PROC, block); } final Object[] convertedArgs = convertArguments((RubyArray) args[0]); JavaProxyInvocationHandler handler = new ProcInvocationHandler(runtime, proc); try { return JavaObject.wrap(runtime, newInstance(convertedArgs, handler)); } catch (Exception e) { RaiseException ex = runtime.newArgumentError("Constructor invocation failed: " + e.getMessage()); ex.initCause(e); throw ex; } }