Given a spout definition, return a Storm spout implementation by attempting to find a matching constructor
in the given spout class. Perform list to array conversion as necessary.
518934
private static IRichSpout buildSpout(SpoutDef def, ExecutionContext context) throws ClassNotFoundException,
            IllegalAccessException, InstantiationException, NoSuchMethodException, InvocationTargetException {
        return (IRichSpout)buildObject(def, context);
    }
490245
public ConstructorFilter build() {
        if(filters.isEmpty()) {
            throw new IllegalStateException("No filter specified.");
        }
        if(filters.size() == 1) {
            return filters.get(0);
        }
        ConstructorFilter[] methodFilters = new ConstructorFilter[filters.size()];
        filters.toArray(methodFilters);
        return new ConstructorFilterList(methodFilters);
    }
197837
private static Object[] makeStubForConstructor(final Class<?>[] constructorParamTypes) {
    if (constructorParamTypes.length == 0) {
      return EMPTY_OBJECT_ARRAY;
    }
    final Object[] result = new Object[constructorParamTypes.length];
    for (int i = 0; i < constructorParamTypes.length; i++) {
      final Class<?> arg = constructorParamTypes[i];
      final Object obj;
      if (arg.isArray()) {
        obj = null;
      } else {
        if (arg == byte.class) {
          obj = (byte) 0;
        } else if (arg == char.class) {
          obj = 'a';
        } else if (arg == short.class) {
          obj = (short) 0;
        } else if (arg == boolean.class) {
          obj = Boolean.FALSE;
        } else if (arg == int.class) {
          obj = 0;
        } else if (arg == long.class) {
          obj = 0L;
        } else if (arg == double.class) {
          obj = 0.0d;
        } else if (arg == float.class) {
          obj = 0.0f;
        } else {
          obj = null;
        }
      }
      result[i] = obj;
    }
    return result;
  }
696973
public static <T, K, V> Func1<Iterable<T>, SolidMap<K, V>> toSolidMap(final Func1<T, K> keyExtractor, final Func1<T, V> valueExtractor) {
        return new Func1<Iterable<T>, SolidMap<K, V>>() {
            @Override
            public SolidMap<K, V> call(final Iterable<T> iterable) {
                return new SolidMap<>(
                    stream(iterable).map(new Func1<T, Pair<K, V>>() {
                        @Override
                        public Pair<K, V> call(T value) {
                            return new Pair<>(keyExtractor.call(value), valueExtractor.call(value));
                        }
                    }));
            }
        };
    }
1280415
public static Constructor<?>[] constructorsDeclaredIn(final Class<?> cls, final Class<?>... additionalClasses) {
        if (cls == null) {
            throw new IllegalArgumentException("You need to supply at least one class.");
        }
        Set<Constructor<?>> constructors = new HashSet<Constructor<?>>();
        constructors.addAll(asList(WhiteboxImpl.getAllConstructors(cls)));
        for (Class<?> klass : additionalClasses) {
            constructors.addAll(asList(WhiteboxImpl.getAllConstructors(klass)));
        }
        return constructors.toArray(new Constructor[constructors.size()]);
    }
941710
protected MethodNode checkGroovyStyleConstructor(final ClassNode node, final ClassNode[] arguments, final ASTNode source) {
        if (node.equals(ClassHelper.OBJECT_TYPE) || node.equals(ClassHelper.DYNAMIC_TYPE)) {
            // in that case, we are facing a list constructor assigned to a def or object
            return null;
        }
        List<ConstructorNode> constructors = node.getDeclaredConstructors();
        if (constructors.isEmpty() && arguments.length == 0) {
            return null;
        }
        List<MethodNode> constructorList = findMethod(node, "<init>", arguments);
        if (constructorList.isEmpty()) {
            if (isBeingCompiled(node) && arguments.length == 1 && LINKEDHASHMAP_CLASSNODE.equals(arguments[0])) {
                // there will be a default hash map constructor added later
                ConstructorNode cn = new ConstructorNode(Opcodes.ACC_PUBLIC, new Parameter[]{
                        new Parameter(LINKEDHASHMAP_CLASSNODE, "args")
                }, ClassNode.EMPTY_ARRAY, EmptyStatement.INSTANCE);
                return cn;
            } else {
                addStaticTypeError("No matching constructor found: " + node + toMethodParametersString("<init>", arguments), source);
                return null;
            }
        } else if (constructorList.size() > 1) {
            addStaticTypeError("Ambiguous constructor call " + node + toMethodParametersString("<init>", arguments), source);
            return null;
        }
        return constructorList.get(0);
    }
139411
public static MultiMatcher<ClassTree, MethodTree> constructor(
      MatchType matchType, Matcher<MethodTree> constructorMatcher) {
    return new ConstructorOfClass(matchType, constructorMatcher);
  }
