Java Reflection Constructor Get getConstructor(Class cls, Class[] args)

Here you can find the source of getConstructor(Class cls, Class[] args)

Description

get Constructor

License

Open Source License

Declaration

public static Constructor getConstructor(Class cls, Class[] args) 

Method Source Code

//package com.java2s;
/*/*from www.  j av  a  2s .co  m*/
 * Scriptographer
 *
 * This file is part of Scriptographer, a Scripting Plugin for Adobe Illustrator
 * http://scriptographer.org/
 *
 * Copyright (c) 2002-2010, Juerg Lehni
 * http://scratchdisk.com/
 *
 * All rights reserved. See LICENSE file for details.
 * 
 * File created on Aug 26, 2007.
 */

import java.lang.reflect.Constructor;

import java.util.IdentityHashMap;

public class Main {
    public static Constructor getConstructor(Class<?> cls, Class[] args,
            IdentityHashMap<Class, Constructor> cache) {
        Constructor ctor = cache != null ? (Constructor) cache.get(cls) : null;
        if (ctor == null) {
            try {
                ctor = cls.getConstructor(args);
                if (cache != null)
                    cache.put(cls, ctor);
            } catch (Exception e) {
            }
        }
        return ctor;
    }

    public static Constructor getConstructor(Class cls, Class[] args) {
        return getConstructor(cls, args, null);
    }
}

Related

  1. getConstructor(Class clazz, Class... argTypes)
  2. getConstructor(Class clazz, Class[] argTypes)
  3. getConstructor(Class clazz, Class[] parametersTypes)
  4. getConstructor(Class clazz, Class[] paramTypes)
  5. getConstructor(Class clazz, Class[] paramTypes)
  6. getConstructor(Class clz, Class expectedTypes[])
  7. getConstructor(Class type, Class[] argTypes)
  8. getConstructor(Class c, Class[] args)
  9. getConstructor(Class clazz, boolean declared, Class... args)