public static Object newProxyInstance(Ruby runtime, Class superClass, Class[] interfaces, Class[] constructorParameters, Object[] constructorArgs, JavaProxyInvocationHandler handler) throws IllegalArgumentException, InstantiationException, IllegalAccessException, InvocationTargetException, SecurityException, NoSuchMethodException { JavaProxyClass proxyClass = newProxyClass(runtime, superClass, interfaces); JavaProxyConstructor constructor = proxyClass.getConstructor( constructorParameters == null ? EMPTY_CLASS_ARRAY : constructorParameters ); return constructor.newInstance(constructorArgs, handler); }
public static Object newProxyInstance(Ruby runtime, Class superClass, Class[] interfaces, Class[] constructorParameters, Object[] constructorArgs, JavaProxyInvocationHandler handler) throws IllegalArgumentException, InstantiationException, IllegalAccessException, InvocationTargetException, SecurityException, NoSuchMethodException { JavaProxyClass jpc = getProxyClass(runtime, superClass, interfaces); JavaProxyConstructor cons = jpc.getConstructor(constructorParameters == null ? new Class[0] : constructorParameters); return cons.newInstance(constructorArgs, handler); }
public static Object newProxyInstance(Ruby runtime, Class superClass, Class[] interfaces, Class[] constructorParameters, Object[] constructorArgs, JavaProxyInvocationHandler handler) throws IllegalArgumentException, InstantiationException, IllegalAccessException, InvocationTargetException, SecurityException, NoSuchMethodException { JavaProxyClass jpc = getProxyClass(runtime, superClass, interfaces); JavaProxyConstructor cons = jpc.getConstructor(constructorParameters == null ? new Class[0] : constructorParameters); return cons.newInstance(constructorArgs, handler); }
public static Object newProxyInstance(Ruby runtime, Class superClass, Class[] interfaces, Class[] constructorParameters, Object[] constructorArgs, JavaProxyInvocationHandler handler) throws IllegalArgumentException, InstantiationException, IllegalAccessException, InvocationTargetException, SecurityException, NoSuchMethodException { JavaProxyClass proxyClass = newProxyClass(runtime, superClass, interfaces); JavaProxyConstructor constructor = proxyClass.getConstructor( constructorParameters == null ? EMPTY_CLASS_ARRAY : constructorParameters ); return constructor.newInstance(constructorArgs, handler); }
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); } }
@Override public final IRubyObject call(ThreadContext context, IRubyObject self, RubyModule clazz, String name, IRubyObject arg0, Block block) { final JavaProxyConstructor[] constructors = getProxyClass(self).getConstructors(); final JavaProxyConstructor matching; switch (constructors.length) { case 1: matching = matchConstructor0ArityOne(context, constructors, arg0); break; default: matching = matchConstructorArityOne(context, constructors, arg0); } JavaObject newObject = matching.newInstance(self, arg0); return JavaUtilities.set_java_object(self, self, newObject); }
@Override public final IRubyObject call(final ThreadContext context, IRubyObject self, RubyModule clazz, String name, IRubyObject[] args) { final int arity = args.length; final JavaProxyConstructor[] constructors = getProxyClass(self).getConstructors(); final JavaProxyConstructor matching; switch (constructors.length) { case 1: matching = matchConstructor0(context, constructors, arity, args); break; default: matching = matchConstructor(context, constructors, arity, args); } JavaObject newObject = matching.newInstance(self, args); return JavaUtilities.set_java_object(self, self, newObject); }
@Override public final IRubyObject call(ThreadContext context, IRubyObject self, RubyModule clazz, String name, IRubyObject arg0, Block block) { final JavaProxyConstructor[] constructors = getProxyClass(self).getConstructors(); final JavaProxyConstructor matching; switch (constructors.length) { case 1: matching = matchConstructor0ArityOne(context, constructors, arg0); break; default: matching = matchConstructorArityOne(context, constructors, arg0); } JavaObject newObject = matching.newInstance(self, arg0); return JavaUtilities.set_java_object(self, self, newObject); }
@Override public final IRubyObject call(final ThreadContext context, IRubyObject self, RubyModule clazz, String name, IRubyObject[] args) { final int arity = args.length; final JavaProxyConstructor[] constructors = getProxyClass(self).getConstructors(); final JavaProxyConstructor matching; switch (constructors.length) { case 1: matching = matchConstructor0(context, constructors, arity, args); break; default: matching = matchConstructor(context, constructors, arity, args); } JavaObject newObject = matching.newInstance(self, args); return JavaUtilities.set_java_object(self, self, newObject); }
return JavaObject.wrap(getRuntime(), newInstance(args, handler)); } catch (Throwable t) { while (t.getCause() != null) {
return JavaObject.wrap(getRuntime(), newInstance(args, handler)); } catch (Throwable t) { while (t.getCause() != null) {
@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; } }
JavaObject newObject = matching.newInstance(self, newArgs); return JavaUtilities.set_java_object(self, self, newObject);
JavaObject newObject = matching.newInstance(self, newArgs); return JavaUtilities.set_java_object(self, self, newObject);
return JavaObject.wrap(getRuntime(), newInstance(converted, handler)); } catch (Exception e) { RaiseException ex = getRuntime().newArgumentError(
result = newInstance(converted, handler); } catch (Exception e) { RaiseException ex = getRuntime().newArgumentError(