1 回答
The verifier is correct to reject your code (see JVM specification). There is no way to bypass bytecode verifier.
One way around is to inline the mediator code at the point of constructor invocation. You still can invoke parts of mediator as method calls before or after the invocation of the constructor, but the very constructor invocation has to be in the same method as the new instruction.
Another way is to make special mediators for every class being instantiation, so the mediators invoke the new
instruction themselves, along with the constructor call.
You can also look at existing AOP libraries if they can do the required job correctly.