ApplyMapping is not happening properly during obfuscation
While trying to obfuscate a jar using proguard-anttask, despite providing an input map file on how the classes have to named after obfuscation using applymapping property, certain methods and fields are not renamed as per the input map file.
For example, in my case I have a jar J1 and it depends on another jar J2, I usually bundle these 2 together and build my resultant jar J3.
I have .map files created from the earlier proguard obfuscation runs for J1 and J2. Now, I merge the .map files together as a single one and feed as input for obfuscating J3 using "applymapping" property
But, certain methods and fields (not all) of J2 are not getting renamed as expected
I tried replacing J1 with a different jar say J4, added the same dependant jar J2 again and repeated the same steps. The resultant jar J5 is having a new set of methods of J2 unobfuscated.
The earlier obfuscation mappings can easily conflict. Merging them then won't work. For example:
- Two classes (one in each jar) could implement the same method in a method hierarchy. If the first obfuscation run maps it to name 'a' and the second obfuscation run maps it to name 'b', an obfuscation run that tries to combine the mapping files has to choose between either name, ignoring the other name.
- Two classes (one in each jar) could implement two completely unrelated public methods with the same signature. The individual obfuscation runs may map both methods to name 'a', The obfuscation run that tries to combine the mapping files gets into problems if these methods have ended up in the same hierarchy, because now there's a conflict.
The mapping files are mostly useful for re-obfuscating code that has only changed slightly. As soon as class hierarchies change, it may need to ignore some mappings to still create consistent code.
I guess the scenario that I'm facing doesn't fall under these 2. The erroroneous method is present only in the common jar J2.
J1 + J2 -> J3 J4 + J2 -> J5
Both J1 and J4 don't override or implement that.