Hi Jack and Jonas,
I use ProGuard 7.5.0 for obfuscation for standalone Java application/service.
javax.print.DocFlavor is obfuscated into Object in a variable of a method:
DocFlavor docFlavor = supportsPdf ? BYTE_ARRAY.PDF : SERVICE_FORMATTED.PAGEABLE; obfuscated to:
Object var8 = var7 ? BYTE_ARRAY.PDF : SERVICE_FORMATTED.PAGEABLE;
In the following usage, var8 not able to assign to DocFlavor:
SimpleDoc var10 = new SimpleDoc(var9, (DocFlavor)var8, var3);
I’m trying to preserve the method by using a rule:
keepclassmembers ‘class com.mycorp.util.OutputFileUtil {
*;
}’
It didn’t help - the method content still gets obfuscated. Also I tried adding:
javax.print.DocFlavor docFlavor inside the above rule. DocFlavor still obfuscated to Object.
And, this rule didn’t help either:
keepclassmembers ‘class com.mycorp.util.OutputFileUtil {
public static void printWithJavaPrintServiceApi(byte[]);
}’
Can you help to either get DocFlavor not obfuscated or get the entire method content not obfuscated?
Thanks,
Jingkun
Here are the rules:
task obfuscateJar (type: proguard.gradle.ProGuardTask) {
injars ‘./target/obfuscated_libs/input/’
outjars outJarFolder
libraryjars './target/obfuscated_libs/output-3rd-party/'
libraryjars "${System.getProperty('java.home')}/jmods/java.base.jmod", jarfilter: '!**.jar', filter: '!module-info.class'
libraryjars "${System.getProperty('java.home')}/jmods/java.sql.jmod", jarfilter: '!**.jar', filter: '!module-info.class'
dontshrink
dontoptimize
dontusemixedcaseclassnames
verbose
dontnote
dontwarn
printmapping './target/obfuscated_libs/report/cepheid-mapping.map'
adaptresourcefilecontents '**.xml, META-INF/MANIFEST.MF"'
keepdirectories '**'
keeppackagenames 'com.mycorp.**'
keepattributes '*Annotation*, Signature,*Exception*,InnerClasses'
keepparameternames
keep 'class com.mycorp.** { \
public *; \
}'
/* keep 'class com.mycorp.persistence.core.**DAO {
;
}'/
keep 'class com.mycorp.**.transfer.** { \
*; \
}'
keep 'class com.mycorp.**.controller.** { \
*; \
}'
keep 'class com.mycorp.**.run.** { \
*; \
}'
keep 'class com.mycorp.**.view.** { \
*; \
}'
/* keep 'class com.mycorp.**.Native {
;
}'/
dependsOn(stageJarsForObfuscation)
}