Menu

#187 Option to let the mapping rules take precedence over mapping file to decide on the obfuscation

Some sunny day
open
mapping (1)
5
2018-06-19
2018-06-19
No

In short, I would like to avoid regenerating the mappings completely from scratch every time the code changes.

When deciding if a class needs obfuscating, there can be 2 possible authorities:

  • the obfuscation rules
  • the (optional) mapping file

Let's consider a scenario with the following obfuscation rule:
-keepclasseswithmembers public class * {
public static void main(java.lang.String[]);
}

1) class A has no main, is obfuscated, save mappings
2) add a main() to class A
3) re-obfuscate using the previous mappings

The rules command to obfuscate A but the mapping say otherwise.
In that case Proguard issues a warning like this:

Warning: com.github.benji.proguard.MyClass is not being kept as 'com.github.benji.proguard.MyClass', but remapped to 'com.github.benji.proguard.a'
Warning: there were 1 kept classes and class members that were remapped anyway.
You should adapt your configuration or edit the mapping file.
If you are sure this remapping won't hurt, you could try your luck
using the '-ignorewarnings' option.
(http://proguard.sourceforge.net/manual/troubleshooting.html#mappingconflict1)

If we ignore the warnings, the mapping file will take precedence and Proguard will obfuscate class A, which makes it impossible to use its main() method.

I think it would be useful to have the possibility to let the mapping rules take precedence to decide what should be obfuscated, but still use the mapping file as the "preferred" names if necessary.

The behavior would be as follows:

  • if the name is obfuscated, then prefer the name in the provided mapping file
  • if the name is not obfuscated, then don't obfuscate regardless of the mapping file

Discussion


Log in to post a comment.

MongoDB Logo MongoDB