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

ogray58 opened this Issue Jul 20, 2017 · 0 comments


2 participants

ogray58 commented Jul 20, 2017

JMockit: 1.33
Java: 8

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

public void test()
	new MockUp<MyThrowable>() {
		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