< prev index next >

modules/javafx.graphics/src/main/java/com/sun/marlin/OffHeapArray.java

Print this page




  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package com.sun.marlin;
  27 
  28 import static com.sun.marlin.MarlinConst.LOG_UNSAFE_MALLOC;
  29 import java.lang.reflect.Field;
  30 import java.security.AccessController;
  31 import java.security.PrivilegedAction;
  32 import sun.misc.Unsafe;
  33 
  34 /**
  35  *
  36  * @author bourgesl
  37  */
  38 final class OffHeapArray  {
  39 
  40     // unsafe reference
  41     static final Unsafe UNSAFE;
  42     // size of int / float
  43     static final int SIZE_INT;
  44 
  45     static {
  46         UNSAFE = AccessController.doPrivileged(new PrivilegedAction<Unsafe>() {
  47             @Override
  48             public Unsafe run() {
  49                 Unsafe ref = null;
  50                 try {
  51                     final Field field = Unsafe.class.getDeclaredField("theUnsafe");
  52                     field.setAccessible(true);
  53                     ref = (Unsafe) field.get(null);
  54                 } catch (Exception e) {
  55                     throw new InternalError("Unable to get sun.misc.Unsafe instance", e);
  56                 }




  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package com.sun.marlin;
  27 
  28 import static com.sun.marlin.MarlinConst.LOG_UNSAFE_MALLOC;
  29 import java.lang.reflect.Field;
  30 import java.security.AccessController;
  31 import java.security.PrivilegedAction;
  32 import sun.misc.Unsafe;
  33 
  34 /**
  35  *

  36  */
  37 final class OffHeapArray  {
  38 
  39     // unsafe reference
  40     static final Unsafe UNSAFE;
  41     // size of int / float
  42     static final int SIZE_INT;
  43 
  44     static {
  45         UNSAFE = AccessController.doPrivileged(new PrivilegedAction<Unsafe>() {
  46             @Override
  47             public Unsafe run() {
  48                 Unsafe ref = null;
  49                 try {
  50                     final Field field = Unsafe.class.getDeclaredField("theUnsafe");
  51                     field.setAccessible(true);
  52                     ref = (Unsafe) field.get(null);
  53                 } catch (Exception e) {
  54                     throw new InternalError("Unable to get sun.misc.Unsafe instance", e);
  55                 }


< prev index next >