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

Remove sun.misc.Unsafe.{shouldBeInitialized,ensureClassInitialized}

XMLWordPrintable

    • Icon: CSR CSR
    • Resolution: Approved
    • Icon: P4 P4
    • 22
    • core-libs
    • None
    • source, binary
    • low
    • Hide
      A search of 175973022 classes in 484751 artifacts found 23 usages of Unsafe.shouldBeInitialized, of which 8 are unique, and 121 usages of Unsafe.ensureClassInitialized, of which 31 are unique. So not a lot of usage, and the few that we samples seem to be compiled to older releases.
      Show
      A search of 175973022 classes in 484751 artifacts found 23 usages of Unsafe.shouldBeInitialized, of which 8 are unique, and 121 usages of Unsafe.ensureClassInitialized, of which 31 are unique. So not a lot of usage, and the few that we samples seem to be compiled to older releases.
    • Java API
    • JDK

      Summary

      Remove sun.misc.Unsafe.shouldBeInitialized(Class) and sun.misc.Unsafe.ensureClassInitialized(Class). These methods have been deprecated, for removal, since JDK 15. The small number of libraries using these methods should migrate to using java.lang.invoke.MethodHandles.Lookup.ensureInitialized(Class) (added in Java 15).

      Problem

      sun.misc.Unsafe is an undocumented/unsupported critical internal API. We need to encourage libraries that use this API directly to move to using standard APIs where possible.

      Solution

      Remove sun.misc.Unsafe.shouldBeInitialized(Class) and sun.misc.Unsafe.ensureClassInitialized(Class).

      Add a release note.

      Specification

      Remove sun.misc.Unsafe.shouldBeInitialized(Class) and sun.misc.Unsafe.ensureClassInitialized(Class).

            alanb Alan Bateman
            alanb Alan Bateman
            Mandy Chung, Roger Riggs
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: