This class may be removed in the future. Consider the replacements in JEP 193 'Variable Handles': http://openjdk.java.net/jeps/193
@Override public char getChar(long byteIndex) { return unsafe.getChar(baseAdress + byteIndex); }
public static char getChar( Object obj, long offset ) { return unsafe.getChar( obj, offset ); }
/** * Gets char value from object field. * * @param obj Object. * @param fieldOff Field offset. * @return Char value from object field. */ public static char getCharField(Object obj, long fieldOff) { return UNSAFE.getChar(obj, fieldOff); }
@Override char getChar(byte[] array, long offset) { return UNSAFE.getChar(array, arrayOffset + offset); } @Override void putChar(byte[] array, long offset, char c) { UNSAFE.putChar(array, arrayOffset + offset, c); }
static boolean isZero(byte[] bytes, int startPos, int length) { if (length <= 0) { return true; } final long baseOffset = BYTE_ARRAY_BASE_OFFSET + startPos; int remainingBytes = length & 7; final long end = baseOffset + remainingBytes; for (long i = baseOffset - 8 + length; i >= end; i -= 8) { if (UNSAFE.getLong(bytes, i) != 0) { return false; } } if (remainingBytes >= 4) { remainingBytes -= 4; if (UNSAFE.getInt(bytes, baseOffset + remainingBytes) != 0) { return false; } } if (remainingBytes >= 2) { return UNSAFE.getChar(bytes, baseOffset) == 0 && (remainingBytes == 2 || bytes[startPos + 2] == 0); } return bytes[startPos] == 0; }
static boolean equals(byte[] bytes1, int startPos1, byte[] bytes2, int startPos2, int length) { if (length <= 0) { return true; } final long baseOffset1 = BYTE_ARRAY_BASE_OFFSET + startPos1; final long baseOffset2 = BYTE_ARRAY_BASE_OFFSET + startPos2; int remainingBytes = length & 7; final long end = baseOffset1 + remainingBytes; for (long i = baseOffset1 - 8 + length, j = baseOffset2 - 8 + length; i >= end; i -= 8, j -= 8) { if (UNSAFE.getLong(bytes1, i) != UNSAFE.getLong(bytes2, j)) { return false; } } if (remainingBytes >= 4) { remainingBytes -= 4; if (UNSAFE.getInt(bytes1, baseOffset1 + remainingBytes) != UNSAFE.getInt(bytes2, baseOffset2 + remainingBytes)) { return false; } } if (remainingBytes >= 2) { return UNSAFE.getChar(bytes1, baseOffset1) == UNSAFE.getChar(bytes2, baseOffset2) && (remainingBytes == 2 || bytes1[startPos1 + 2] == bytes2[startPos2 + 2]); } return bytes1[startPos1] == bytes2[startPos2]; }
public final int getCharValue(Object obj) throws IllegalAccessException { if (!isAndroid && memOffset >= 0) { return FSTUtil.unFlaggedUnsafe.getChar(obj, memOffset); } return field.getChar(obj); }
@Override public char getChar(long byteIndex) { checkIndex(byteIndex,2); return unsafe.getChar(base, off + byteIndex); }
static boolean isZero(byte[] bytes, int startPos, int length) { if (length <= 0) { return true; } final long baseOffset = BYTE_ARRAY_BASE_OFFSET + startPos; int remainingBytes = length & 7; final long end = baseOffset + remainingBytes; for (long i = baseOffset - 8 + length; i >= end; i -= 8) { if (UNSAFE.getLong(bytes, i) != 0) { return false; } } if (remainingBytes >= 4) { remainingBytes -= 4; if (UNSAFE.getInt(bytes, baseOffset + remainingBytes) != 0) { return false; } } if (remainingBytes >= 2) { return UNSAFE.getChar(bytes, baseOffset) == 0 && (remainingBytes == 2 || bytes[startPos + 2] == 0); } return bytes[startPos] == 0; }
public static char getChar( long address ) { checkAccess( address, Character.BYTES ); return unsafe.getChar( address ); }
/** * Gets char value from byte array. Alignment aware. * * @param arr Byte array. * @param off Offset. * @return Char value from byte array. */ public static char getChar(byte[] arr, long off) { return UNALIGNED ? UNSAFE.getChar(arr, off) : getCharByByte(arr, off, BIG_ENDIAN); }
/** * Gets char value from given address. Alignment aware. * * @param addr Address. * @return Char value from given address. */ public static char getChar(long addr) { return UNALIGNED ? UNSAFE.getChar(addr) : getCharByByte(addr, BIG_ENDIAN); }
return ConstantTimeUtils.equalsConstantTime(result | (UNSAFE.getInt(bytes1, baseOffset1 + 3) ^ UNSAFE.getInt(bytes2, baseOffset2 + 3)) | (UNSAFE.getChar(bytes1, baseOffset1 + 1) ^ UNSAFE.getChar(bytes2, baseOffset2 + 1)) | (UNSAFE.getByte(bytes1, baseOffset1) ^ UNSAFE.getByte(bytes2, baseOffset2)), 0); case 6: return ConstantTimeUtils.equalsConstantTime(result | (UNSAFE.getInt(bytes1, baseOffset1 + 2) ^ UNSAFE.getInt(bytes2, baseOffset2 + 2)) | (UNSAFE.getChar(bytes1, baseOffset1) ^ UNSAFE.getChar(bytes2, baseOffset2)), 0); case 5: return ConstantTimeUtils.equalsConstantTime(result | case 3: return ConstantTimeUtils.equalsConstantTime(result | (UNSAFE.getChar(bytes1, baseOffset1 + 1) ^ UNSAFE.getChar(bytes2, baseOffset2 + 1)) | (UNSAFE.getByte(bytes1, baseOffset1) ^ UNSAFE.getByte(bytes2, baseOffset2)), 0); case 2: return ConstantTimeUtils.equalsConstantTime(result | (UNSAFE.getChar(bytes1, baseOffset1) ^ UNSAFE.getChar(bytes2, baseOffset2)), 0); case 1: return ConstantTimeUtils.equalsConstantTime(result |
public char getChar(final int index) { boundsCheck0(index, SIZE_OF_CHAR); return UNSAFE.getChar(byteArray, ARRAY_BASE_OFFSET + index); }
public char getChar(final int index) { if (SHOULD_BOUNDS_CHECK) { boundsCheck0(index, SIZE_OF_CHAR); } return UNSAFE.getChar(byteArray, addressOffset + index); }
public char getChar(final int index) { boundsCheck0(index, SIZE_OF_CHAR); return UNSAFE.getChar(null, address + index); }
public char getChar(final long index) { if (SHOULD_BOUNDS_CHECK) { boundsCheck0(index, SIZE_OF_CHAR); } return UNSAFE.getChar(null, addressOffset + index); }
/** * Gets char value from given address assuming that value stored in little-endian byte order and native byte order * is big-endian. Alignment aware. * * @param addr Address. * @return Char value from given address. */ public static char getCharLE(long addr) { return UNALIGNED ? Character.reverseBytes(UNSAFE.getChar(addr)) : getCharByByte(addr, false); }
/** * Gets char value from byte array assuming that value stored in little-endian byte order and native byte order * is big-endian. Alignment aware. * * @param arr Byte array. * @param off Offset. * @return Char value from byte array. */ public static char getCharLE(byte[] arr, long off) { return UNALIGNED ? Character.reverseBytes(UNSAFE.getChar(arr, off)) : getCharByByte(arr, off, false); }
public char getChar(final int index, final ByteOrder byteOrder) { boundsCheck0(index, SIZE_OF_SHORT); char bits = UNSAFE.getChar(byteArray, ARRAY_BASE_OFFSET + index); if (NATIVE_BYTE_ORDER != byteOrder) { bits = (char)Short.reverseBytes((short)bits); } return bits; }