@Test public void testHashCodeAscii() { for (int i = 0; i < 1000; ++i) { byte[] bytes = new byte[i]; char[] bytesChar = new char[i]; for (int j = 0; j < bytesChar.length; ++j) { bytesChar[j] = randomCharInByteRange(); bytes[j] = (byte) (bytesChar[j] & 0xff); } String string = new String(bytesChar); assertEquals("length=" + i, PlatformDependent.hashCodeAsciiSafe(bytes, 0, bytes.length), PlatformDependent.hashCodeAscii(bytes, 0, bytes.length)); assertEquals("length=" + i, PlatformDependent.hashCodeAsciiSafe(string), PlatformDependent.hashCodeAscii(string)); assertEquals("length=" + i, PlatformDependent.hashCodeAscii(bytes, 0, bytes.length), PlatformDependent.hashCodeAscii(string)); } }
public static int hashCodeAscii(byte[] bytes, int startPos, int length) { if (!hasUnsafe() || !PlatformDependent0.unalignedAccess()) { return hashCodeAsciiSafe(bytes, startPos, length); } return PlatformDependent0.hashCodeAscii(bytes, startPos, length); }
PlatformDependent { public static int hashCodeAscii(byte[] bytes, int startPos, int length) { if (!hasUnsafe() || !PlatformDependent0.unalignedAccess()) { return hashCodeAsciiSafe(bytes, startPos, length); } return PlatformDependent0.hashCodeAscii(bytes, startPos, length); } }
PlatformDependent { public static int hashCodeAscii(byte[] bytes, int startPos, int length) { if (!hasUnsafe() || !PlatformDependent0.unalignedAccess()) { return hashCodeAsciiSafe(bytes, startPos, length); } return PlatformDependent0.hashCodeAscii(bytes, startPos, length); } private  PlatformDependent(); }
PlatformDependent { public static int hashCodeAscii(byte[] bytes, int startPos, int length) { if (!hasUnsafe() || !PlatformDependent0.unalignedAccess()) { return hashCodeAsciiSafe(bytes, startPos, length); } return PlatformDependent0.hashCodeAscii(bytes, startPos, length); } private  PlatformDependent(); static boolean isAndroid(); static boolean isWindows(); static boolean isRoot(); static int javaVersion(); static boolean canEnableTcpNoDelayByDefault(); static boolean hasUnsafe(); static boolean isUnaligned(); static boolean directBufferPreferred(); static long maxDirectMemory(); static boolean hasJavassist(); static File tmpdir(); static int bitMode(); static int addressSize(); static long allocateMemory(long size); static void freeMemory(long address); static void throwException(Throwable t); static ConcurrentMap<K, V> newConcurrentHashMap(); static LongCounter newLongCounter(); static ConcurrentMap<K, V> newConcurrentHashMap(int initialCapacity); static ConcurrentMap<K, V> newConcurrentHashMap(int initialCapacity, float loadFactor); static ConcurrentMap<K, V> newConcurrentHashMap(
            int initialCapacity, float loadFactor, int concurrencyLevel); static ConcurrentMap<K, V> newConcurrentHashMap(Map<? extends K, ? extends V> map); static void freeDirectBuffer(ByteBuffer buffer); static long directBufferAddress(ByteBuffer buffer); static Object getObject(Object object, long fieldOffset); static Object getObjectVolatile(Object object, long fieldOffset); static int getInt(Object object, long fieldOffset); static long objectFieldOffset(Field field); static byte getByte(long address); static short getShort(long address); static int getInt(long address); static long getLong(long address); static byte getByte(byte[] data, int index); static short getShort(byte[] data, int index); static int getInt(byte[] data, int index); static long getLong(byte[] data, int index); static void putOrderedObject(Object object, long address, Object value); static void putByte(long address, byte value); static void putShort(long address, short value); static void putInt(long address, int value); static void putLong(long address, long value); static void putByte(byte[] data, int index, byte value); static void putShort(byte[] data, int index, short value); static void putInt(byte[] data, int index, int value); static void putLong(byte[] data, int index, long value); static void copyMemory(long srcAddr, long dstAddr, long length); static void copyMemory(byte[] src, int srcIndex, long dstAddr, long length); static void copyMemory(long srcAddr, byte[] dst, int dstIndex, long length); static void setMemory(byte[] dst, int dstIndex, long bytes, byte value); static void setMemory(long address, long bytes, byte value); static boolean equals(byte[] bytes1, int startPos1, byte[] bytes2, int startPos2, int length); static int hashCodeAscii(byte[] bytes, int startPos, int length); static int hashCodeAscii(CharSequence bytes); static AtomicReferenceFieldUpdater<U, W> newAtomicReferenceFieldUpdater(
            Class<? super U> tclass, String fieldName); static AtomicIntegerFieldUpdater<T> newAtomicIntegerFieldUpdater(
            Class<? super T> tclass, String fieldName); static AtomicLongFieldUpdater<T> newAtomicLongFieldUpdater(
            Class<? super T> tclass, String fieldName); static Queue<T> newMpscQueue(); static Queue<T> newSpscQueue(); static Queue<T> newFixedMpscQueue(int capacity); static ClassLoader getClassLoader(final Class<?> clazz); static ClassLoader getContextClassLoader(); static ClassLoader getSystemClassLoader(); static Deque<C> newConcurrentDeque(); }
