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

MockUp of class extending Throwable throws NoClassDefFoundError #433

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

Comments

2 participants
@ogray58

ogray58 commented Jul 20, 2017

Version
JMockit: 1.33
Java: 8

Description
If you create a Mock up of a class which extends Throwable, and Mock out printStackTrace(), as shown in the example code below, a call to the printStackTrace() on an instance of the mocked class will result in the following error: java.lang.NoClassDefFoundError: package/Class$MyThrowable

This error does not does not occur if:

  • Throwable is used in the MockUp instead of MyThrowable
  • The printStackTrace() method isn't mocked, but the MockUp is still created
  • There is an an override of printStackTrace in MyThrowable

Code to Reproduce

@Test
public void test()
{
	new MockUp<MyThrowable>() {
		@Mock
		void printStackTrace() {}
	};

	new MyThrowable().printStackTrace();
}

static class MyThrowable extends Throwable {}

@rliesenfeld rliesenfeld self-assigned this Jul 21, 2017

@rliesenfeld rliesenfeld added the bug label Jul 21, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment