byte-buddy icon indicating copy to clipboard operation
byte-buddy copied to clipboard

on JDK24 gives warning of usage of deprecated methods

Open nagkumar opened this issue 5 months ago • 3 comments

> Task :test
WARNING: A terminally deprecated method in sun.misc.Unsafe has been called
WARNING: sun.misc.Unsafe::objectFieldOffset has been called by net.bytebuddy.dynamic.loading.ClassInjector$UsingUnsafe$Dispatcher$CreationAction (file:/C:/Users/nagkumar/.gradle/caches/modules-2/files-2.1/net.bytebuddy/byte-buddy/1.17.6/8c70cbc6950b2ae5291a98d5003e06406d633803/byte-buddy-1.17.6.jar)
WARNING: Please consider reporting this to the maintainers of class net.bytebuddy.dynamic.loading.ClassInjector$UsingUnsafe$Dispatcher$CreationAction
WARNING: sun.misc.Unsafe::objectFieldOffset will be removed in a future release

This is the error when using jdk 24, works fine with jdk 17..

using these versions..

    implementation("net.bytebuddy:byte-buddy:1.17.6")
    implementation("net.bytebuddy:byte-buddy-agent:1.17.6")

nagkumar avatar Jul 22 '25 13:07 nagkumar

This will no longer happen, as Byte Buddy already guards against the class not being available. You can however run with -Dnet.bytebuddy.safe=true. Are you using unsafe explicitly in your program somehow?

raphw avatar Jul 24 '25 19:07 raphw

when I give this jvm arg

-Dnet.bytebuddy.safe=true

those warnings are gone..

However not sure how to get back this warning as post true I made the value to false, no warning, and removed this -D property fully, then also no warning..

when I give this byte rewrite is not happening.. can you check the code changes needed

nagkumar avatar Jul 25 '25 02:07 nagkumar

Are you using unsafe explicitly in your program somehow?

No, but maybe indirectly ,as my two files to wrap method calls are in

https://github.com/nagkumar/java/tree/416e4b60dd4accdadf4aa7bc9113842b43b414d3/tutorials/testing/junit5/AssertsCounter/ACAgent/src/com/shivohamai/testing/tools/junit5/assertscounter/agent

nagkumar avatar Jul 25 '25 02:07 nagkumar