@@ -40,14 +40,14 @@ public class FlexStack<T> {
4040
4141 /**
4242 * Soft limit imposed for growing arrays. JVMs do not allow to allocate arrays above certain
43- * length and you will get the following exception if trying to do so:
43+ * length, and you will get the following exception if trying to do so:
4444 *
4545 * <p>java.lang.OutOfMemoryError: Requested array size exceeds VM limit
4646 *
4747 * <p>Therefore the maxSize of any stack is capped to this value. This max value is not arbitrary
4848 * and was taken from OpenJDK.
4949 */
50- private static final int SOFT_MAX_ARRAY_LENGTH = Integer .MAX_VALUE - 8 ;
50+ private static final int MAX_ARRAY_LENGTH = Integer .MAX_VALUE - 8 ;
5151
5252 private T [] entries ;
5353
@@ -65,7 +65,7 @@ public class FlexStack<T> {
6565 @ SuppressWarnings ("unchecked" )
6666 public FlexStack (final int maxSize , final Class <T > klass ) {
6767 checkArgument (maxSize > 0 , "max size must be positive" );
68- checkArgument (maxSize <= SOFT_MAX_ARRAY_LENGTH , "max size is too large" );
68+ checkArgument (maxSize <= MAX_ARRAY_LENGTH , "max size is too large" );
6969
7070 int initialSize = (int ) Math .round (maxSize * INITIAL_SIZE_COEFICIENT ) + 1 ;
7171 this .currentCapacity = Math .min (initialSize , maxSize );
@@ -190,7 +190,7 @@ public void push(final T operand) {
190190
191191 private int newLength (final int oldCapacity , final int prefGrowth ) {
192192 final int growth = Math .max (1 , prefGrowth );
193- if (SOFT_MAX_ARRAY_LENGTH - growth < oldCapacity ) {
193+ if (MAX_ARRAY_LENGTH - growth < oldCapacity ) {
194194 return maxSize ;
195195 }
196196 return Math .min (oldCapacity + growth , maxSize );
0 commit comments