Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NoClassDefFoundError when using a dependency with package private abstract class #373

Open
dannygonzalez opened this issue Nov 22, 2023 · 5 comments

Comments

@dannygonzalez
Copy link

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

@rubenpieters
Copy link
Contributor

rubenpieters commented Nov 22, 2023

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?

@dannygonzalez
Copy link
Author

dannygonzalez commented Nov 22, 2023

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

@rubenpieters
Copy link
Contributor

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.

@robinlefever
Copy link
Contributor

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.

@dannygonzalez
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants