Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8342381

Implement JEP 498: Warn upon Use of Memory-Access Methods in sun.misc.Unsafe

XMLWordPrintable

    • Icon: CSR CSR
    • Resolution: Approved
    • Icon: P4 P4
    • 24
    • core-libs
    • None
    • behavioral
    • low
    • The warning may be problematic in some environments but it can be suppressed by running with --sun-misc-unsafe-memory-access=allow.
    • add/remove/modify command line option
    • JDK

      Summary

      Change the default value of the command line option --sun-misc-unsafe-memory-access from allow to warn. A warning is printed to standard error on the first occasion that any memory-access method in sun.misc.Unsafe is used.

      Problem

      JEP 471 introduced --sun-misc-unsafe-memory-access={allow|warn|debug|deny}, which controls the runtime behavior of sun.misc.Unsafe's memory-access methods, with the default value of allow.

      The next step in the roadmap is to change the default value of the option from allow to warn. A future JEP and CSR will propose to change the default value to deny.

      Solution

      Change the default value of the command line option --sun-misc-unsafe-memory-access to warn. This is the equivalent of running with --sun-misc-unsafe-memory-access=warn. A warning is printed to standard error on the first occasion that any memory-access method is used.

      The warning can be suppressed in this release by running with --sun-misc-unsafe-memory-access=allow.

      Developers can prepare for the future by testing with --sun-misc-unsafe-memory-access=deny.

      Specification

      There are no specification changes.

      The output from java -X for the command line option changes to:

          --sun-misc-unsafe-memory-access=<value>
                            allow or deny usage of unsupported API sun.misc.Unsafe
                            <value> is one of "allow", "warn", "debug", or "deny".
                            The default value is "warn".

            rpressler Ron Pressler
            rpressler Ron Pressler
            Alan Bateman, Chen Liang
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: