@Override public final boolean isVarArgs() { return constructor.isVarArgs(); }
@Override public final boolean isVarArgs() { return constructor.isVarArgs(); }
public ReflectiveConstructorExecutor(Constructor<?> ctor) { this.ctor = ctor; if (ctor.isVarArgs()) { Class<?>[] paramTypes = ctor.getParameterTypes(); this.varargsPosition = paramTypes.length - 1; } else { this.varargsPosition = null; } }
@Override public final boolean isVarArgs() { return constructor.isVarArgs(); }
@Override public boolean isApplicable() { return constructor != null && constructor.isVarArgs(); }
@Override public final boolean isVarArgs() { return constructor.isVarArgs(); }
public static boolean callIsVarArgs(Constructor thiz) { return thiz.isVarArgs(); }
private Executable(final Constructor<?> constructor) { parameterTypes = constructor.getParameterTypes(); isVarArgs = constructor.isVarArgs(); }
public ReflectiveConstructorExecutor(Constructor<?> ctor) { this.ctor = ctor; if (ctor.isVarArgs()) { Class<?>[] paramTypes = ctor.getParameterTypes(); this.varargsPosition = paramTypes.length - 1; } else { this.varargsPosition = null; } }
private Executable(final Constructor<?> constructor) { parameterTypes = constructor.getParameterTypes(); isVarArgs = constructor.isVarArgs(); }
public static boolean isVarargs(Member member) { if (member instanceof Method) { return ((Method) member).isVarArgs(); } if (member instanceof Constructor) { return ((Constructor) member).isVarArgs(); } throw new BugException(); }
@Override public TypedValue execute(EvaluationContext context, Object... arguments) throws AccessException { try { ReflectionHelper.convertArguments( context.getTypeConverter(), arguments, this.ctor, this.varargsPosition); if (this.ctor.isVarArgs()) { arguments = ReflectionHelper.setupArgumentsForVarargsInvocation( this.ctor.getParameterTypes(), arguments); } ReflectionUtils.makeAccessible(this.ctor); return new TypedValue(this.ctor.newInstance(arguments)); } catch (Exception ex) { throw new AccessException("Problem invoking constructor: " + this.ctor, ex); } }
public MetaConstructor(Constructor<?> constructor, MetaClass methodClass) { super(StringUtil.getUnqualifiedMemberName(constructor.getName())); this.constructorToString = constructor.toString(); this.metaClass = methodClass; returnType = Void.TYPE; paramTypes = Arrays.asList(constructor.getParameterTypes()); modifier = constructor.getModifiers(); isVarArgs = constructor.isVarArgs(); if (DEBUG_MEMBER_CREATION) { logger.debug("Created MetaConstructor: {}", toString()); } }
public MetaConstructor(Constructor<?> constructor, MetaClass methodClass) { super(StringUtil.getUnqualifiedMemberName(constructor.getName())); this.constructorToString = constructor.toString(); this.metaClass = methodClass; returnType = Void.TYPE; paramTypes = Arrays.asList(constructor.getParameterTypes()); modifier = constructor.getModifiers(); isVarArgs = constructor.isVarArgs(); if (DEBUG_MEMBER_CREATION) { logger.debug("Created MetaConstructor: {}", toString()); } }
static Constructor<?> findConstructor(Class<?> klass, Class<?>[] paramTypes, Object[] params) { if (paramTypes != null) { try { Constructor<?> c = klass.getConstructor(paramTypes); if (Modifier.isPublic(c.getModifiers())) { return c; } } catch (java.lang.NoSuchMethodException ex) { } throw new MethodNotFoundException("The constructor for class " + klass + " not found or accessible"); } int paramCount = (params == null)? 0: params.length; for (Constructor<?> c: klass.getConstructors()) { if (c.isVarArgs() || c.getParameterTypes().length==paramCount) { return c; } } throw new MethodNotFoundException("The constructor for class " + klass + " not found"); }
"No such accessible constructor on object: " + cls.getName()); if (ctor.isVarArgs()) { final Class<?>[] methodParameterTypes = ctor.getParameterTypes(); args = MethodUtils.getVarArgs(args, methodParameterTypes);
@Override public TypedValue execute(EvaluationContext context, Object... arguments) throws AccessException { try { ReflectionHelper.convertArguments( context.getTypeConverter(), arguments, this.ctor, this.varargsPosition); if (this.ctor.isVarArgs()) { arguments = ReflectionHelper.setupArgumentsForVarargsInvocation( this.ctor.getParameterTypes(), arguments); } ReflectionUtils.makeAccessible(this.ctor); return new TypedValue(this.ctor.newInstance(arguments)); } catch (Exception ex) { throw new AccessException("Problem invoking constructor: " + this.ctor, ex); } }
static Object invokeConstructor(ELContext context, Constructor<?> c, Object[] params) { Class[] parameterTypes = c.getParameterTypes(); Object[] parameters = null; if (parameterTypes.length > 0) { if (c.isVarArgs()) { // TODO } else { parameters = new Object[parameterTypes.length]; for (int i = 0; i < parameterTypes.length; i++) { parameters[i] = context.convertToType(params[i], parameterTypes[i]); } } } try { return c.newInstance(parameters); } catch (IllegalAccessException iae) { throw new ELException(iae); } catch (InvocationTargetException ite) { throw new ELException(ite.getCause()); } catch (InstantiationException ie) { throw new ELException(ie.getCause()); } }
Constructor<?> ctor = (Constructor<?>) member; paramDescriptors = CodeFlow.toDescriptors(ctor.getParameterTypes()); isVarargs = ctor.isVarArgs();
if (ctor.isVarArgs() && argumentTypes.size() >= paramTypes.length - 1) {