Issue regarding hugeLength() method of ArraysSupport class in java.internal.util package

Raffaello Giulietti raffaello.giulietti at oracle.com
Wed Jul 27 10:19:59 UTC 2022


1. minLength < 0 means that there is an overflow in the preceding 
addition, so the error's message is correct.

2. + 3. hugeLength() is only ever invoked by the newLength() method just 
above. The javadoc spec of that method is quite clear about what 
newLength(), and thus hugeLength(), are expected to return and to throw.
The interplay between these methods implements the spec correctly.


Greetings
Raffaello



On 2022-07-27 08:25, Ananya Nayak wrote:
> After analysing the method declaration carefully I realized some bugs in 
> the code:
> 
>   1.the if condition on seeing min length as less than 0 returns out of 
> memory error with a message that "required length is too large" which is 
> contradictory to what we are checking in the condition.
> 
> 2. We should actually return the out of memory error when it exceeds the 
> SOFT_ARRAY_MAX_LENGTH.
> 
> 3. Moreover we are returning minLength in the third condition when we 
> actually shouldn't because it exceeds the limit
> 
> Kindly verify this.
> 
> 


More information about the core-libs-dev mailing list