Skip to content

Terminal Deprecation Warning for sun.misc.Unsafe memory-access (JEP 471) #615

@cmdjulian

Description

@cmdjulian

Expected behavior

The HiveMQ Embedded Broker should run on modern JDKs (JDK 23+) without issuing terminal deprecation warnings. Dependency versions should be updated to ensure compatibility with JEP 471 (Phase 2 warnings in JDK 25 and Phase 3 exceptions in JDK 26).

Actual behavior

When running with HiveMQ CE on JDK 25, the JVM issues a runtime warning caused by Guava:

WARNING: A terminally deprecated method in sun.misc.Unsafe has been called
WARNING: sun.misc.Unsafe::objectFieldOffset has been called by com.google.common.util.concurrent.AbstractFuture$UnsafeAtomicHelper
WARNING: sun.misc.Unsafe::objectFieldOffset will be removed in a future release

To Reproduce

  • Steps: Run a Kotlin project using HiveMQ CE Embedded on JVM 25.
  • Current Dependency: com.google.guava:guava:33.3.1-jre (as seen in the trace).

Details

  • Affected HiveMQ CE version(s): 2025.x (Embedded)
  • Used JVM version: 25

Context: JEP 471 & Migration Path

As outlined in JEP 471, sun.misc.Unsafe::objectFieldOffset is now terminally deprecated. In JDK 25, the JVM defaults to --sun-misc-unsafe-memory-access=warn. In JDK 26, this will escalate to deny (throwing an exception), which will cause AbstractFuture initialization to fail and potentially crash the broker.

Solution Found

The issue has already been addressed upstream by the Guava maintainers in Guava 33.4.8.

  • Ref: Guava Issue #7811
  • Fix: Guava now uses java.lang.invoke.VarHandle (standard since JDK 9) instead of Unsafe for its atomic helpers when running on modern JVMs.

Suggested Fix

Update the Guava dependency in HiveMQ CE from 33.3.1-jre to 33.4.8 (or newer, current is 33.5.0-jre).

// Suggested change in build.gradle
implementation("com.google.guava:guava:33.4.8-jre")

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