简单记录下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();

        //这个方法才是目标对象上有注解的方法
        Method realMethod = joinPoint.getTarget().getClass().getDeclaredMethod(method.getName(), method.getParameterTypes());
        CheckLogin checkLogin  = realMethod.getAnnotation(CheckLogin.class);

        //下面这句代码是获得那个自定义的注解的对象
        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,"跳转成功",Toast.LENGTH_SHORT).show();
}

胖子玩AOP的时候,报:Cause: zip file is empty

baidu、google一晚,还是google靠谱,这里记录下。

public void checkLogin(ProceedingJoinPoint joinPoint),这里的一定要是public。如果是private就会报Cause: zip file is empty

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容