Package com.alexkasko.unsafe.bytearray

Byte array operations using sun.misc.Unsafe

See: Description

Package com.alexkasko.unsafe.bytearray Description

Byte array operations using sun.misc.Unsafe

This package contains one public frontend class ByteArrayTool with two implementations - main one (UnsafeByteArrayTool) that uses Unsafe and fallback one (BitShiftLittleEndianByteArrayTool) that uses bit shifting. It contains operations for reading and writing primitives from/into byte arrays and additional copy operation.

Operations

All operations with Unsafe are done using platform endianness (little endian on most platform), bitshift backend always uses little endian byte order.

Boundary checks

With Unsafe backend all operations have boundary checks using assert keyword. With assertions enabled in runtime (-ea java switch) illegal memory access will thow AssertionError. Without assertions illegal memory access will crash JVM.

Usage example (in tests): github link

Copyright © 2014. All Rights Reserved.