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

Mocked Interface with dependency on package private class throws IllegalAccessError #436

ogray58 opened this issue Jul 27, 2017 · 0 comments


Copy link

@ogray58 ogray58 commented Jul 27, 2017

JMockit: 1.33
JUnit: 4.11
Java: 1.8.0_66

It seems that a fake implementation of an interface does not have the same access privilege as an implementation created inside the same package as the interface. (I know it's a really strange use case...)
The code below causes the following error:
java.lang.IllegalAccessError: tried to access class package.PackagePrivateClass from class package.$Impl_TestInterface

Code to Reproduce

import mockit.Mocked;
import org.junit.Test;

public class ExampleTest

	@SuppressWarnings("unused") @Mocked private TestInterface mockedTestInterface = null;

	public void test()

public interface TestInterface

	PackagePrivateClass getPackagePrivateClass();

class PackagePrivateClass

@rliesenfeld rliesenfeld self-assigned this Jul 29, 2017
@jmockit jmockit locked and limited conversation to collaborators Sep 17, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

No branches or pull requests

2 participants