Good question. The reason is that JMockit performs certain transformations to the bytecode in constructors and initialization blocks of an Expectations
or NonStrictExpectations
subclass. (Essentially, this is done so that the mocking API works. For example, every assignment to the special result
field is actually replaced with a method call, so that it gets properly associated with the current expectation.)
Methods in an expectation block, however, are not yet transformed. They should be, so I am implementing it now. From the next release (0.999.19) on, this will be supported.