/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *      https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.apache.commons.lang3.reflect;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.util.Objects;

import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.ClassUtils;

/**
 * Utility reflection methods focused on constructors, modeled after {@link MethodUtils}.
 *
 * <h2>Known Limitations</h2>
 * <h3>Accessing Public Constructors In A Default Access Superclass</h3>
 * <p>
 * There is an issue when invoking {@code public} constructors contained in a default access superclass. Reflection correctly locates these constructors and
 * assigns them as {@code public}. However, an {@link IllegalAccessException} is thrown if the constructor is invoked.
 * </p>
 *
 * <p>
 * {@link ConstructorUtils} contains a workaround for this situation: it will attempt to call {@link java.lang.reflect.AccessibleObject#setAccessible(boolean)}
 * on this constructor. If this call succeeds, then the method can be invoked as normal. This call will only succeed when the application has sufficient
 * security privileges. If this call fails then a warning will be logged and the method may fail.
 * </p>
 *
 * @since 2.5
 */
public class ConstructorUtils {

    /**
     * Finds a constructor given a class and signature, checking accessibility.
     *
     * <p>
