Skip to content

Jython 2.7.2 on JRE25: JEP 498 sun.misc.Unsafe deprecation warning from bundled Guava #449

Closed

Description

@yogi1967

(yes, AI helped me write this - sorry 😉)

(AbstractFuture$UnsafeAtomicHelper) under JDK 24+

Running Jython 2.7.2 embedded under JDK 25 produces this at startup:

WARNING: A terminally deprecated method in sun.misc.Unsafe has been called
WARNING: sun.misc.Unsafe::objectFieldOffset has been called by org.python.google.common.util.concurrent.AbstractFuture$UnsafeAtomicHelper (file:.../jython-standalone.jar)
WARNING: sun.misc.Unsafe::objectFieldOffset will be removed in a future release

Root cause: the shaded Guava copy under org.python.google.common.* still uses Unsafe.objectFieldOffset() in AbstractFuture$UnsafeAtomicHelper's static initializer (confirmed via javap -c against the bundled jar — 5 calls, one per field: waiters, listeners, value, thread, next). JDK 24+ warns on this per JEP 498; the memory-access methods are slated for removal per JEP 471.

I looked as to whether upgrading to 2.7.4 resolves this. Per NEWS, 2.7.2 bundles guava-22.0-android, and 2.7.4 (GH-269) bumps to guava-32.0.1. However, Guava's own issue tracker (google/guava#6806, PR #7555/#7759) shows the fix — trying VarHandle before Unsafe in AbstractFuture — didn't land until after 33.4.0-jre, i.e. Guava 33.4.1+. So poss even the current Jython 2.7.4 with Guava 32.0.1 still triggers this warning. I'm note sure that upgrading Jython alone won't fix it as things stand?

Questions:

  1. Is there an open issue/PR tracking a further Guava bump to ≥33.4.1 in the shaded jar? I didn't find one in the GH-3xx range.
  2. I assume Jython 2.7.5 is targeting support for java 25? Is specifically silencing this warning on the roadmap at all, or is it considered out of scope for the 2.7.5 release?
  3. Is there a supported way to suppress this at the embedding-application level (e.g. via a system property Jython sets internally) short of the host JVM launcher passing --sun-misc-unsafe-memory-access=allow?

Environment: Jython 2.7.2 standalone jar, embedded in a desktop Java app, running under JDK 25.

Thanks

Activity

  1. jeff5 commented on Jul 26, 2026

    @jeff5
    Member
    • Is there an open issue/PR tracking a further Guava bump to ≥33.4.1 in the shaded jar? I didn't find one in the GH-3xx range.

    Already on it: #438, #448

    • I assume Jython 2.7.5 is targeting support for java 25? Is specifically silencing this warning on the roadmap at all, or is it considered out of scope for the 2.7.5 release?

    We'll tolerate Java 25 to the extent possible. #435 ;-) Not suppress, but avoid generating it where we can.

    • Is there a supported way to suppress this at the embedding-application level (e.g. via a system property Jython sets internally) short of the host JVM launcher passing --sun-misc-unsafe-memory-access=allow?

    Probably not in an application that embeds Jython (rather than runs Jython with the launcher or java command). It's a thing you ask the JVM to tolerate. I don't know if that can be changed once running. The launcher has sprouted options necessary to tolerate some unsafe access in #435.

    Have you noticed the jython-slim JAR which gives you more scope for choosing your own dependencies without shading?

  2. linked a pull request that will close this issueUpdate Apache commons and Guava JARs #448on Jul 26, 2026
  3. yogi1967 commented on Jul 26, 2026

    @yogi1967
    Author

    Thanks for replying... So I'm not sure where that leaves 2.7.4/5? Are you saying that this unsafe warning will somehow be eliminated in 2.7.5 (by somebody, somehow)? Or does someone have to do something? Thanks

  4. jeff5 commented on Jul 27, 2026

    @jeff5
    Member

    If your code or a dependency does something that raises such warnings, it is outside our scope to suppress it, and I think you ought to know anyway. However, we have made some code changes (in 2.7.4 I think) and are updating dependencies, including the Guava one, to avoid generating it where we can. So it's as fixed as it can be.

    I think you still get it if you operate on a file handle in Windows.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions