I used to use proguard 5 on java 8, but as I now use Java 11, I've downloaded proguard 6.1.1, but I've encountered issues.
1 - Lot of warnings are generated because proguard does not find basic classes present in java.awt
or java.lang
:
Warning: ...: can't find referenced class java.awt.image.BufferedImage
Warning: ...: can't find referenced class javax.swing.JPanel
Warning: ...: can't find referenced class java.lang.management.ManagementFactory
I can remove all the warning by adding a global or specifics -dontwarn
, but I don't think it's ideal. Is there a better solution?
2 - If I remove the warnings, with the option -dontwarn
, an error is generated:
Unexpected error while performing partial evaluation:
Class = [...]
Method = [<init>()V]
Exception = [java.lang.IllegalArgumentException] (Can't find common super class of [softwares/progeria/nuclei/NucleiLabeling] (with 1 known super classes) and [java/lang/InterruptedException] (with 4 known super classes))
Unexpected error while preverifying:
Class = [...]
Method = [<init>()V]
Exception = [java.lang.IllegalArgumentException] (Can't find common super class of [...] (with 1 known super classes) and [java/lang/InterruptedException] (with 4 known super classes))
Error: Can't find common super class of [...] (with 1 known super classes) and [java/lang/InterruptedException] (with 4 known super classes)
The class that generates this error extends a JFrame and runs perfectly. How can I fix this error?
Your application depends on various runtime libraries which you need to tell ProGuard about.
Prior to Java 8, all of the built-in java libraries such as AWT
, Swing
etc. were bundled together in rt.jar
. You would have supplied something like the following parameter to ProGuard:
-libraryjars <java.home>/lib/rt.jar
or if using Ant:
<libraryjar file="${java.home}/jre/lib/rt.jar" />
Since Java 9, these runtime libraries are packaged as a number of jmod files under <java.home>/jmods
. As a minimum you will probably need:
-libraryjars <java.home>/jmods/java.base.jmod(!**.jar;!module-info.class)
or if using Ant:
<libraryjar file="${java.home}/jmods/java.base.jmod(!**.jar;!module-info.class)" />
However this will not include AWT or Swing, which are now in java.desktop.jmod
. Precisely which of the jmods you need to link will depend on which Java runtime libraries your application makes use of.
In your case it looks like you need
-libraryjars <java.home>/jmods/java.base.jmod(!**.jar;!module-info.class)
-libraryjars <java.home>/jmods/java.destop.jmod(!**.jar;!module-info.class)
-libraryjars <java.home>/jmods/java.management.jmod(!**.jar;!module-info.class)
or
<libraryjar file="${java.home}/jmods/java.base.jmod" jarfilter="!**.jar" filter="!module-info.class" />
<libraryjar file="${java.home}/jmods/java.desktop.jmod" jarfilter="!**.jar" filter="!module-info.class" />
<libraryjar file="${java.home}/jmods/java.management.jmod" jarfilter="!**.jar" filter="!module-info.class" />
A web search for jmod <some class or package>
or simply JDK Module Summary
should help you identify any others you might need.
Note: If there is no <java.home>/jmods folder, and you use openjdk please note that there's a separate package for it search for java-11-openjdk-jmods to install the right package
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With