Skip to content

fix: add replacement for deprecated methods in sun.misc.Unsafe#1661

Merged
0utplay merged 4 commits intonightlyfrom
unsafe-replacement
Jun 20, 2025
Merged

fix: add replacement for deprecated methods in sun.misc.Unsafe#1661
0utplay merged 4 commits intonightlyfrom
unsafe-replacement

Conversation

@derklaro
Copy link
Member

Motivation

All methods that are performing memory-access operations in sun.misc.Unsafe have been deprecated for removal in jdk 24. There are safe replacements available, however, as CloudNet supports (some) very old libraries we need that these methods stay available to support these old library versions.

Modification

Add a replacement for deprecated methods in sun.misc.Unsafe that are (partly) using safe replacements in an unsafe way. While the performance of the replacement will not be as good as the performance of sun.misc.Unsafe and some very spcial (and undocumented) method invocations might not be possible anymore, it at least ensures that most old libraries can still run on new jdk versions.

Result

Old libraries that are using deprecated methods from sun.misc.Unsafe will use a "safe" implementation (possibly slower) instead. This ensures that old libraries can continue to work on newer jdk versions.

@derklaro derklaro requested a review from 0utplay June 17, 2025 21:57
@derklaro derklaro self-assigned this Jun 17, 2025
@derklaro derklaro added v: 4.X This pull should be included in the 4.0 release t: fix A pull request introducing a fix for a bug. t: improvement The pull request improves existing code in: wrapper An issue/pull request releated to the wrapper module code labels Jun 17, 2025
@github-actions
Copy link

github-actions bot commented Jun 17, 2025

Test Results

 56 files  + 4   56 suites  +4   2m 26s ⏱️ -17s
566 tests +42  566 ✅ +42  0 💤 ±0  0 ❌ ±0 
931 runs  +42  931 ✅ +42  0 💤 ±0  0 ❌ ±0 

Results for commit c31c23f. ± Comparison against base commit eba28eb.

This pull request removes 31 and adds 73 tests. Note that renamed tests count towards both.
eu.cloudnetservice.driver.impl.document.DocumentSerialisationTest ‑ [4] {"b":1,"s":2,"i":3,"l":4,"f":5.0,"d":6.0,"c":"/","string":"Hello, World!","bol":true,"cloud":["Ben?","Yes","No","HoHoHoHo"],"world":{"hello":"world","insane":"!","this":"is"}}, PRETTY
eu.cloudnetservice.driver.impl.document.gson.JavaTimeSerializerTest ‑ [23] 06:45:49.825519729
eu.cloudnetservice.driver.impl.document.gson.JavaTimeSerializerTest ‑ [28] 06:45:49.825624444Z
eu.cloudnetservice.driver.impl.document.gson.JavaTimeSerializerTest ‑ [29] 06:45:49.825644241Z
eu.cloudnetservice.driver.impl.document.gson.JavaTimeSerializerTest ‑ [30] 06:45:49.825664840+05:00
eu.cloudnetservice.driver.impl.document.gson.JavaTimeSerializerTest ‑ [31] 06:45:49.825679137-03:00
eu.cloudnetservice.driver.impl.document.gson.JavaTimeSerializerTest ‑ [34] 2025-06-18T06:45:49.825800583
eu.cloudnetservice.driver.impl.document.gson.JavaTimeSerializerTest ‑ [39] 2025-06-18T06:45:49.825927560Z
eu.cloudnetservice.driver.impl.document.gson.JavaTimeSerializerTest ‑ [4] 2025-06-18T06:45:49.820397824Z
eu.cloudnetservice.driver.impl.document.gson.JavaTimeSerializerTest ‑ [5] 2025-06-18T06:37:29.820401551Z
…
eu.cloudnetservice.driver.impl.document.DocumentSerialisationTest ‑ [4] {"b":1,"s":2,"i":3,"l":4,"f":5.0,"d":6.0,"c":"/","string":"Hello, World!","bol":true,"cloud":["Ben?","Yes","No","HoHoHoHo"],"world":{"insane":"!","this":"is","hello":"world"}}, PRETTY
eu.cloudnetservice.driver.impl.document.gson.JavaTimeSerializerTest ‑ [23] 06:57:26.595877194
eu.cloudnetservice.driver.impl.document.gson.JavaTimeSerializerTest ‑ [28] 06:57:26.595978433Z
eu.cloudnetservice.driver.impl.document.gson.JavaTimeSerializerTest ‑ [29] 06:57:26.595998670Z
eu.cloudnetservice.driver.impl.document.gson.JavaTimeSerializerTest ‑ [30] 06:57:26.596018307+05:00
eu.cloudnetservice.driver.impl.document.gson.JavaTimeSerializerTest ‑ [31] 06:57:26.596033405-03:00
eu.cloudnetservice.driver.impl.document.gson.JavaTimeSerializerTest ‑ [34] 2025-06-18T06:57:26.596152758
eu.cloudnetservice.driver.impl.document.gson.JavaTimeSerializerTest ‑ [39] 2025-06-18T06:57:26.596281057Z
eu.cloudnetservice.driver.impl.document.gson.JavaTimeSerializerTest ‑ [4] 2025-06-18T06:57:26.584608110Z
eu.cloudnetservice.driver.impl.document.gson.JavaTimeSerializerTest ‑ [5] 2025-06-18T06:49:06.584611075Z
…

♻️ This comment has been updated with latest results.

@0utplay 0utplay merged commit 8676986 into nightly Jun 20, 2025
5 checks passed
@0utplay 0utplay deleted the unsafe-replacement branch June 20, 2025 14:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

in: wrapper An issue/pull request releated to the wrapper module code t: fix A pull request introducing a fix for a bug. t: improvement The pull request improves existing code v: 4.X This pull should be included in the 4.0 release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants