Skip to content

Commit

Permalink
8298596: vmTestbase/nsk/sysdict/vm/stress/chain/chain008/chain008.jav…
Browse files Browse the repository at this point in the history
…a fails with "NoClassDefFoundError: Could not initialize class java.util.concurrent.ThreadLocalRandom"

Reviewed-by: mbaesken
Backport-of: c3242ee452c25b5038283c68e65541122a10df0d
  • Loading branch information
Amos Shi committed Aug 16, 2024
1 parent df4a4ea commit 0683b19
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions test/hotspot/jtreg/vmTestbase/nsk/share/gc/gp/GarbageUtils.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2007, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2007, 2023, 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
Expand Down Expand Up @@ -234,11 +234,21 @@ public static int eatMemory(ExecutionController stresser, GarbageProducer gp, lo
long.class,
OOM_TYPE.class);

private static MethodHandle eat;

static {
try {
eat = MethodHandles.lookup().findStatic(GarbageUtils.class, "eatMemoryImpl", mt);
} catch (Exception nsme) {
// Can't run the test for some unexpected reason
throw new RuntimeException(nsme);
}
}


public static int eatMemory(ExecutionController stresser, GarbageProducer gp, long initialFactor, long minMemoryChunk, long factor, OOM_TYPE type) {
try {
// Using a methodhandle invoke of eatMemoryImpl to prevent inlining of it
MethodHandles.Lookup lookup = MethodHandles.lookup();
MethodHandle eat = lookup.findStatic(GarbageUtils.class, "eatMemoryImpl", mt);
return (int) eat.invoke(stresser, gp, initialFactor, minMemoryChunk, factor, type);
} catch (OutOfMemoryError e) {
return numberOfOOMEs++;
Expand Down

0 comments on commit 0683b19

Please sign in to comment.