return type.getName().startsWith("java.") && Modifier.isFinal(type.getModifiers());
}
private static <T> MockData<T> createMethodInvocationControl(final String mockName, Class<T> type,
Method[] methods, boolean isSpy, Object delegator, MockSettings mockSettings) {
final MockSettingsImpl settings;
if (mockSettings == null) {
// We change the context classloader to the current CL in order for the Mockito
// framework to load it's plugins (such as MockMaker) correctly.
final ClassLoader originalCL = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(MockCreator.class.getClassLoader());
try {
settings = (MockSettingsImpl) Mockito.withSettings();
} finally {
Thread.currentThread().setContextClassLoader(originalCL);
}
} else {
settings = (MockSettingsImpl) mockSettings;
}
if (isSpy) {
settings.defaultAnswer(Mockito.CALLS_REAL_METHODS);
}
settings.setMockName(new MockNameImpl(mockName));
settings.setTypeToMock(type);
InternalMockHandler mockHandler = new MockHandlerFactory().create(settings);
MethodInterceptorFilter filter = new PowerMockMethodInterceptorFilter(mockHandler, settings);
final T mock = (T) ClassImposterizer.INSTANCE.imposterise(filter, type);
final MockitoMethodInvocationControl invocationControl = new MockitoMethodInvocationControl(filter,