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

Closed
ogray58 opened this Issue Jul 27, 2017 · 0 comments

Comments

2 participants
@ogray58

ogray58 commented Jul 27, 2017

Version
JMockit: 1.33
JUnit: 4.11
Java: 1.8.0_66

Description
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
ExampleTest.java:

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

public class ExampleTest
{

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

	@Test
	public void test()
	{
		mockedTestInterface.getPackagePrivateClass();
	}
}

TestInterface.java

public interface TestInterface
{

	PackagePrivateClass getPackagePrivateClass();
}

PackagePrivateClass.java

class PackagePrivateClass
{

}

@rliesenfeld rliesenfeld self-assigned this Jul 29, 2017

@rliesenfeld rliesenfeld added the bug label 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.