> `Collections.rotate` method contains a bug. This method throws 
> IndexOutOfBoundsException on arrays larger than $2^{30}$ elements. The way to 
> reproduce:
> 
> final int size = (1 << 30) + 1;
> final List<Byte> list = new ArrayList<>(size);
> for (int i = 0; i < size; ++i)
>     list.add((byte) 0);
> Collections.rotate(list, size - 1);
> 
> Output:
> ```Exception in thread "main" java.lang.IndexOutOfBoundsException: Index 
> -2147483648 out of bounds for length 1073741825```
> 
> In that case private method `Collections.rotate1` will be called. And the 
> line:
> `i += distance;`
> will cause overflow. I fixed this method and wrote a test for it.
> 
> I've signed the Oracle Contributor Agreement, but I don't have permission to 
> raise a bug in the JDK Bug System.
> 
> Kindly ask you to raise a bug.

Nikita Sakharin has updated the pull request incrementally with 141 additional 
commits since the last revision:

 - 8314990: Generational ZGC: Strong OopStorage stats reported as weak roots
   
   Reviewed-by: stefank, eosterlund
 - 8312749: Generational ZGC: Tests crash with assert(index == 0 || 
is_power_of_2(index))
   
   Co-authored-by: Stefan Karlsson <stef...@openjdk.org>
   Co-authored-by: Erik Ă–sterlund <eosterl...@openjdk.org>
   Reviewed-by: thartmann, ayang, kvn
 - 8314951: VM build without C2 still fails after JDK-8313530
   
   Reviewed-by: dnsimon, kvn
 - 8219567: Name of first parameter of RandomAccessFile(String,String) is 
inconsistent
   
   Reviewed-by: jlu, vtewari, rriggs, jpai
 - 8314850: SharedRuntime::handle_wrong_method() gets called too often when 
resolving Continuation.enter
   
   Reviewed-by: rpressler, aph
 - 8314759: VirtualThread.parkNanos timeout adjustment when pinned should be 
replaced
   
   Reviewed-by: aturbanov, shade, dfuchs
 - 8306040: HttpResponseInputStream.available() returns 1 on empty stream
   
   Reviewed-by: dfuchs
 - 8314656: GHA: No need for Debian ports keyring installation after JDK-8313701
   
   Reviewed-by: fyang
 - 8314554: Debian/Ubuntu should not link OpenJDK with --as-needed link option
   
   Reviewed-by: erikj
 - 8314883: Java_java_util_prefs_FileSystemPreferences_lockFile0 write result 
errno in missing case
   
   Reviewed-by: jpai, shade, vtewari
 - ... and 131 more: https://git.openjdk.org/jdk/compare/69672701...b49bf280

-------------

Changes:
  - all: https://git.openjdk.org/jdk/pull/15270/files
  - new: https://git.openjdk.org/jdk/pull/15270/files/69672701..b49bf280

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=jdk&pr=15270&range=06
 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=15270&range=05-06

  Stats: 14502 lines in 618 files changed: 9508 ins; 1142 del; 3852 mod
  Patch: https://git.openjdk.org/jdk/pull/15270.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/15270/head:pull/15270

PR: https://git.openjdk.org/jdk/pull/15270

Reply via email to