yWorks / yGuard

The open-source Java obfuscation tool working with Ant and Gradle by yWorks - the diagramming experts

Home Page:https://yworks.github.io/yGuard/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Static initialize constants is being discarded

dsokoya opened this issue · comments

Hello,
The following static variable initialization
transient static Map<String, Integer> indexTypeMap=new LinkedHashMap<String, Integer>() {{
put("problems", 1);
put("allergys", 2);
put("medications", 3);
put("immunizations", 4);
put("documents", 5);
}};
was turned into
static transient Map<String, Integer> indexType = new LinkedHashMap<String, Integer>() {
};
Is there a keep attribute I can set to stop this from happening?

Regards,
Deen Sokoya

yGuard does not remove initializer code. This looks like your decompiler was not able to decompile the anonymous class you are using. Did you actually test if the obfuscated code still works? If you did and your code does not work anymore, please post your yGuard task configuration to give us a chance at reproducing the problem.

Thank you so much for taking the time to explain the process. You are absolutely right. The decompiler wasn't showing the anonymous classes for the static initialized variables. I was able to see these classed in the jar file from zip archiver. I was able to trace the problem variable names hardcoded using reflection in the program but the names changed at runtime due to the obfuscation.
Btw I appreciate the product.
Regards,
Deen Sokoya

Glad you were able to sort it out.