proguard icon indicating copy to clipboard operation
proguard copied to clipboard

Proguard unable to update internals of module-info.class, cannot use Proguard + modular projects

Open credmond opened this issue 1 year ago • 0 comments

If I have a simple modular Java project with a module-info.java file:

import com.certak.Main;

open module com.certak {
    uses Main;
}

When compiled, additional info describing the module (i.e., packages) gets added to this compiled "class" -- package names that Proguard changes afterwards.

If I "keep" module-info, which is often suggested online to prevent renaming the file, then elements inside module-info.class are wrong, and classes cannot be loaded at runtime.

E.g., using a hex editor, I can see references to packages that Proguard would have since obfuscated ("fail" for example):

image

The only way to "fix" this is to not rename packages -- which isn't exactly ideal.

Proguard should cater for this somehow.

Similar to what's mentioned here, I suspect all of these errors are down to a similar root cause:

  • https://sourceforge.net/p/proguard/bugs/763/
  • https://github.com/Guardsquare/proguard/issues/392
  • https://sourceforge.net/p/proguard/bugs/704/
  • https://sourceforge.net/p/proguard/bugs/712/
  • https://community.guardsquare.com/t/modular-program-and-proguard/4057

Example minimal config:

-dontshrink
-dontoptimize

-keep class module-info
-keepattributes *
 
-keep public class com.certak.Main {
    public static void main(java.lang.String[]);
}

I find it a bit odd that Proguard won't bring its documentation/examples/functionality into the 20th century. It's still filled up with useless examples re: midlets, J2ME, xlets, applets, etc. These things would easily be noticed and solved. Is Dexguard the same?

credmond avatar Dec 14 '24 17:12 credmond