You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Error in running the zerocode tests in JDK23/21Β #704
Thanks for your interest. Assigned to you now. You can proceed please.
My suggestion would be to try it locally first, once you get an idea of the problem and the fix, then raise a PR with changing the Java version here(Line No.20).
@rkampani I tried messing around a little bit, but eventually never replied in the thread.
One thing I found trying to research on a random error from using JDK 21 and running mvn test is that it comes from mockito-core which is used by the juckito dependency for tests.
I tried updating mockito-core through dependency management and the specific error I was looking into was fixed.
(juckito has no more releases so an upgrade not possible)
The problem with this approach was that I noticed not all tests run with the previous mockito-core version was executed using the latest version. This complicates things (a lot I guess)?.
I assume the requirement is to only use a newer JDK to build, run and pass all tests - don't update the projects source code version used aka 1.8 -> 21.
@authorjapps I would love some info/discussion/feedback on this - even a short answer. This is a valuable experience for me even If I don't get to practically contribute.
@rkampani Does my approach sound a good start? What is your strategy for approaching this issue? Again I would appreciate knowledge sharing for experience.
Hey @thanasissot, thanks! AFAIK, You were spot on βThe issue stems from changes introduced newer JDK , where Java has tightened encapsulation and access control on internal fields of platform classes such as java.util.Optional. Specifically, we're seeing the error: Failed making field 'java.util.Optional#value' accessible when running tests using Jukito β a testing framework that combines JUnit and Guice β on JDK 21.0.6 or 23.0.1. This problem is triggered by Gson attempting to reflectively access the private value field inside Optional, which is now restricted by newer JDK versions. However, Jukitoβs reliance on an older version of Mockito added some additional complexity.
To address this, we had a few options:
Option1: Add a custom TypeAdapter.
Option2: Use the --add-opens JVM option in pom .( This is a quick hacky workaround that violates Javaβs encapsulation)
Option3: Migrate to a different library or JAR. as @authorjapps mentioned..
I went with Option 1 (custom TypeAdapter),β which provides as it offers a clean solution with minimal code refactoring : ) . I also made sure to exclude any conflicting mockito dependencies to avoid potential version issues.
I've opened a draft PR for now ββI remember you had shown interest in this request earlier, so if you'd like, feel free to take a look and build on top of it. Once youβve pushed the final changes, we can go ahead and clean up the draft. Donβt hesitate to reach out if you need any support β Iβm happy to help!
Activity
thanasissot commentedon Apr 20, 2025
first timer trying to work on contributing. can I get the assignment?
can I get more info?
Tests are failing with JDK21,23 when lower JDKs are all successful?
authorjapps commentedon Apr 20, 2025
@thanasissot , lower lower JDKs are all successful. This is very much evident from the latest CI builds.
You can have a look at the last CI runs here.
Also have a look at the POM file here (Line No. 100 and 101).
Let me know if you think you can still proceed with the fix, then we can assign the issue to you.
rkampani commentedon Apr 25, 2025
Is anyone currently working on this issue? If not, I'd be happy to take it on
authorjapps commentedon Apr 26, 2025
Hello @rkampani , noone seems picked up yet.
Thanks for your interest. Assigned to you now. You can proceed please.
My suggestion would be to try it locally first, once you get an idea of the problem and the fix, then raise a PR with changing the Java version here(Line No.20).
thanasissot commentedon Apr 26, 2025
@rkampani I tried messing around a little bit, but eventually never replied in the thread.
One thing I found trying to research on a random error from using JDK 21 and running mvn test is that it comes from mockito-core which is used by the juckito dependency for tests.
I tried updating mockito-core through dependency management and the specific error I was looking into was fixed.
(juckito has no more releases so an upgrade not possible)
The problem with this approach was that I noticed not all tests run with the previous mockito-core version was executed using the latest version. This complicates things (a lot I guess)?.
I assume the requirement is to only use a newer JDK to build, run and pass all tests - don't update the projects source code version used aka 1.8 -> 21.
@authorjapps I would love some info/discussion/feedback on this - even a short answer. This is a valuable experience for me even If I don't get to practically contribute.
@rkampani Does my approach sound a good start? What is your strategy for approaching this issue? Again I would appreciate knowledge sharing for experience.
authorjapps commentedon Apr 27, 2025
Thanks @thanasissot, Great findings.
This is interesting. Can we use another library?
Then get rid of "juckito"!
We should have the Test coverage, than using "juckito" :)
Error in running the zerocode tests in JDK23/21 authorjapps#704
rkampani commentedon Apr 28, 2025
Hey @thanasissot, thanks! AFAIK, You were spot on βThe issue stems from changes introduced newer JDK , where Java has tightened encapsulation and access control on internal fields of platform classes such as java.util.Optional. Specifically, we're seeing the error: Failed making field 'java.util.Optional#value' accessible when running tests using Jukito β a testing framework that combines JUnit and Guice β on JDK 21.0.6 or 23.0.1. This problem is triggered by Gson attempting to reflectively access the private value field inside Optional, which is now restricted by newer JDK versions. However, Jukitoβs reliance on an older version of Mockito added some additional complexity.
To address this, we had a few options:
I went with Option 1 (custom TypeAdapter),β which provides as it offers a clean solution with minimal code refactoring : ) . I also made sure to exclude any conflicting mockito dependencies to avoid potential version issues.
I've opened a draft PR for now ββI remember you had shown interest in this request earlier, so if you'd like, feel free to take a look and build on top of it. Once youβve pushed the final changes, we can go ahead and clean up the draft. Donβt hesitate to reach out if you need any support β Iβm happy to help!
authorjapps commentedon Apr 28, 2025
Both @rkampani and @thanasissot have been added as collaborators here:
#713 (comment)
Error in running the zerocode tests in JDK23/21 authorjapps#704
Error in running the zerocode tests in JDK23/21 authorjapps#704
Error in running the zerocode tests in JDK23/21 authorjapps#704
Merge pull request #713 from rkampani/feature/704-fixJunitsJdk24