Skip to content

Error in running the zerocode tests in JDK23/21Β #704

Closed

Description

@mailtoach79

Observed the following error in running the tests in higher version of JDK(21.0.6 and JDK(23.0.1).

Appreciate if anyone can provide the fix.

Image

Activity

  1. thanasissot commented on Apr 20, 2025

    @thanasissot
    Collaborator

    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?

  2. authorjapps commented on Apr 20, 2025

    @authorjapps
    Owner

    Tests are failing with JDK21,23 when lower JDKs are all successful?

    @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).

    <java-compiler-source.version>1.8</java-compiler-source.version>
    <java-compiler-target.version>1.8</java-compiler-target.version>
    

    Let me know if you think you can still proceed with the fix, then we can assign the issue to you.

  3. rkampani commented on Apr 25, 2025

    @rkampani
    Collaborator

    Is anyone currently working on this issue? If not, I'd be happy to take it on

  4. authorjapps commented on Apr 26, 2025

    @authorjapps
    Owner

    Is anyone currently working on this issue? If not, I'd be happy to take it on

    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).

  5. thanasissot commented on Apr 26, 2025

    @thanasissot
    Collaborator

    @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.

  6. authorjapps commented on Apr 27, 2025

    @authorjapps
    Owner

    Thanks @thanasissot, Great findings.

    (juckito has no more releases so an upgrade not possible)

    This is interesting. Can we use another library?
    Then get rid of "juckito"!

    We should have the Test coverage, than using "juckito" :)

  7. rkampani commented on Apr 28, 2025

    @rkampani
    Collaborator

    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!

  8. authorjapps commented on Apr 28, 2025

    @authorjapps
    Owner

    Both @rkampani and @thanasissot have been added as collaborators here:
    #713 (comment)

  9. added a commit that references this issue on May 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions