#408 Classes merged across jars



I really love ProGuard. I'm using it to compress a large program I've written, but I've found an odd problem.

My program is in two parts (two jars), A & B. B is the main program. A depends completely on B, though B doesn't need A.

In ProGuard I have input and output jars as follows:
-injars A.jar
-outjars A-optimized.jar
-injars B.jar
-outjars B-optimized.jar

That's worked beautifully until now.

But after recent development, when classes get merged, some static methods (to do with color blending) from a class in jar B get given to a class in jar A (to do with LZMA compression!).

The trouble is, when the program in B is running, the stuff from A isn't always available. B normally has no dependencies on A. But after the classes are merged, B tries to use its helper functions for color blending and crashes with a mysterious ClassNotFoundException because the LZMA compression code isn't there!

I can work around it by duplicating A's classes in the B jar. It's not a big problem for me because jar A is small (20 kB). But it's quirky. It feels like a bug, if jars that are normally separate can magically grow these dependencies to each other. The fix would be to limit class merge candidates to classes from the same input/output pairs. Or is there something I'm doing wrong?

Thanks for reading.


  • Eric Lafortune

    Eric Lafortune - 2011-07-31

    I see your point. However, reading and writing jars is currently orthogonal to processing the code. ProGuard does not take into account later packaging when performing optimizations. I probably won't change this behavior in the short term. The current solution is to process jar B and then incrementally process jar A, although that might require more complex configurations. Alternatively, just switching off optimization would work, since only the optimization step moves around code. It might be sufficient to switch off class merging and method inlining.

  • Eric Lafortune

    Eric Lafortune - 2011-07-31
    • assigned_to: nobody --> lafortune
    • priority: 5 --> 3
    • status: open --> open-later

Log in to post a comment.