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 package java.lang.invoke;
26
27 import java.nio.Buffer;
28 import java.nio.ByteBuffer;
29
30 import static java.lang.invoke.MethodHandleStatics.UNSAFE;
31
32 /**
33 * The base class for generated byte array and byte buffer view
34 * implementations
35 */
36 abstract class VarHandleByteArrayBase {
37 // Buffer.address
38 static final long BUFFER_ADDRESS;
39 // Buffer.limit
40 static final long BUFFER_LIMIT;
41 // ByteBuffer.hb
42 static final long BYTE_BUFFER_HB;
43 // ByteBuffer.isReadOnly
44 static final long BYTE_BUFFER_IS_READ_ONLY;
45
46 static {
47 try {
48 BUFFER_ADDRESS = UNSAFE.objectFieldOffset(
49 Buffer.class.getDeclaredField("address"));
50
51 BUFFER_LIMIT = UNSAFE.objectFieldOffset(
52 Buffer.class.getDeclaredField("limit"));
53
54 BYTE_BUFFER_HB = UNSAFE.objectFieldOffset(
55 ByteBuffer.class.getDeclaredField("hb"));
56
57 BYTE_BUFFER_IS_READ_ONLY = UNSAFE.objectFieldOffset(
58 ByteBuffer.class.getDeclaredField("isReadOnly"));
59 }
60 catch (ReflectiveOperationException e) {
61 throw new Error(e);
62 }
63 }
64
65 static final boolean BE = UNSAFE.isBigEndian();
66
67 static IllegalStateException newIllegalStateExceptionForMisalignedAccess(int index) {
68 return new IllegalStateException("Misaligned access at index: " + index);
69 }
70 }
|
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 package java.lang.invoke;
26
27 import java.nio.Buffer;
28 import java.nio.ByteBuffer;
29
30 import static java.lang.invoke.MethodHandleStatics.UNSAFE;
31
32 /**
33 * The base class for generated byte array and byte buffer view
34 * implementations
35 */
36 abstract class VarHandleByteArrayBase {
37 // Buffer.address
38 static final long BUFFER_ADDRESS
39 = UNSAFE.objectFieldOffset(Buffer.class, "address");
40
41 // Buffer.limit
42 static final long BUFFER_LIMIT
43 = UNSAFE.objectFieldOffset(Buffer.class, "limit");
44
45 // ByteBuffer.hb
46 static final long BYTE_BUFFER_HB
47 = UNSAFE.objectFieldOffset(ByteBuffer.class, "hb");
48
49 // ByteBuffer.isReadOnly
50 static final long BYTE_BUFFER_IS_READ_ONLY
51 = UNSAFE.objectFieldOffset(ByteBuffer.class, "isReadOnly");
52
53 static final boolean BE = UNSAFE.isBigEndian();
54
55 static IllegalStateException newIllegalStateExceptionForMisalignedAccess(int index) {
56 return new IllegalStateException("Misaligned access at index: " + index);
57 }
58 }
|