eclipse-aspectj / aspectj

Other
303 stars 86 forks source link

Pitest Mutators #188

Closed sanmibuh closed 1 year ago

sanmibuh commented 2 years ago

Hello, Using AspectJ with pitest, I have a false positive mutator. I think it is because of the null check that inserts AspectJ. At the generated class I see:

public class DemoClass {
  public DemoClass() {
  }

  @MyAspect
  public int init() {
    JoinPoint var1 = Factory.makeJP(ajc$tjp_0, this, this);
    MyAspectImpl var10002 = MyAspectImpl.aspectOf();
    ProceedingJoinPoint var10003 = (ProceedingJoinPoint)var1;
    Annotation var10004 = ajc$anno$0;
    if (var10004 == null) {
      var10004 = ajc$anno$0 = DemoClass.class.getDeclaredMethod("init").getAnnotation(MyAspect.class);
    }

    return Conversions.intValue(init_aroundBody1$advice(this, var1, var10002, var10003, (MyAspect)var10004));
  }

  static {
    ajc$preClinit();
  }
}

And the report returns:

image

I have created this demo repo for check the issue: https://github.com/sanmibuh/pitest-aspectj You could check running ./gradlew clean build pitest

Im not sure if the problem if on pitest or in aspectj so I have created an issue at Pitest also https://github.com/hcoles/pitest/issues/1097

sanmibuh commented 2 years ago

Maybe if AspectJ adds a Generated named annotation in the injected code it could be fixed 🤔 https://github.com/hcoles/pitest/issues/347#issuecomment-301184718

kriegaex commented 1 year ago

I understand how that would be helpful for you when using pitest, but I do not feel inclined to add extra annotations to AspectJ just to address this. I am and have been the only active developer for a while now, and in addition to simply not having the cycles to implement and thoroughly test this, it also seems to be risky. AspectJ is used in lots of enterprise software, and I want to avoid breaking anything or adding more overhead than necessary to class files, maybe making classes too big for the JVM in the process, just to satisfy the needs of a testing tool.