Skip to content

Silence warning with latest Java LTS (25) in maven 3.9.x#11729

Open
mpetricek-corp wants to merge 1 commit intoapache:maven-3.9.xfrom
mpetricek-corp:maven-3.9.x
Open

Silence warning with latest Java LTS (25) in maven 3.9.x#11729
mpetricek-corp wants to merge 1 commit intoapache:maven-3.9.xfrom
mpetricek-corp:maven-3.9.x

Conversation

@mpetricek-corp
Copy link

When used with latest Java LTS (i.e. 25 at the moment), maven 3.9.x outputs a warning:

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 (file:/usr/share/maven/lib/guava.jar)
WARNING: Please consider reporting this to the maintainers of class com.google.common.util.concurrent.AbstractFuture$UnsafeAtomicHelper
WARNING: sun.misc.Unsafe::objectFieldOffset will be removed in a future release

Properly fixing this in 3.9.x branch would mean upgrading Guava to newer version, which I understood is impossible due to dependency version collisions/limitations.
This fix silences the warning, in similar manner to MNG-8248

…utputs a warning:

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 (file:/usr/share/maven/lib/guava.jar)
WARNING: Please consider reporting this to the maintainers of class com.google.common.util.concurrent.AbstractFuture$UnsafeAtomicHelper
WARNING: sun.misc.Unsafe::objectFieldOffset will be removed in a future release

Properly fixing this in 3.9.x branch would mean upgrading Guava to newer version, which I understood is impossible due to dependency version collisions/limitations
This fix silences the warning
@slawekjaranowski
Copy link
Member

how can I reproduce such warning ...

@cstamas
Copy link
Member

cstamas commented Feb 17, 2026

Isn't this 26 and not 25?

@slawekjaranowski
Copy link
Member

even with 26 I can not see it

@Bukama
Copy link
Contributor

Bukama commented Feb 17, 2026

From my expierence this comes from dependencies. For example when building maven core project with Maven 3.9.12 and Java 25 some tests throw this

D:\Github\Maven\maven>mvn clean verify site > ..\maven_build.log
WARNING: A terminally deprecated method in sun.misc.Unsafe has been called
WARNING: sun.misc.Unsafe::staticFieldBase has been called by com.diffplug.spotless.java.ModuleHelper (file:/C:/Users/matth/.m2/repository/com/diffplug/spotless/spotless-lib/4.0.0/spotless-lib-4.0.0.jar)
WARNING: Please consider reporting this to the maintainers of class com.diffplug.spotless.java.ModuleHelper
WARNING: sun.misc.Unsafe::staticFieldBase will be removed in a future release
OpenJDK 64-Bit Server VM warning: Sharing is only supported for boot loader classes because bootstrap classpath has been appended
OpenJDK 64-Bit Server VM warning: Sharing is only supported for boot loader classes because bootstrap classpath has been appended
OpenJDK 64-Bit Server VM warning: Sharing is only supported for boot loader classes because bootstrap classpath has been appended
OpenJDK 64-Bit Server VM warning: Sharing is only supported for boot loader classes because bootstrap classpath has been appended
OpenJDK 64-Bit Server VM warning: Sharing is only supported for boot loader classes because bootstrap classpath has been appended
OpenJDK 64-Bit Server VM warning: Sharing is only supported for boot loader classes because bootstrap classpath has been appended
WARNING: A restricted method in java.lang.System has been called
WARNING: java.lang.System::load has been called by org.jline.nativ.JLineNativeLoader in an unnamed module (file:/C:/Users/matth/.m2/repository/org/jline/jline-native/3.30.6/jline-native-3.30.6.jar)
WARNING: Use --enable-native-access=ALL-UNNAMED to avoid a warning for callers in this module
WARNING: Restricted methods will be blocked in a future release unless native access is enabled

OpenJDK 64-Bit Server VM warning: Sharing is only supported for boot loader classes because bootstrap classpath has been appended
OpenJDK 64-Bit Server VM warning: Sharing is only supported for boot loader classes because bootstrap classpath has been appended
OpenJDK 64-Bit Server VM warning: Sharing is only supported for boot loader classes because bootstrap classpath has been appended
WARNING: A terminally deprecated method in sun.misc.Unsafe has been called
WARNING: sun.misc.Unsafe::staticFieldBase has been called by com.google.inject.internal.aop.HiddenClassDefiner (file:/C:/Users/matth/.m2/repository/com/google/inject/guice/5.1.0/guice-5.1.0-classes.jar)
WARNING: Please consider reporting this to the maintainers of class com.google.inject.internal.aop.HiddenClassDefiner
WARNING: sun.misc.Unsafe::staticFieldBase will be removed in a future release
WARNING: A restricted method in java.lang.System has been called
WARNING: java.lang.System::load has been called by org.fusesource.jansi.internal.JansiLoader in an unnamed module (file:/D:/Github/Maven/maven/impl/maven-executor/target/dependency/apache-maven-3.9.11/lib/jansi-2.4.2.jar)
WARNING: Use --enable-native-access=ALL-UNNAMED to avoid a warning for callers in this module
WARNING: Restricted methods will be blocked in a future release unless native access is enabled

WARNING: A terminally deprecated method in sun.misc.Unsafe has been called
WARNING: sun.misc.Unsafe::staticFieldBase has been called by com.google.inject.internal.aop.HiddenClassDefiner (file:/D:/Github/Maven/maven/impl/maven-executor/target/dependency/apache-maven-3.9.11/lib/guice-5.1.0-classes.jar)
WARNING: Please consider reporting this to the maintainers of class com.google.inject.internal.aop.HiddenClassDefiner
WARNING: sun.misc.Unsafe::staticFieldBase will be removed in a future release

@slawekjaranowski
Copy link
Member

@mpetricek-corp
Copy link
Author

I observed it on debian, with system openJDK 25 installed. Not sure if different instantiation of JDK 25 could silence that warning by default.

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

Successfully merging this pull request may close these issues.

4 participants

Comments