I'm only using Proguard (version 5.2.1) to shrink, not to obfuscate or optimize. Here's my config:
-forceprocessing
-dontobfuscate
-dontoptimize
-dontwarn
-dontnote
-dontskipnonpubliclibraryclasses
-dontskipnonpubliclibraryclassmembers
-libraryjars <java.home>/lib
-keep class ** extends **.MyRequestHandler
-keep @org.springframework.stereotype.Component class **
-keep @org.aspectj.lang.annotation.Aspect class **
-keep @interface *
I have a class which is an AspectJ aspect that looks like this:
@Aspect
public class MyAspect {
@Pointcut("execution(* com.amazonaws.services.dynamodb*.*AmazonDynamoDB.*(..))")
public void myPointCut() {
}
@Around(value = "myPointCut()")
public Object logExecution(ProceedingJoinPoint joinPoint) throws Throwable {
System.out.println(joinPoint);
return joinPoint.proceed();
}
}
When I feed my application through Proguard, and then decompile the resulting class file, this is what it looks like:
@Aspect
public class MyAspect {
@Pointcut("execution(* com.amazonaws.services.dynamodb*.*AmazonDynamoDB.*(..))")
public void myPointCut() {
}
@Around
public Object logExecution(ProceedingJoinPoint joinPoint) throws Throwable {
System.out.println(joinPoint);
return joinPoint.proceed();
}
}
Notice that the "value" parameter from the @Around
annotation is missing! This is very weird behavior... I almost think it's a bug in Proguard. It's keeping the annotation itself, just not the parameter... though weirdly enough it is keeping the parameter from the @Pointcut
annotation. Does anyone know how to fix this?
As a reminder, I'm only shrinking, and the -keepattributes
config is only for obfuscation, so please no one respond that -keepattributes *Annotation*
will fix it. I've tried it and it has no effect.
I found this similar question (annotations having no effect in proguard) which is where I got the -keep @interface *
config. This setting is supposed to keep all annotations, which it seems to be doing, but for some reason it's not keeping all of the parameters. I tried many variations of this, such as:
-keep @interface **
-keep @interface* *
-keep @interface.On *
-keep @interface.* *
-keepclassmembers class ** { @org.aspectj.lang.annotation.Around ; }
-keepclassmembers class ** { @org.aspectj.lang.annotation.Around.On ; }
-keepclassmembers class ** { @org.aspectj.lang.annotation.Around.* ; }
Some of these approaches just cause Proguard to throw an error, and the ones that don't aren't having any effect. Please help!