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
2 - If I remove the warnings, with the option -dontwarn, an error is generated:
Unexpected error while performing partial evaluation:
Class = [...]
Method = [<init>()V]</init>
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]</init>
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?
With
-dontwarn
you can indeed trigger the problem that you see, because part of the class hierarchy is missing in the preverification step.Due to the modularization of the java runtime, you need to explicitly specify the relevant jmod files with
-libraryjars
, e.g. jmods/java.desktop.jmod, in addition to jmods/java.base.jmod.Thank you for your answer, but I don't really understand.
Why ProGuard doesn't know basic classes?
Do I have to add all the basic classes like JFrame?
ProGuard is generic for all types of Java: JSE, JME, Android,...., in all their versions. You therefore need to explicitly specify the appropriate runtime. With older versions of Java SE, this was simply rt.jar. With the new modularized Java, this is a collection of jmod files. Admittedly, it's inconvenient to figure out the required ones. There are tools that print out the dependencies for you (
jdeps --list-deps
). We may make it more convenient in the future.Thanks. I know where to find the Java installation. But which path do I give to the jdeps?
When using Java 11+ you have to use a different -libraryjars input.
The missing classes would be found in this for example:
-libraryjars <java.home>/jmods/java.desktop.jmod(!**.jar;!module-info.class)</java.home>
Thank you for your answer.
This line "-libraryjars <java.home>/jmods/java.desktop.jmod(!**.jar;!module-info.class)" is already in my config file. I tried to replace it by the exact path, and it didn't change anything.
None of the basic java libraries are found (like the BufferedIimage) so I get thousands of warnings and it ends with this error: "Error: Can't find common super class of..."</java.home>