1 /*
   2  * Copyright (c) 2019, Red Hat Inc. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  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 jdk.internal.misc;
  27 
  28 /**
  29  * A class used to expose details of the underlying hardware that
  30  * configure the operation of class Unsafe.  This class is
  31  * package-private as the only intended client is class Unsafe.
  32  * All fields in this class must be static final constants.
  33  *
  34  * @since 13
  35  *
  36  * @implNote
  37  *
  38  * The JVM injects hardware-specific values into all the static fields
  39  * of this class during JVM initialization. The static initialization
  40  * block exists to prevent the fields from being considered constant
  41  * variables, so the field values will be not be compiled directly into
  42  * any class that uses them.
  43  */
  44 
  45 final class UnsafeConstants {
  46 
  47     /**
  48      * This constructor is private because the class is not meant to
  49      * be instantiated.
  50      */
  51     private UnsafeConstants() {}
  52 
  53     /**
  54      * The size in bytes of a native pointer, as stored via {@link
  55      * #putAddress}.  This value will be either 4 or 8.  Note that the
  56      * sizes of other primitive types (as stored in native memory
  57      * blocks) is determined fully by their information content.
  58      *
  59      * @implNote
  60      * The actual value for this field is injected by the JVM.
  61      */
  62 
  63     static final int ADDRESS_SIZE0;
  64 
  65     /**
  66      * The size in bytes of a native memory page (whatever that is).
  67      * This value will always be a power of two.
  68      *
  69      * @implNote
  70      * The actual value for this field is injected by the JVM.
  71      */
  72 
  73     static final int PAGE_SIZE;
  74     
  75     /**
  76      * Flag whose value is true if and only if the native endianness
  77      * of this platform is big.
  78      *
  79      * @implNote
  80      * The actual value for this field is injected by the JVM.
  81      */
  82     
  83     static final boolean BE;
  84 
  85     /**
  86      * Flag whose value is true if and only if the platform can
  87      * perform unaligned accesses
  88      *
  89      * @implNote
  90      * The actual value for this field is injected by the JVM.
  91      */
  92     
  93     static final boolean UNALIGNED_ACCESS;
  94 
  95     static {
  96         ADDRESS_SIZE0 = 0;
  97         PAGE_SIZE = 0;
  98         BE = false;
  99         UNALIGNED_ACCESS = false;
 100     }
 101 }