Build Failed with Java 21, proguard 7.4.2, Spring boot 3.2

Faile message:
[proguard] ProGuard, version 7.4.2
[proguard] Exception in thread “main” java.lang.NoSuchMethodError: ‘void proguard.io.ClassReader.(boolean, boolean, boolean, boolean, boolean, proguard.classfile.util.WarningPrinter, proguard.classfile.visitor.ClassVisitor)’
[proguard] at proguard.InputReader.execute(InputReader.java:93)
[proguard] at proguard.pass.PassRunner.run(PassRunner.java:24)
[proguard] at proguard.ProGuard.readInput(ProGuard.java:330)
[proguard] at proguard.ProGuard.execute(ProGuard.java:123)
[proguard] at proguard.ProGuard.main(ProGuard.java:648)

Here is maven plugin configuration:

           <plugin>
                <groupId>com.github.wvengen</groupId>
                <artifactId>proguard-maven-plugin</artifactId>
                <version>2.6.0</version>
                <executions>
                    <execution>
                        <id>obfuscation-packaging</id>
                        <phase>package</phase>
                        <goals>
                            <goal>proguard</goal>
                        </goals>
                        <configuration>
                            <proguardVersion>7.4.2</proguardVersion>
                            <obfuscate>true</obfuscate>
                            <attach>true</attach>
                            <appendClassifier>false</appendClassifier>
                            <addMavenDescriptor>true</addMavenDescriptor>
                            <injar>${project.build.finalName}.jar</injar>
                            <injarNotExistsSkip>true</injarNotExistsSkip>
                            <libs>
                          
                                <lib>${java.home}/jmods/java.base.jmod(!**.jar;!module-info.class)</lib>
                            </libs>

                            <options>
                                <option>-keep
                                    class com.obfuscation.ObfuscationApplication {
                                    public static
                                    void main(java.lang.String[]);
                                    }
                                </option>
                                <option>-keepdirectories</option>
                            </options>
                        </configuration>
                    </execution>
                </executions>
                <dependencies>
                    <dependency>
                        <groupId>com.guardsquare</groupId>
                        <artifactId>proguard-base</artifactId>
                        <version>7.4.2</version>
                        <scope>runtime</scope>
                        <optional>true</optional>
                    </dependency>
                </dependencies>
            </plugin>

Please let me what could cause it. Thanks.

Even I use disable options, it still gives error. Is it any issue related to setup?

-dontshrink -dontoptimize -dontobfuscate

I fix the problem with setup.

  1. change java lib to

    ${java.home}/jmods/java.base.jmod
  2. add dependency for core even there is complains about duplication. It solves the problem with mismatch version from maven plugin.

    com.guardsquare
    proguard-core
    9.1.1
    runtime
1 Like