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-protected as the only intended client is class Unsafe. 32 * 33 * @since 13 34 * 35 * @implNote 36 37 * The JVM injects values into all the static fields of this class 38 * during JVM initialization. A static initialization block is used to 39 * initialize these values but that is only done to communicate that 40 * each static final field is not statically foldable, and to avoid 41 * any possible circular dependency during vm initialization. The 42 * values assigned in the static block may not correspond to the 43 * hardware-specific constants installed by the JVM. 44 */ 45 46 final class UnsafeConstants { 47 48 /** 49 * This constructor is private because the class is not meant to 50 * be instantiated. 51 */ 52 private UnsafeConstants() {} 53 54 /** 55 * The size in bytes of a native pointer, as stored via {@link 56 * #putAddress}. This value will be either 4 or 8. Note that the 57 * sizes of other primitive types (as stored in native memory 58 * blocks) is determined fully by their information content. 59 * 60 * @implNote 61 * The actual value for this field is injected by JVM. A static 62 * initialization block is used to set the value here to 63 * communicate that this static final field is not statically 64 * foldable, and to avoid any possible circular dependency during 65 * vm initialization. 66 */ 67 68 static final int ADDRESS_SIZE; 69 70 /** 71 * The size in bytes of a native memory page (whatever that is). 72 * This value will always be a power of two. 73 * 74 * @implNote 75 * The actual value for this field is injected by JVM. A static 76 * initialization block is used to set the value here to 77 * communicate that this static final field is not statically 78 * foldable, and to avoid any possible circular dependency during 79 * vm initialization. 80 */ 81 82 static final int PAGE_SIZE; 83 84 /** 85 * flag whose value is true if and only if the native endianness 86 * of this platform is big. 87 */ 88 89 static final boolean BIG_ENDIAN; 90 91 /** 92 * flag whose value is true if and only if the platform can 93 * perform unaligned accesses 94 */ 95 96 static final boolean UNALIGNED_ACCESS; 97 98 static { 99 ADDRESS_SIZE = 0; 100 PAGE_SIZE = 0; 101 BIG_ENDIAN = false; 102 UNALIGNED_ACCESS = false; 103 } 104 }