Menu

#599 Obfuscation of multiple jars leading to invalid code

v5.2
closed-wont-fix
None
High
2019-12-06
2016-04-13
rupi
No

I have weird issue where my application is spread over two jar files. When I obfuscate the code, one of the methods starts referring to the wrong class in the other jar whihc is totally unrelated. I have added an eclipse project with an ANT script to compile the code, create the jars and then obfuscate them using proguard. The jars are placed in the dist folder and the obfuscated ones are placed in the dist/obg folder.

The two jars are main.jar and helper.jar and I am using both as the programJars to proguard.

main.jar has a class called FileSnapshotAccessor with a method namet setFilter with this code:

 public void setFilter(long startDate, long endDate, boolean excludeJvmEvents)
  {
    if (startDate > 0 || endDate < Long.MAX_VALUE || excludeJvmEvents)
    {
      this.filter = new EventFilter(startDate, endDate, excludeJvmEvents);
    }
  }

After obfuscation it gets converted to:

 private void a(long paramLong1, long paramLong2, boolean paramBoolean)
  {
    if ((paramLong1 > 0L) || (paramLong2 < Long.MAX_VALUE) || (paramBoolean)) {
      new a.a.a.a(paramLong1, paramLong2, paramBoolean);
    }
  }

But that a.a.a.a class is actually a different class in the helper.jar file.

The mappings file has the following mapping for a.a.a.a

com.test.config.Config -> a.a.a.a

So essentially the constructor to com.test.event.EventFilter changes to the constructor for com.test.config.Config and the two classes are completely unrelated. The latter does not have that constructor and so my application fails.

The actual code is more involved but I have created a simplifed self executing sample. The source code, the proguard jar I am using are also included in the project itself.

1 Attachments

Discussion

  • Toby Willcock

    Toby Willcock - 2017-02-21

    We had a similar issue, obfuscating multiple jars and classes getting merged across both jars. The suggested workaround on https://sourceforge.net/p/proguard/bugs/579/ fixed it for us (-optimizations !class/merging/*) though the cause must be something different as the issue still occurs in 5.3.2.

     
  • T. Neidhart

    T. Neidhart - 2019-12-06
    • status: open --> closed-wont-fix
    • Priority: 5 --> High
     
  • T. Neidhart

    T. Neidhart - 2019-12-06

    When using multiple output jars, there is no way to control that only classes belonging to the same input / output jar should be merged together.

    There is also no intention to support that in the near future, disabling class merging as suggested is the best option.

     

Log in to post a comment.