Skip to content

Commit

Permalink
[ci maven-central-release] Merge pull request #2020 from mockito/cons…
Browse files Browse the repository at this point in the history
…tructor-dispatch

Constructor dispatch
  • Loading branch information
raphw committed Aug 22, 2020
2 parents c0e48cd + c5406ae commit 9ca3225
Showing 1 changed file with 16 additions and 0 deletions.
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

0 comments on commit 9ca3225

Please sign in to comment.