Community
Participate
Working Groups
Build Identifier: AspectJ Compiler 1.7.0 (1.7.0 - Built: Tuesday Jul 3, 2012 at 22:30:30 GMT) - Eclipse Compiler 0.B79_R37x, 3.7 Assertions in aspects are evaluated even when explicitly disabling them with the 'java -da -dsa ...' command-line argument. The generated bytecode seems wrong: the static $assertionsDisabled variable (which is added to any class/aspect containg an assert statement) is never initialized in aspects. The bytecode generated for normal classes starts with: static {}; Code: 0: ldc #1; //class Test2 2: invokevirtual #10; //Method java/lang/Class.desiredAssertionStatus:()Z 5: ifne 12 8: iconst_1 9: goto 13 12: iconst_0 13: putstatic #16; //Field $assertionsDisabled:Z Which sets $assertionsDisabled to 1 or 0 depending on the value desiredAssertionStatus returned for that class (which in turn depends on the -da command line argument). This bytecode is missing in the static {}; section for aspects. Reproducible: Always Steps to Reproduce: 1. Compile the following code with aspectj, source level 1.5 or higher: public class Test1 { public static void main(String[] args) { m(); } public static void m() { ; } } aspect Test1Aspect { before(): call(public static void Test1.m()) { assert false; } } 2. Executing 'java -da -dsa Test1' results in an AssertionError, even though the -da -dsa command-line parameters should prevent any assertions from being checked.