1042457
public ConstructorDoc[] constructors(boolean filter) {
        Names names = tsym.name.table.names;
        List<ConstructorDocImpl> constructors = List.nil();
        for (Symbol sym : tsym.members().getSymbols(NON_RECURSIVE)) {
            if (sym != null &&
                sym.kind == MTH && sym.name == names.init) {
                MethodSymbol s = (MethodSymbol)sym;
                if (!filter || env.shouldDocument(s)) {
                    constructors = constructors.prepend(env.getConstructorDoc(s));
                }
            }
        }
        //### Cache constructors here?
        return constructors.toArray(new ConstructorDocImpl[constructors.length()]);
    }
617540
private LocalVariableDefinition constructStructInstance(MethodDefinition read, Map<Short, LocalVariableDefinition> structData)
    {
        LocalVariableDefinition instance = read.addLocalVariable(structType, "instance");

        // create the new instance (or builder)
        if (metadata.getBuilderClass() == null) {
            read.newObject(structType).dup();
        }
        else {
            read.newObject(metadata.getBuilderClass()).dup();
        }

        // invoke constructor
        ThriftConstructorInjection constructor = metadata.getConstructorInjection().get();
        // push parameters on stack
        for (ThriftParameterInjection parameter : constructor.getParameters()) {
            read.loadVariable(structData.get(parameter.getId()));
        }
        // invoke constructor
        read.invokeConstructor(constructor.getConstructor())
                .storeVariable(instance);
        return instance;
    }
749418
public static ConstructorInstance getConstructorInstance(Class clazz, Object[] args) throws NoSuchMethodException {
	ConstructorInstance ci = getConstructorInstance(clazz, args, null);
	if (ci != null) return ci;
	throw new NoSuchMethodException("No matching Constructor for " + clazz.getName() + "(" + getDspMethods(getClasses(args)) + ") found");
    }
290424
public static ConstructorNode findConstructor(ClassNode classNode,Parameter[] constructorParams) {
        List<ConstructorNode> declaredConstructors = classNode.getDeclaredConstructors();
        for (ConstructorNode declaredConstructor : declaredConstructors) {
            if (parametersEqual(constructorParams, declaredConstructor.getParameters())) {
                return declaredConstructor;
            }
        }
        return null;
    }
135812
@Nonnull
	public <V1 extends T1, V2 extends T2> LBiObjDblConsumerBuilder<T1, T2> casesOf(Class<V1> argC1, Class<V2> argC2, Consumer<LBiObjDblConsumerBuilder<V1, V2>> pcpConsumer) {
		PartialCase.The pc = partialCaseFactoryMethod((a1, a2, a3) -> (argC1 == null || argC1.isInstance(a1)) && (argC2 == null || argC2.isInstance(a2)));

		pc.specifySubCases((Consumer) pcpConsumer);
		return self();
	}
1253806
private static Class<?> findClass(String className, ClassLoader classLoader) throws ClassNotFoundException {
        try {
            Class<?> spiClass;
            if (classLoader == null) {
                spiClass = Class.forName(className);
            } else {
                try {
                    spiClass = Class.forName(className, false, classLoader);
                } catch (ClassNotFoundException ex) {
                    spiClass = Class.forName(className);
                }
            }
            return spiClass;
        } catch (ClassNotFoundException x) {
            throw x;
        } catch (Exception x) {
            throw new ClassNotFoundException("Factory " + className + " could not be instantiated: " + x, x);
        }
    }
601455
static <T> Pair<Boolean, T> constructViaConstructor(Class<T> type, String fromValue) {

		Constructor[] allConstructors = type.getDeclaredConstructors();
		for (Constructor ctor : allConstructors) {

			Class<?>[] pType = ctor.getParameterTypes();
			if (pType.length == 1) { // ok ... match ... might be possible to use

				try {

					for (Class primitive : SIMPLE_TYPE) {

						if (pType[0].isAssignableFrom(primitive)) {

							Object value = stringToPrimitiveType(fromValue, primitive);
							return new Pair(true, ctor.newInstance(value));
						}
					}
				}
				catch (IllegalAccessException | InstantiationException | InvocationTargetException e) {
					//continue; // try next one ... if any
					log.warn("Failed constructing: " + ctor, e);
				}
			}
		}

		return new Pair<>(false, null);
	}
304614
<T extends JCTree> List<Type> classEnter(List<T> trees, Env<AttrContext> env) {
        ListBuffer<Type> ts = new ListBuffer<>();
        for (List<T> l = trees; l.nonEmpty(); l = l.tail) {
            Type t = classEnter(l.head, env);
            if (t != null)
                ts.append(t);
        }
        return ts.toList();
    }
946121
public static <T> Constructor<T> getConstructor(Class<T> cls, Class... params) {
        try {
            return cls.getConstructor(params);
        } catch (Exception e) {
            throw new ClientException(e);
        }
    }
1039249
def parameter_constructor(cls, loader, node):
        
        value = loader.construct_scalar(node)

        if isinstance(value, str):
            if '=' in value:
                (varname, varvalue) = Parser.parse_equality(value)
                return cls(varname, varvalue)
            else:
                return cls(value)
        else:
            return cls(value)