src/java.base/share/classes/java/nio/Direct-X-Buffer-bin.java.template
changeset 49210 7c795d301dbf
parent 48356 29e165bdf669
--- a/src/java.base/share/classes/java/nio/Direct-X-Buffer-bin.java.template	Mon Mar 12 21:30:58 2018 +0000
+++ b/src/java.base/share/classes/java/nio/Direct-X-Buffer-bin.java.template	Mon Mar 12 16:09:18 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -32,24 +32,40 @@
 #if[rw]
 
     private $type$ get$Type$(long a) {
-        $memtype$ x = UNSAFE.get$Memtype$Unaligned(null, a, bigEndian);
-        return $fromBits$(x);
+        try {
+            $memtype$ x = UNSAFE.get$Memtype$Unaligned(null, a, bigEndian);
+            return $fromBits$(x);
+        } finally {
+            Reference.reachabilityFence(this);
+        }
     }
 
     public $type$ get$Type$() {
-        return get$Type$(ix(nextGetIndex($BYTES_PER_VALUE$)));
+        try {
+            return get$Type$(ix(nextGetIndex($BYTES_PER_VALUE$)));
+        } finally {
+            Reference.reachabilityFence(this);
+        }
     }
 
     public $type$ get$Type$(int i) {
-        return get$Type$(ix(checkIndex(i, $BYTES_PER_VALUE$)));
+        try {
+            return get$Type$(ix(checkIndex(i, $BYTES_PER_VALUE$)));
+        } finally {
+            Reference.reachabilityFence(this);
+        }
     }
 
 #end[rw]
 
     private ByteBuffer put$Type$(long a, $type$ x) {
 #if[rw]
-        $memtype$ y = $toBits$(x);
-        UNSAFE.put$Memtype$Unaligned(null, a, y, bigEndian);
+        try {
+            $memtype$ y = $toBits$(x);
+            UNSAFE.put$Memtype$Unaligned(null, a, y, bigEndian);
+        } finally {
+            Reference.reachabilityFence(this);
+        }
         return this;
 #else[rw]
         throw new ReadOnlyBufferException();