Package org.easymock.internal
Class DefaultClassInstantiator
java.lang.Object
org.easymock.internal.DefaultClassInstantiator
- All Implemented Interfaces:
IClassInstantiator
Default class instantiator that is pretty limited. It just hope that the
mocked class has a public empty constructor.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static LongcallLongMethod(Class<?> clazz, String methodName) Object[]getArgsForTypes(Class<?>[] methodTypes) Get some default instances of provided classesConstructor<?> getConstructorToUse(Class<?> clazz) Return the constructor considered the best to use with this class.private static LonggetSerializableUID(Class<?> clazz) private static byte[]getSerializedBytes(Class<?> clazz) private booleanisSerializable(Class<?> clazz) Tells if the provided class is serializablenewInstance(Class<?> c) Try to instantiate a class without using a special constructor.private static ObjectreadObject(byte[] bytes)
-
Field Details
-
EMPTY
-
-
Constructor Details
-
DefaultClassInstantiator
public DefaultClassInstantiator()
-
-
Method Details
-
newInstance
Try to instantiate a class without using a special constructor. See documentation for the algorithm.- Specified by:
newInstancein interfaceIClassInstantiator- Parameters:
c- Class to instantiate- Returns:
- new instance of clazz
- Throws:
InstantiationException- when an error occured during instantiation
-
isSerializable
Tells if the provided class is serializable- Parameters:
clazz- Class to check- Returns:
- If the class is serializable
-
getConstructorToUse
Return the constructor considered the best to use with this class. Algorithm is: No args constructor and then first constructor defined in the class- Parameters:
clazz- Class in which constructor is searched- Returns:
- Constructor to use
-
getArgsForTypes
Get some default instances of provided classes- Parameters:
methodTypes- Classes to instantiate- Returns:
- Instances of methodTypes in order
- Throws:
InstantiationException- Thrown if the class instantiation fails
-
getSerializedBytes
- Throws:
IOException
-
getSerializableUID
-
callLongMethod
-
readObject
- Throws:
IOExceptionClassNotFoundException
-