proguard icon indicating copy to clipboard operation
proguard copied to clipboard

NoClassDefFoundError when using a dependency with package private abstract class

Open dannygonzalez opened this issue 1 year ago • 5 comments

There is an issue with the latest proguard 7.4.0 which we didn't have when using 7.3.2

I have recreated the issue in the attached project. The project has a dependency on a lib module. the lib module has the following class hierarchy:

hierarchy

AbstractFoo is package private within the lib module.

The main application references only ConcreteFoo1, ConcreteFoo2 and FooInterface. It has no reference to AbstractFoo. However when I build this project I will get the following error: java.lang.NoClassDefFoundError: com/screamingfrog/utils/foo/AbstractFoo

If I make AbstractFoo public then this error goes away.

Looks like the updated proguard has an issue with this package private class. It looks like it is still somehow referencing the unobfuscated version when it shouldn't be.

To recreate this issue: Update the path to the Java 21 JDK in jdk.home for each pom.xml

Then run:

mvn clean package
java -jar proguard-issue/target/proguard-issue-0.0.1-SNAPSHOT.jar 

proguard_issue.zip

dannygonzalez avatar Nov 22 '23 09:11 dannygonzalez

Hello @dannygonzalez I can observe the crash in the project you linked. However changing the version from proguard 7.4 to 7.3.2 in proguard-issue/pom.xml and lib/pom.xml does not resolve the crash for me. How did you observe the correctly functioning behavior with an earlier proguard version?

rubenpieters avatar Nov 22 '23 15:11 rubenpieters

Hi @rubenpieters I wasn't quite accurate.

We discovered this issue when we updated from Java 17 to Java 21 which made us update the following sections also. Here are what they were before the update to Java21:

<jdk.version>17.0.7</jdk.version> <jdk.home>/Library/Java/JavaVirtualMachines/jdk-17.0.7.jdk/Contents/Home</jdk.home>

and the proguard-core version was 9.0.8

I have attached a project that doesn't exhibit the issue with the above versions updated.

proguard_issue_good.zip

dannygonzalez avatar Nov 22 '23 15:11 dannygonzalez

Thanks for explaining it further. I can indeed confirm it is a regression in proguard-core 9.0.9 compared to 9.0.8 . We have scheduled to look at this internally to see what is the cause of the regression.

rubenpieters avatar Nov 23 '23 17:11 rubenpieters

Hi @dannygonzalez , We were able to narrow down the issue to the field type specialization optimization. We don’t have a fix for the issue yet, but you should be able to disable the optimization by adding the following rule to your proguard configuration: -optimizations !field/specialization/type Please let us know whether this fixes the issue on your end as well.

robinlefever avatar Nov 28 '23 10:11 robinlefever

Hi @robinlefever Thanks, yes that seems to fix the issue for us. We will monitor this bug to see when this is fixed so we can wind back the workaround.

dannygonzalez avatar Nov 28 '23 10:11 dannygonzalez