[12] 8206403: ByteArrayOutputStream hugeCapacity method can return invalid capacity
Brian Burkhalter
brian.burkhalter at oracle.com
Tue Jul 24 00:40:48 UTC 2018
On Jul 23, 2018, at 5:26 PM, Martin Buchholz <martinrb at google.com> wrote:
> I'm the author of most of the MAX_ARRAY_SIZE code in the jdk.
> We should be as consistent as we can given the history.
Thanks for the history lesson.
> It all looks pretty similar.
There are in fact a number of them in java.base:
private static final int MAX_ARRAY_SIZE = Integer.MAX_VALUE - 8;
src/java.base/share/classes/java/io/ByteArrayOutputStream.java
private static final int MAX_ARRAY_SIZE = Integer.MAX_VALUE - 8;
src/java.base/share/classes/java/lang/AbstractStringBuilder.java
private static final int MAX_ARRAY_SIZE = Integer.MAX_VALUE - 8;
src/java.base/share/classes/java/util/AbstractCollection.java
private static final int MAX_ARRAY_SIZE = Integer.MAX_VALUE - 8;
src/java.base/share/classes/java/util/ArrayDeque.java
private static final int MAX_ARRAY_SIZE = Integer.MAX_VALUE - 8;
src/java.base/share/classes/java/util/ArrayList.java
static final int MAX_ARRAY_SIZE = Integer.MAX_VALUE - 8;
src/java.base/share/classes/java/util/concurrent/ConcurrentHashMap.java
private static final int MAX_ARRAY_SIZE = Integer.MAX_VALUE - 8;
src/java.base/share/classes/java/util/concurrent/PriorityBlockingQueue.java
private static final int MAX_ARRAY_SIZE = Integer.MAX_VALUE - 8;
src/java.base/share/classes/java/util/Hashtable.java
private static final int MAX_ARRAY_SIZE = Integer.MAX_VALUE - 8;
src/java.base/share/classes/java/util/PriorityQueue.java
static final long MAX_ARRAY_SIZE = Integer.MAX_VALUE - 8;
src/java.base/share/classes/java/util/stream/Nodes.java
private static final int MAX_ARRAY_SIZE = Integer.MAX_VALUE - 8;
src/java.base/share/classes/java/util/Vector.java
> So unsurprisingly I prefer the status quo.
I am wondering whether MAX_ARRAY_SIZE is even still necessary in current VMs? I don’t know the low level details enough to comment on that.
Thanks,
Brian
More information about the core-libs-dev
mailing list