Top Description Fields Constructors Methods
org.glassfish.jaxb.core.v2

public final Class ClassFactory

extends Object
Class Inheritance
Imports
java.lang.reflect.Constructor, .InvocationTargetException, .Method, .Modifier, java.security.AccessController, .PrivilegedAction, java.util.logging.Level, .Logger, org.glassfish.jaxb.core.Utils

Creates new instances of classes.

This code handles the case where the class is not public or the constructor is not public.

Author
Kohsuke Kawaguchi
Since
2.0

Field Summary

Modifier and TypeField and Description
private static final ClassValue<Constructor<T>>
DECLARED_CTORS

Cache from a class to its default constructor.

private static final Class<T>[]
private static final Object[]
private static final Logger

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static void
cleanCache()
Deprecated for removal. this method is empty by now and will be removed in next major version

public static <T> T
create(Class<T> clazz)

The same as create0 but with an error handling to make the instantiation error fatal.

public static Object
create(Method method)

Call a method in the factory class to get the object.

public static <T> T
create0(final Class<T> clazz)

Creates a new instance of the class but throw exceptions without catching it.

public static <T> Class<? extends T>

Returns:

null if inference fails.
inferImplClass
(Class<T> fieldType, Class<T>[] knownImplClasses)

Infers the instantiable implementation class that can be assigned to the given field type.

private static <T> Constructor<T>
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

DECLARED_CTORSback to summary
private static final ClassValue<Constructor<T>> DECLARED_CTORS

Cache from a class to its default constructor.

emptyClassback to summary
private static final Class<T>[] emptyClass
emptyObjectback to summary
private static final Object[] emptyObject
loggerback to summary
private static final Logger logger

Constructor Detail

ClassFactoryback to summary
private ClassFactory()

Method Detail

cleanCacheback to summary
public static void cleanCache()

Deprecated

for removal.

this method is empty by now and will be removed in next major version

Annotations
@Deprecated
forRemoval:true
See Also
Issue 978
createback to summary
public static <T> T create(Class<T> clazz)

The same as create0 but with an error handling to make the instantiation error fatal.

createback to summary
public static Object create(Method method)

Call a method in the factory class to get the object.

create0back to summary
public static <T> T create0(final Class<T> clazz) throws IllegalAccessException, InvocationTargetException, InstantiationException

Creates a new instance of the class but throw exceptions without catching it.

inferImplClassback to summary
public static <T> Class<? extends T> inferImplClass(Class<T> fieldType, Class<T>[] knownImplClasses)

Infers the instantiable implementation class that can be assigned to the given field type.

Returns:Class<? extends T>

null if inference fails.

tryGetDeclaredConstructorback to summary
private static <T> Constructor<T> tryGetDeclaredConstructor(Class<T> clazz)