PlatformDependent { public static int hashCodeAscii(byte[] bytes, int startPos, int length) { if (!hasUnsafe() || !PlatformDependent0.unalignedAccess()) { return hashCodeAsciiSafe(bytes, startPos, length); } return PlatformDependent0.hashCodeAscii(bytes, startPos, length); } private  PlatformDependent(); static boolean isAndroid(); static boolean isWindows(); static boolean isRoot(); static int javaVersion(); static boolean canEnableTcpNoDelayByDefault(); static boolean hasUnsafe(); static boolean isUnaligned(); static boolean directBufferPreferred(); static long maxDirectMemory(); static boolean hasJavassist(); static File tmpdir(); static int bitMode(); static int addressSize(); static long allocateMemory(long size); static void freeMemory(long address); static void throwException(Throwable t); static ConcurrentMap<K, V> newConcurrentHashMap(); static LongCounter newLongCounter(); static ConcurrentMap<K, V> newConcurrentHashMap(int initialCapacity); static ConcurrentMap<K, V> newConcurrentHashMap(int initialCapacity, float loadFactor); static ConcurrentMap<K, V> newConcurrentHashMap(
            int initialCapacity, float loadFactor, int concurrencyLevel); static ConcurrentMap<K, V> newConcurrentHashMap(Map<? extends K, ? extends V> map); static void freeDirectBuffer(ByteBuffer buffer); static long directBufferAddress(ByteBuffer buffer); static Object getObject(Object object, long fieldOffset); static Object getObjectVolatile(Object object, long fieldOffset); static int getInt(Object object, long fieldOffset); static long objectFieldOffset(Field field); static byte getByte(long address); static short getShort(long address); static int getInt(long address); static long getLong(long address); static byte getByte(byte[] data, int index); static short getShort(byte[] data, int index); static int getInt(byte[] data, int index); static long getLong(byte[] data, int index); static void putOrderedObject(Object object, long address, Object value); static void putByte(long address, byte value); static void putShort(long address, short value); static void putInt(long address, int value); static void putLong(long address, long value); static void putByte(byte[] data, int index, byte value); static void putShort(byte[] data, int index, short value); static void putInt(byte[] data, int index, int value); static void putLong(byte[] data, int index, long value); static void copyMemory(long srcAddr, long dstAddr, long length); static void copyMemory(byte[] src, int srcIndex, long dstAddr, long length); static void copyMemory(long srcAddr, byte[] dst, int dstIndex, long length); static void setMemory(byte[] dst, int dstIndex, long bytes, byte value); static void setMemory(long address, long bytes, byte value); static boolean equals(byte[] bytes1, int startPos1, byte[] bytes2, int startPos2, int length); static int hashCodeAscii(byte[] bytes, int startPos, int length); static int hashCodeAscii(CharSequence bytes); static AtomicReferenceFieldUpdater<U, W> newAtomicReferenceFieldUpdater(
            Class<? super U> tclass, String fieldName); static AtomicIntegerFieldUpdater<T> newAtomicIntegerFieldUpdater(
            Class<? super T> tclass, String fieldName); static AtomicLongFieldUpdater<T> newAtomicLongFieldUpdater(
            Class<? super T> tclass, String fieldName); static Queue<T> newMpscQueue(); static Queue<T> newSpscQueue(); static Queue<T> newFixedMpscQueue(int capacity); static ClassLoader getClassLoader(final Class<?> clazz); static ClassLoader getContextClassLoader(); static ClassLoader getSystemClassLoader(); static Deque<C> newConcurrentDeque(); static final boolean BIG_ENDIAN_NATIVE_ORDER; }