Java Reflection Constructor Invoke invokeCtor(Constructor ctor, String str)

Here you can find the source of invokeCtor(Constructor ctor, String str)

Description

invoke Ctor

License

LGPL

Declaration

private static Object invokeCtor(Constructor ctor, String str) 

Method Source Code


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

import java.lang.reflect.Constructor;

public class Main {
    private static Object invokeCtor(Constructor ctor, String str) {
        try {//ww w. j  a va2 s  .  c  o  m
            return ctor.newInstance(new Object[] { str });
        } catch (Throwable t) {
            //System.err.println("Error in constructor invocation with argument "+str+" : "+t.getMessage());
            return null;
        }
    }
}

Related

  1. invokeConstructor(final Constructor constructor, final Object[] args)
  2. invokeConstructor(final Constructor constructor, final Object... args)
  3. invokeConstructor(String className, Class[] paramTypes, Object[] paramValues)
  4. invokeConstructor(String className, Object... arguments)
  5. invokeConstructorOrFail(Constructor constructor, Object... args)
  6. invokeExactConstructor(Class klass, Object arg)
  7. invokePrivateConstructor(Class clazz)
  8. invokePrivateConstructor(Class classType)
  9. invokePrivateConstructor(Class clazz)