apache / apache/netbeans

Remove sun.misc.Unsafe memory access API usage

Open
#8,259 4 comments 4 reactions 0 assignees View on GitHub
Code cleanup Java priority:high Upgrade JDK
Dominant language
Java
Stars
3.1k
Forks
935
Avg merge
2d 3h
Merged PRs (30d)
17

Description

- JDK 24 logs warnings to console on misc.Unsafe mem access API use,
- "JDK 26 or later" will set `--sun-misc-unsafe-memory-access` to `deny`
- last phase removes the methods

see [JEP 498](https://openjdk.org/jeps/498).

nb 25 started on JDK 24 in terminal will print the following to console:
```
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 (jar:file:/home/mbien/dev/nb/java/maven/lib/guava-33.2.1-jre.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
```
to get the full stack trace, set `--sun-misc-unsafe-memory-access=debug`

(but there might be more usages, guava might have it fixed in the next release https://github.com/google/guava/issues/6806#issuecomment-2590312869) edit: guava and guice is resolved

Contributor guide

Open the contributing guide

Research direction

No NetBeans source files or tests are named. Start by searching the NetBeans sources and bundled dependencies for sun.misc.Unsafe memory-access calls, then run NetBeans on JDK 24 with --sun-misc-unsafe-memory-access=debug; done means the remaining usage is removed or replaced and the warnings no longer occur.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
devtools
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.