Class MagicInstantiator<T>
java.lang.Object
org.objenesis.instantiator.exotic.MagicInstantiator<T>
- All Implemented Interfaces:
ObjectInstantiator<T>
@Instantiator(STANDARD)
public class MagicInstantiator<T>
extends Object
implements ObjectInstantiator<T>
This instantiator will correctly bypass the constructors by instantiating the class using the default
constructor from Object. It will be allowed to do so by extending
MagicAccessorImpl
which prevents
its children to be verified by the class loader-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final int
private static final byte[]
private static final int
private static final String
private static final String
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private final ObjectInstantiator<T>
private static final String
private static final byte[]
private static final int
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionGet the underlying instantiator.private static String
Returns a new instance of an object.private ObjectInstantiator<T>
newInstantiatorOf
(Class<T> type) private byte[]
writeExtendingClass
(Class<?> type, String className) Will generate the bytes for a class extending the type passed in parameter.
-
Field Details
-
MAGIC_ACCESSOR
-
INDEX_CLASS_THIS
private static final int INDEX_CLASS_THIS- See Also:
-
INDEX_CLASS_SUPERCLASS
private static final int INDEX_CLASS_SUPERCLASS- See Also:
-
INDEX_UTF8_CONSTRUCTOR_NAME
private static final int INDEX_UTF8_CONSTRUCTOR_NAME- See Also:
-
INDEX_UTF8_CONSTRUCTOR_DESC
private static final int INDEX_UTF8_CONSTRUCTOR_DESC- See Also:
-
INDEX_UTF8_CODE_ATTRIBUTE
private static final int INDEX_UTF8_CODE_ATTRIBUTE- See Also:
-
INDEX_UTF8_INSTANTIATOR_CLASS
private static final int INDEX_UTF8_INSTANTIATOR_CLASS- See Also:
-
INDEX_UTF8_SUPERCLASS
private static final int INDEX_UTF8_SUPERCLASS- See Also:
-
INDEX_CLASS_INTERFACE
private static final int INDEX_CLASS_INTERFACE- See Also:
-
INDEX_UTF8_INTERFACE
private static final int INDEX_UTF8_INTERFACE- See Also:
-
INDEX_UTF8_NEWINSTANCE_NAME
private static final int INDEX_UTF8_NEWINSTANCE_NAME- See Also:
-
INDEX_UTF8_NEWINSTANCE_DESC
private static final int INDEX_UTF8_NEWINSTANCE_DESC- See Also:
-
INDEX_METHODREF_OBJECT_CONSTRUCTOR
private static final int INDEX_METHODREF_OBJECT_CONSTRUCTOR- See Also:
-
INDEX_CLASS_OBJECT
private static final int INDEX_CLASS_OBJECT- See Also:
-
INDEX_UTF8_OBJECT
private static final int INDEX_UTF8_OBJECT- See Also:
-
INDEX_NAMEANDTYPE_DEFAULT_CONSTRUCTOR
private static final int INDEX_NAMEANDTYPE_DEFAULT_CONSTRUCTOR- See Also:
-
INDEX_CLASS_TYPE
private static final int INDEX_CLASS_TYPE- See Also:
-
INDEX_UTF8_TYPE
private static final int INDEX_UTF8_TYPE- See Also:
-
CONSTANT_POOL_COUNT
private static final int CONSTANT_POOL_COUNT- See Also:
-
CONSTRUCTOR_CODE
private static final byte[] CONSTRUCTOR_CODE -
CONSTRUCTOR_CODE_ATTRIBUTE_LENGTH
private static final int CONSTRUCTOR_CODE_ATTRIBUTE_LENGTH -
NEWINSTANCE_CODE
private static final byte[] NEWINSTANCE_CODE -
NEWINSTANCE_CODE_ATTRIBUTE_LENGTH
private static final int NEWINSTANCE_CODE_ATTRIBUTE_LENGTH -
CONSTRUCTOR_NAME
- See Also:
-
CONSTRUCTOR_DESC
- See Also:
-
instantiator
-
-
Constructor Details
-
MagicInstantiator
-
-
Method Details
-
getInstantiator
Get the underlying instantiator.MagicInstantiator
is a wrapper around another object which implementsObjectInstantiator
interface. This method exposes that instantiator.- Returns:
- the underlying instantiator
-
newInstantiatorOf
-
writeExtendingClass
Will generate the bytes for a class extending the type passed in parameter. This class will only have an empty default constructor- Parameters:
type
- type to extendclassName
- name of the wrapped instantiator class- Returns:
- the byte for the class
- Throws:
ObjenesisException
- is something goes wrong
-
newInstance
Description copied from interface:ObjectInstantiator
Returns a new instance of an object. The returned object's class is defined by the implementation.- Specified by:
newInstance
in interfaceObjectInstantiator<T>
- Returns:
- A new instance of an object.
-
getMagicClass
-