On Tue, 12 Nov 2024 12:18:03 GMT, Per Minborg <pminb...@openjdk.org> wrote:

> I want to add such a test case, but I am worried that it will consume too 
> many resources during the build process.
> 
> ```java
> /**
>  * @test
>  * @bug 8343984
>  * @summary Test that the append capacity is close to Integer.MaxValue
>  * @run main/othervm -Xms6g -Xmx6g HugeAppend
>  */
> 
> public final class HugeAppend {
>     public static void main(String[] args) {
>         StringBuilder buf = new StringBuilder();
>         int loop4 = Integer.MAX_VALUE / 4;
>         for (int i = 0; i < loop4; i++) {
>             buf.append(true);
>         }
> 
>         buf.setLength(0);
>         int loop5 = Integer.MAX_VALUE / 5;
>         for (int i = 0; i < loop5; i++) {
>             buf.append(false);
>         }
>     }
> }
> ```

In the master branch, this test will succeed in jtreg

* jtreg

make test TEST="jtreg:test/jdk/java/util/BitSet/HugeToString.java"


* result

==============================
Test summary
==============================
   TEST                                              TOTAL  PASS  FAIL ERROR   
   jtreg:test/jdk/java/util/BitSet/HugeToString.java     1     1     0     0   
==============================
TEST SUCCESS


But running it directly will cause JVM Crash

 ~/git/jdk_x/build/macosx-aarch64-server-release/images/jdk/bin/java -Xms6g 
-Xmx6g HugeAppend

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

PR Comment: https://git.openjdk.org/jdk/pull/22027#issuecomment-2470661592

Reply via email to