org.jmock.lib.nonstd
Class UnsafeHackConcreteClassImposteriser
java.lang.Object
org.jmock.lib.nonstd.UnsafeHackConcreteClassImposteriser
- All Implemented Interfaces:
- Imposteriser
public class UnsafeHackConcreteClassImposteriser
- extends Object
- implements Imposteriser
This class lets you imposterise concrete classes with CGLIB
without calling the constructors of the mocked class.
However, it uses undocumented, internal features of Sun's JVM.
It will not work on JVMs from other vendors. Sun may remove
the undocumented feature this class relies upon in any future
versions.
You have been warned!
- Author:
- npryce
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
INSTANCE
public static final Imposteriser INSTANCE
canImposterise
public boolean canImposterise(Class<?> type)
- Description copied from interface:
Imposteriser
- Reports if the Imposteriser is able to imposterise a given type.
- Specified by:
canImposterise in interface Imposteriser
- Parameters:
type - The type in question.
- Returns:
- True if this imposteriser can imposterise type, false otherwise.
imposterise
public <T> T imposterise(Invokable mockObject,
Class<T> mockedType,
Class<?>... ancilliaryTypes)
- Description copied from interface:
Imposteriser
- Creates an imposter for a given type that forwards
Invocations to an
Invokable object.
- Specified by:
imposterise in interface Imposteriser
- Type Parameters:
T - The static type of the imposter that is created.- Parameters:
mockObject - The object that is to receive invocations forwarded from the imposter.mockedType - The class representing the static type of the imposter.ancilliaryTypes - Other types for the imposter. It must be possible to dynamically cast the imposter to these types.
These types must all be interfaces because Java only allows single inheritance of classes.
- Returns:
- A new imposter. The imposter must implement the mockedType and all the ancialliaryTypes.