Java Class New Instance newInstance(Constructor constructor, Object... args)

Here you can find the source of newInstance(Constructor constructor, Object... args)

Description

new Instance

License

Apache License

Declaration

private static Object newInstance(Constructor<?> constructor, Object... args) 

Method Source Code


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

import java.lang.reflect.Constructor;

import java.lang.reflect.InvocationTargetException;

public class Main {
    private static Object newInstance(Constructor<?> constructor, Object... args) {
        try {//  w  w w  .  ja  va2s.  co m
            return constructor.newInstance(args);
        } catch (InstantiationException e) {
            throw new IllegalArgumentException("Can't instantiate " + constructor, e);
        } catch (IllegalAccessException e) {
            throw new IllegalArgumentException("Can't instantiate " + constructor, e);
        } catch (InvocationTargetException e) {
            throw new IllegalArgumentException("Can't instantiate " + constructor, e);
        }
    }
}

Related

  1. newInstance(Class type, Class declarator, Annotation annotation)
  2. newInstance(Class type, Class[] parameterTypes, Object[] args)
  3. newInstance(Class type, Object... args)
  4. newInstance(Class type, Object... params)
  5. newInstance(Constructor c, List parameters)
  6. newInstance(Constructor constructor, Object... arguments)
  7. newInstance(Constructor ctor, Object... params)
  8. newInstance(Field field)
  9. newInstance(final Class clazz)

  10. HOME | Copyright © www.java2s.com 2016