Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Constructor dispatch #2020

Merged
merged 2 commits into from Aug 22, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -11,6 +11,22 @@

public abstract class MockMethodDispatcher {

static {
ClassLoader classLoader = MockMethodDispatcher.class.getClassLoader();
if (classLoader != null) {
// Do not use Mockito classes in here as this is executed on the boot loader.
throw new IllegalStateException(
MockMethodDispatcher.class.getName()
+ " is not loaded by the bootstrap class loader but by an instance of "
+ classLoader.getClass().getName()
+ ".\n\nThis causes the inline mock maker to not work as expected. "
+ "Please contact the maintainer of this class loader implementation "
+ "to assure that this class is never loaded by another class loader. "
+ "The bootstrap class loader must always be queried first for this "
+ "class for Mockito's inline mock maker to function correctly.");
}
}

private static final ConcurrentMap<String, MockMethodDispatcher> DISPATCHERS =
new ConcurrentHashMap<>();

Expand Down