On Fri, 10 May 2024 10:06:55 GMT, Alan Bateman <[email protected]> wrote:
> This is the implementation changes for JEP 471.
>
> The methods in sun.misc.Unsafe for on-heap and off-heap access are deprecated
> for removal. This means a removal warning at compile time. No methods have
> been removed. A deprecated message is added to each of the methods but
> unlikely to be seen as the JDK does not generate or publish the API docs for
> this class.
>
> A new command line option --sun-misc-unsafe-memory-access=$value is
> introduced to allow or deny access to these methods. The default proposed for
> JDK 23 is "allow" so no change in behavior compared to JDK 22 or previous
> releases.
>
> A new test is added to test the command line option settings. The existing
> micros for FFM that use Unsafe are updated to suppress the removal warning at
> compile time. A new micro is introduced with a small sample of methods to
> ensure the changes doesn't cause any perf regressions.
>
> For now, the changes include the update to the man page for the "java"
> command. It might be that this has to be separated out so that it goes with
> other updates in the release.
src/jdk.unsupported/share/classes/sun/misc/Unsafe.java line 1764:
> 1762: }
> 1763: // set to true by first usage of memory-access method
> 1764: private static @Stable boolean memoryAccessWarned;
Very nice code. The fact that you only need to report first use (and not first
use per module, like in FFM) simplify things a bit (and, most importantly,
avoids the need to make all unsafe methods caller sensitive!).
src/jdk.unsupported/share/classes/sun/misc/Unsafe.java line 1869:
> 1867: default -> {
> 1868: // emit warning
> 1869: log("--sun-misc-unsafe-memory-access ignored,
> value '" + value +
The FFM code throws if an unknown value is passed. Here we log. Should we try
to be more consistent?
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/19174#discussion_r1601362348
PR Review Comment: https://git.openjdk.org/jdk/pull/19174#discussion_r1601364811