summaryrefslogtreecommitdiff
path: root/src/main/java/org/mockito/internal/creation/bytebuddy/SubclassLoader.java
blob: 011504ea173eae9808d9393810a937bf3813e422 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
/*
 * Copyright (c) 2017 Mockito contributors
 * This program is made available under the terms of the MIT License.
 */
package org.mockito.internal.creation.bytebuddy;

import net.bytebuddy.dynamic.loading.ClassLoadingStrategy;

/**
 * A subclass loader is responsible for resolving a class loading strategy for a mock that is implemented as a subclass.
 */
public interface SubclassLoader {

    /**
     * Checks if this loader does not require a module to be open.
     *
     * @return {@code true} if this loader is not constraint to a target module being opened for loading a class.
     */
    boolean isDisrespectingOpenness();

    /**
     * Resolves a class loading strategy.
     *
     * @param mockedType  The type being mocked.
     * @param classLoader The class loader being used.
     * @param localMock   {@code true} if the mock is loaded within the runtime package of the mocked type.
     * @return An appropriate class loading strategy.
     */
    ClassLoadingStrategy<ClassLoader> resolveStrategy(Class<?> mockedType, ClassLoader classLoader, boolean localMock);
}