Community
Participate
Working Groups
AspectJ compiler does not catch following case and causes java.lang.VerifyError at runtime. Case: Constructor call is not a first statement inside a constructor added via inter-type declaration. Example: public class Example { Example() { /* default const */ } public static void main(String[] args) { new Example(1); } } aspect MyAspect { Example.new(int var) { System.out.println("Hello"); // do something before calling constructor this(); } } Result: Compiled without error, but following exception occurs at runtime. Exception in thread "main" java.lang.VerifyError: Bad operand type when invoking <init> Exception Details: Location: MyAspect.ajc$postInterConstructor$MyAspect$Example(LExample;I)V @9: invokespecial Reason: Invalid type: 'Example' (current frame, stack[0]) Current Frame: bci: @9 flags: { } locals: { 'Example', integer } stack: { 'Example' } Bytecode: 0x0000000: b200 2212 28b6 002a 2ab7 0030 b1 at Example.<init>(Example.java:1) at Example.main(Example.java:5)