Java Class New Instance newInstanceOrThrow(final Class clazz)

Here you can find the source of newInstanceOrThrow(final Class clazz)

Description

new Instance Or Throw

License

Apache License

Declaration

private static <T> T newInstanceOrThrow(final Class<T> clazz) 

Method Source Code

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

public class Main {
    private static <T> T newInstanceOrThrow(final Class<T> clazz) {
        try {/*w  ww .  ja  v  a2s .  com*/
            return clazz.newInstance();
        } catch (final Exception e) {
            throw new RuntimeException("Could not instantiate class:" + clazz.getSimpleName(), e);
        }
    }
}

Related

  1. newInstanceFromClassName(String className, Class classType)
  2. newInstanceFromUnknownArgumentTypes(Class cls, Object[] args)
  3. newInstanceHard(String name)
  4. newInstanceOf(Class clazz)
  5. newInstanceOf(String className)
  6. newInstancesViaMetaAnnotation(Class declarator, Class metaAnnotationClass, Class expected)
  7. newInstanceViaAnnotation(Class declarator, Annotation annotation, Class expected, Annotation parameter)
  8. newInstanceWithDefaults(Class annotationType)
  9. newInstanceWithFill(Class componentType, int length, Object filledValue)