Java Reflection Constructor Get getConstructor(Class type, Class[] parameterTypes)

Here you can find the source of getConstructor(Class type, Class[] parameterTypes)

Description

get Constructor

License

Apache License

Declaration

private static <T> Constructor<T> getConstructor(Class<T> type,
            Class<?>[] parameterTypes) throws Exception 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.lang.reflect.Constructor;

public class Main {
    private static <T> Constructor<T> getConstructor(Class<T> type,
            Class<?>[] parameterTypes) throws Exception {
        try {//w  ww .  j  av  a  2s  .  com
            return type.getConstructor(parameterTypes);
        } catch (NoSuchMethodException e1) {
            try {
                return type.getDeclaredConstructor(parameterTypes);
            } catch (NoSuchMethodException e2) {
                throw e2;
            }
        }
    }
}

Related

  1. getConstructor(Class cls, Class[] args)
  2. getConstructor(Class cls, Object... args)
  3. getConstructor(Class instanceType)
  4. getConstructor(Class targetClass, Class... parameterTypes)
  5. getConstructor(Class type, Class... parameterTypes)
  6. getConstructor(final Class theClass, final Class... parameterTypes)
  7. getConstructor(final Class clazz, final Class... parameterTypes)
  8. getConstructor(final Class clazz, final Class[] paramTypes)
  9. getConstructor(final Class valueClass, final Class parameter)