Archinamon / android-gradle-aspectj

gradle plug-in adding supports of AspectJ into Android project
Apache License 2.0
365 stars 58 forks source link

Add experimental aj-compiler options #18

Closed Archinamon closed 7 years ago

Archinamon commented 8 years ago

-XhasMember allow hasmethod() and hasfield type patterns in declare parents and declare @type -Xjoinpoints: supply a comma separated list of new joinpoints that can be identified by pointcuts. Values are: arrayconstruction, synchronization

Archinamon commented 7 years ago

Added new qualifier to gradle config:

aspectj {
    experimental true
}

Simple test of new experimental options:

public aspect TestExperimentalFeatures {

    pointcut testJoinPoints(): call(String[].new(..));
    before(): testJoinPoints() {
        Log.e(aspectOf().getClass().getSimpleName(), thisJoinPoint.toString());
    }

    interface Abc {}
    declare parents: AppCompatActivity+ && hasmethod(* getRouter()) implements Abc;
}

The joinpoint of array's constructors couldn't be catched before. Now it correctly supplies. Now available to define hasmethod(MethodPattern) and hasfield(FieldPattern) directives to target exact classes in declare parents and declare @type morphemes.

Archinamon commented 7 years ago

Implemented.