Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions src/main/java/net/ladenthin/streambuffer/StreamBuffer.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,15 @@ public class StreamBuffer implements Closeable {
static final String EXCEPTION_MESSAGE_VALIDATE_OFFSET_AND_LENGTH_TO_WRITE_INDEX_OUT_OF_BOUNDS_EXCEPTION =
"Invalid offset or length given to validateOffsetAndLengthToWrite.";

/**
* Largest {@code byte[]} length this class allocates: {@code Integer.MAX_VALUE - 8}.
* Same value as {@code jdk.internal.util.ArraysSupport.SOFT_MAX_ARRAY_LENGTH}, mirrored
* because that class is JDK-internal (not exported, absent on Java 8).
* Reason: VMs reserve array header words; HotSpot rejects {@code Integer.MAX_VALUE} and
* {@code Integer.MAX_VALUE - 1} with "Requested array size exceeds VM limit", on any heap size.
*/
static final int MAX_ARRAY_LENGTH = Integer.MAX_VALUE - 8;

/**
* An object to get an unique access to the {@link #buffer}. It is needed to
* get an exclusive access for read and write operations.
Expand Down Expand Up @@ -132,15 +141,6 @@ public class StreamBuffer implements Closeable {
*/
private final AtomicLong totalBytesRead = new AtomicLong();

/**
* Largest {@code byte[]} length this class allocates: {@code Integer.MAX_VALUE - 8}.
* Same value as {@code jdk.internal.util.ArraysSupport.SOFT_MAX_ARRAY_LENGTH}, mirrored
* because that class is JDK-internal (not exported, absent on Java 8).
* Reason: VMs reserve array header words; HotSpot rejects {@code Integer.MAX_VALUE} and
* {@code Integer.MAX_VALUE - 1} with "Requested array size exceeds VM limit", on any heap size.
*/
static final int MAX_ARRAY_LENGTH = Integer.MAX_VALUE - 8;

/**
* Maximum size of a single byte array during consolidation. Default {@link #MAX_ARRAY_LENGTH}.
*/
Expand Down
Loading