Java Class New Instance newInstanceFromClass(final Class clazz)

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

Description

Get a new instance of a class using the default constructor.

License

Open Source License

Declaration

public static Object newInstanceFromClass(final Class clazz)
        throws IllegalAccessException, InstantiationException 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 1998, 2015 Oracle and/or its affiliates. All rights reserved.
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
 * which accompanies this distribution./*from   w  w  w. j  a v a  2 s. co  m*/
 * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
 * and the Eclipse Distribution License is available at
 * http://www.eclipse.org/org/documents/edl-v10.php.
 *
 * Contributors:
 *     Oracle - initial API and implementation from Oracle TopLink
 *     08/23/2010-2.2 Michael O'Brien 
 *        - 323043: application.xml module ordering may cause weaving not to occur causing an NPE.
 *                       warn if expected "_persistence_*_vh" method not found
 *                       instead of throwing NPE during deploy validation.
 *     30/05/2012-2.4 Guy Pelletier
 *       - 354678: Temp classloader is still being used during metadata processing
 *
 ******************************************************************************/

public class Main {
    /**
     * Get a new instance of a class using the default constructor.  Wrap the call in a privileged block
     * if necessary.
     */
    public static Object newInstanceFromClass(final Class clazz)
            throws IllegalAccessException, InstantiationException {
        return clazz.newInstance();
    }
}

Related

  1. newInstance(Type type)
  2. newInstanceByName(String className)
  3. newInstanceByName(String className)
  4. newInstanceForClass(Class type)
  5. newInstanceForName(String fullClassName, Object... args)
  6. newInstanceFromClassName(String className, Class classType)
  7. newInstanceFromUnknownArgumentTypes(Class cls, Object[] args)
  8. newInstanceHard(String name)
  9. newInstanceOf(Class clazz)