When compiling using AspectJ's ajc compiler, bad bytecode would get generated that would cause this error:
Exception in thread "main" java.lang.AbstractMethodError: org.perf4j.aop.AbstractTimingAspect.hello(Ljava/lang/String;Ljava/lang/String;)V
at org.perf4j.aop.AbstractTimingAspect.ajc$inlineAccessMethod$org_perf4j_aop_AbstractTimingAspect$org_perf4j_aop_AbstractTimingAspect$hello(AbstractTimingAspect.java:1)
at org.perf4j.aop.AbstractTimingAspect.doPerfLogging(AbstractTimingAspect.java:57)
at ProfiledExample.logFailuresSeparatelyExample(ProfiledExample.java:83)
at ProfiledExample.main(ProfiledExample.java:12)
It turns out this was caused by this bug in AspectJ (which has, erroneously, been closed):
https://bugs.eclipse.org/bugs/show_bug.cgi?id=97481
In my debugging I found that in some cases ajc generates "inline" methods, like so (from javap output - see the ajc$inlineAccessMethods at the bottom):
public abstract class org.perf4j.aop.AbstractTimingAspect extends java.lang.Object{
public org.perf4j.aop.AbstractTimingAspect();
public java.lang.Object doPerfLogging(org.aspectj.lang.ProceedingJoinPoint, org.perf4j.aop.Profiled) throws java.lang.Throwable;
protected java.lang.String getStopWatchTag(org.perf4j.aop.Profiled, org.aspectj.lang.ProceedingJoinPoint, java.lang.Object, java.lang.Throwable);
protected java.lang.String getStopWatchMessage(org.perf4j.aop.Profiled, org.aspectj.lang.ProceedingJoinPoint, java.lang.Object, java.lang.Throwable);
protected java.lang.String evaluateJexl(java.lang.String, java.lang.Object[], java.lang.Object, java.lang.Object, java.lang.Throwable);
protected org.apache.commons.jexl.Expression getJexlExpression(java.lang.String) throws java.lang.Exception;
protected abstract org.perf4j.LoggingStopWatch newStopWatch(java.lang.String, java.lang.String);
public static java.lang.String ajc$inlineAccessMethod$org_perf4j_aop_AbstractTimingAspect$org_perf4j_aop_AbstractTimingAspect$getStopWatchTag(org.perf4j.aop.AbstractTimingAspect, org.perf4j.aop.Profiled, org.aspectj.lang.ProceedingJoinPoint, java.lang.Object, java.lang.Throwable);
public static org.perf4j.LoggingStopWatch ajc$inlineAccessMethod$org_perf4j_aop_AbstractTimingAspect$org_perf4j_aop_AbstractTimingAspect$newStopWatch(org.perf4j.aop.AbstractTimingAspect, java.lang.String, java.lang.String);
public static java.lang.String ajc$inlineAccessMethod$org_perf4j_aop_AbstractTimingAspect$org_perf4j_aop_AbstractTimingAspect$getStopWatchMessage(org.perf4j.aop.AbstractTimingAspect, org.perf4j.aop.Profiled, org.aspectj.lang.ProceedingJoinPoint, java.lang.Object, java.lang.Throwable);
}
It turns out I was able to work around this problem simply by changing this line in AbstractTimingAspect from:
LoggingStopWatch stopWatch = newStopWatch(profiled.logger(), profiled.level());
to
LoggingStopWatch stopWatch = newStopWatch(profiled.logger() + "", profiled.level());
For whatever reason adding the empty string causes ajc to NOT generate those faulty inline methods.
When compiling using AspectJ's ajc compiler, bad bytecode would get generated that would cause this error:
Exception in thread "main" java.lang.AbstractMethodError: org.perf4j.aop.AbstractTimingAspect.hello(Ljava/lang/String;Ljava/lang/String;)V
at org.perf4j.aop.AbstractTimingAspect.ajc$inlineAccessMethod$org_perf4j_aop_AbstractTimingAspect$org_perf4j_aop_AbstractTimingAspect$hello(AbstractTimingAspect.java:1)
at org.perf4j.aop.AbstractTimingAspect.doPerfLogging(AbstractTimingAspect.java:57)
at ProfiledExample.logFailuresSeparatelyExample(ProfiledExample.java:83)
at ProfiledExample.main(ProfiledExample.java:12)
It turns out this was caused by this bug in AspectJ (which has, erroneously, been closed):
https://bugs.eclipse.org/bugs/show_bug.cgi?id=97481
In my debugging I found that in some cases ajc generates "inline" methods, like so (from javap output - see the ajc$inlineAccessMethods at the bottom):
public abstract class org.perf4j.aop.AbstractTimingAspect extends java.lang.Object{
public org.perf4j.aop.AbstractTimingAspect();
public java.lang.Object doPerfLogging(org.aspectj.lang.ProceedingJoinPoint, org.perf4j.aop.Profiled) throws java.lang.Throwable;
protected java.lang.String getStopWatchTag(org.perf4j.aop.Profiled, org.aspectj.lang.ProceedingJoinPoint, java.lang.Object, java.lang.Throwable);
protected java.lang.String getStopWatchMessage(org.perf4j.aop.Profiled, org.aspectj.lang.ProceedingJoinPoint, java.lang.Object, java.lang.Throwable);
protected java.lang.String evaluateJexl(java.lang.String, java.lang.Object[], java.lang.Object, java.lang.Object, java.lang.Throwable);
protected org.apache.commons.jexl.Expression getJexlExpression(java.lang.String) throws java.lang.Exception;
protected abstract org.perf4j.LoggingStopWatch newStopWatch(java.lang.String, java.lang.String);
public static java.lang.String ajc$inlineAccessMethod$org_perf4j_aop_AbstractTimingAspect$org_perf4j_aop_AbstractTimingAspect$getStopWatchTag(org.perf4j.aop.AbstractTimingAspect, org.perf4j.aop.Profiled, org.aspectj.lang.ProceedingJoinPoint, java.lang.Object, java.lang.Throwable);
public static org.perf4j.LoggingStopWatch ajc$inlineAccessMethod$org_perf4j_aop_AbstractTimingAspect$org_perf4j_aop_AbstractTimingAspect$newStopWatch(org.perf4j.aop.AbstractTimingAspect, java.lang.String, java.lang.String);
public static java.lang.String ajc$inlineAccessMethod$org_perf4j_aop_AbstractTimingAspect$org_perf4j_aop_AbstractTimingAspect$getStopWatchMessage(org.perf4j.aop.AbstractTimingAspect, org.perf4j.aop.Profiled, org.aspectj.lang.ProceedingJoinPoint, java.lang.Object, java.lang.Throwable);
}
It turns out I was able to work around this problem simply by changing this line in AbstractTimingAspect from:
LoggingStopWatch stopWatch = newStopWatch(profiled.logger(), profiled.level());
to
LoggingStopWatch stopWatch = newStopWatch(profiled.logger() + "", profiled.level());
For whatever reason adding the empty string causes ajc to NOT generate those faulty inline methods.