8341243: Use ArraySupport.SOFT_MAX_ARRAY_LENGTH for max array size in java.base

Reviewed-by: jpai, smarks
This commit is contained in:
Eirik Bjørsnøs 2024-10-02 01:27:03 +00:00 committed by Jaikiran Pai
parent 8d6d37fea1
commit 0f381137cb
15 changed files with 51 additions and 41 deletions

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 1994, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1994, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -30,6 +30,7 @@ import java.util.function.BiConsumer;
import java.util.function.Function;
import java.util.function.BiFunction;
import jdk.internal.access.SharedSecrets;
import jdk.internal.util.ArraysSupport;
/**
* This class implements a hash table, which maps keys to values. Any
@ -390,12 +391,9 @@ public class Hashtable<K,V>
}
/**
* The maximum size of array to allocate.
* Some VMs reserve some header words in an array.
* Attempts to allocate larger arrays may result in
* OutOfMemoryError: Requested array size exceeds VM limit
* The maximum size of array to allocate
*/
private static final int MAX_ARRAY_SIZE = Integer.MAX_VALUE - 8;
private static final int MAX_ARRAY_SIZE = ArraysSupport.SOFT_MAX_ARRAY_LENGTH;
/**
* Increases the capacity of and internally reorganizes this