Bug 492523

Summary: BCException: Bad type signature RuntimeVisibleAnnotations
Product: [Tools] AspectJ Reporter: Eduard Matsukov <archinamon>
Component: CompilerAssignee: aspectj inbox <aspectj-inbox>
Status: NEW --- QA Contact:
Severity: normal    
Priority: P3 CC: aclement
Version: 1.8.9   
Target Milestone: ---   
Hardware: Macintosh   
OS: Mac OS X   
Whiteboard:
Attachments:
Description Flags
crash log
none
new crash
none
strange crash none

Description Eduard Matsukov CLA 2016-04-27 05:09:00 EDT
Created attachment 261287 [details]
crash log

Compilation flow of this bug is:
1. compiled all aspects in project on 'main' configuration;
2. then starts compilation of 'test' config, where already compiled aspects and java classes passed as '-aspectpath' and '-classpath';
3. failed with ajc crash;

The aspect where ajc fails:
aspect OptionMenuRules {

    private static final String TAG = OptionMenuRules.class.getSimpleName();

    declare warning : illegalNativeCall()
            : "Call to ::setHasOptionsMenu(boolean) is forbidden! Call was obsolete. Remove this call from your source!";

    declare warning : missedActionBar() : "Do not attch ActionBar to Activity from current Fragment!";

    pointcut illegalNativeCall():
        findOptionsMenuDecor() &&
        within(Fragment+) &&
        call(void *.setHasOptionsMenu(boolean));

    pointcut missedActionBar():
        findOptionsMenuDecor() &&
        call(void AppCompatActivity+.setSupportActionBar(..));

    private pointcut findOptionsMenuDecor():
        !staticinitialization(*) &&
        @annotation(WithOptionsMenu);

    private pointcut excludeNativeOptionsSetter(WithOptionsMenu menu):
        @this(menu) &&
        (within(Fragment+) ||
            within(AppCompatActivity+)) &&
        cflow(execution(void *.onCreate(..))) &&
            call(void *.setHasOptionsMenu(boolean));

    void around(WithOptionsMenu menuMark): excludeNativeOptionsSetter(menuMark) {
        Class<?> target = thisJoinPoint.getThis().getClass();
        Log.e(TAG, "Call to " + target.getSimpleName() +
                   "::setHasOptionsMenu(boolean) is forbidden! Call was obsolete. Remove this call from your source!");
    }
}
Comment 1 Eduard Matsukov CLA 2016-04-27 05:18:53 EDT
Created attachment 261288 [details]
new crash

Trying to exclude from this problem aspect the last one point+advice I've got new error.
Comment 2 Eduard Matsukov CLA 2016-04-27 11:27:13 EDT
Created attachment 261306 [details]
strange crash

All these crashes occurs when compiled aspect classes are passing to -aspectpath parameter.
And all that looks strange :(
Comment 3 Andrew Clement CLA 2016-04-28 14:50:28 EDT
I am suspecting these problems are due to something else altering the class files. All the issues indicate we aren't finding what we expect in the constant pool. I notice Android in there - are you using any android tools on the class files?  If, after compiling the aspects initially, something operates on the classfile and adversely disturbs the constant pool then when AspectJ is called again to use the aspects, it can't understand them.  This can happen if some kind of 'optimizer' step runs that throws away constant pool entries it thinks aren't being used (in fact they are being used, they are just being referred to from class file attributes AspectJ created).