JDK-8145082 : Remove sun.misc.Unsafe dependency from sun.nio.cs.StringUTF16
  • Type: Bug
  • Component: core-libs
  • Affected Version: 9
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2015-12-10
  • Updated: 2016-03-25
  • Resolved: 2015-12-10
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 9
9 b97Fixed
Related Reports
Relates :  
Description
Looks like the Compact Strings work inadvertently introduced a
dependency on sun.misc.Unsafe. ( just temporary confusion with
having two Unsafes until the jdk.unsupported module is defined )

diff --git a/src/java.base/share/classes/sun/nio/cs/StringUTF16.java b/src/java.base/share/classes/sun/nio/cs/StringUTF16.java
--- a/src/java.base/share/classes/sun/nio/cs/StringUTF16.java
+++ b/src/java.base/share/classes/sun/nio/cs/StringUTF16.java
@@ -25,8 +25,8 @@

package sun.nio.cs;

-import static sun.misc.Unsafe.ARRAY_BYTE_BASE_OFFSET;
-import static sun.misc.Unsafe.ARRAY_BYTE_INDEX_SCALE;
+import static jdk.internal.misc.Unsafe.ARRAY_BYTE_BASE_OFFSET;
+import static jdk.internal.misc.Unsafe.ARRAY_BYTE_INDEX_SCALE;

class StringUTF16 {

@@ -35,5 +35,5 @@
                              ARRAY_BYTE_BASE_OFFSET + ARRAY_BYTE_INDEX_SCALE * index * 2L);
    }

-    private static final sun.misc.Unsafe unsafe = sun.misc.Unsafe.getUnsafe();
+    private static final jdk.internal.misc.Unsafe unsafe = jdk.internal.misc.Unsafe.getUnsafe();
}