簡單記錄下aspectjrt操作中的Cause: zip file is empty

自定義注解

@Retention()
@Target(allowedTargets = AnnotationTarget.FUNCTION)
public @interface CheckLogin{
}
CheckLoginAspect

@Pointcut("execution(@xxx.xxxx.CheckLogin * *(..))")
    private void methodAnnotated(){
    }

    @Around("methodAnnotated()")
    public void checkLogin(ProceedingJoinPoint joinPoint) throws Throwable {//一定要是public
        Signature signature =  joinPoint.getSignature();//方法簽名
        Method method = ( (MethodSignature)signature).getMethod();

        //這個(gè)方法才是目標(biāo)對象上有注解的方法
        Method realMethod = joinPoint.getTarget().getClass().getDeclaredMethod(method.getName(), method.getParameterTypes());
        CheckLogin checkLogin  = realMethod.getAnnotation(CheckLogin.class);

        //下面這句代碼是獲得那個(gè)自定義的注解的對象
        CheckLogin authorizationNeed = (method.getAnnotation(CheckLogin.class));

        Log.e("checkLogin",(checkLogin == null) + "");
        Log.e("authorizationNeed",(authorizationNeed == null) + "");
        //這里兩種getAnnotation的方式都為null,請大神指教,百思不得其解
    }
MainActivity

@CheckLogin()
private void test(){
    Toast.makeText(this,"跳轉(zhuǎn)成功",Toast.LENGTH_SHORT).show();
}

胖子玩AOP的時(shí)候,報(bào):Cause: zip file is empty

baidu、google一晚,還是google靠譜,這里記錄下。

public void checkLogin(ProceedingJoinPoint joinPoint),這里的一定要是public。如果是private就會(huì)報(bào)Cause: zip file is empty

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容