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 is executed when the class is initialized then JVM injection
  41  * updates the fields with the correct constants. The static block
  42  * is required to prevent the fields from being considered constant
  43  * variables, so the field values will be not be compiled directly into
  44  * any class that uses them.
  45  */
  46 
  47 final class UnsafeConstants {
  48 
  49     /**
  50      * This constructor is private because the class is not meant to
  51      * be instantiated.
  52      */
  53     private UnsafeConstants() {}
  54 
  55     /**
  56      * The size in bytes of a native pointer, as stored via {@link
  57      * #putAddress}.  This value will be either 4 or 8.  Note that the
  58      * sizes of other primitive types (as stored in native memory
  59      * blocks) is determined fully by their information content.
  60      *
  61      * @implNote
  62      * The actual value for this field is injected by the JVM.
  63      */
  64 
  65     static final int ADDRESS_SIZE0;
  66 
  67     /**
  68      * The size in bytes of a native memory page (whatever that is).
  69      * This value will always be a power of two.
  70      *
  71      * @implNote
  72      * The actual value for this field is injected by the JVM.
  73      */
  74 
  75     static final int PAGE_SIZE;
  76 
  77     /**
  78      * Flag whose value is true if and only if the native endianness
  79      * of this platform is big.
  80      *
  81      * @implNote
  82      * The actual value for this field is injected by the JVM.
  83      */
  84 
  85     static final boolean BIG_ENDIAN;
  86 
  87     /**
  88      * Flag whose value is true if and only if the platform can
  89      * perform unaligned accesses
  90      *
  91      * @implNote
  92      * The actual value for this field is injected by the JVM.
  93      */
  94 
  95     static final boolean UNALIGNED_ACCESS;
  96 
  97     static {
  98         ADDRESS_SIZE0 = 0;
  99         PAGE_SIZE = 0;
 100         BIG_ENDIAN = false;
 101         UNALIGNED_ACCESS = false;
 102     }
 103 }