Skip to content

Commit 0683b19

Browse files
author
Amos Shi
committed
8298596: vmTestbase/nsk/sysdict/vm/stress/chain/chain008/chain008.java fails with "NoClassDefFoundError: Could not initialize class java.util.concurrent.ThreadLocalRandom"
Reviewed-by: mbaesken Backport-of: c3242ee452c25b5038283c68e65541122a10df0d
1 parent df4a4ea commit 0683b19

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

test/hotspot/jtreg/vmTestbase/nsk/share/gc/gp/GarbageUtils.java

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2007, 2022, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2007, 2023, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -234,11 +234,21 @@ public static int eatMemory(ExecutionController stresser, GarbageProducer gp, lo
234234
long.class,
235235
OOM_TYPE.class);
236236

237+
private static MethodHandle eat;
238+
239+
static {
240+
try {
241+
eat = MethodHandles.lookup().findStatic(GarbageUtils.class, "eatMemoryImpl", mt);
242+
} catch (Exception nsme) {
243+
// Can't run the test for some unexpected reason
244+
throw new RuntimeException(nsme);
245+
}
246+
}
247+
248+
237249
public static int eatMemory(ExecutionController stresser, GarbageProducer gp, long initialFactor, long minMemoryChunk, long factor, OOM_TYPE type) {
238250
try {
239251
// Using a methodhandle invoke of eatMemoryImpl to prevent inlining of it
240-
MethodHandles.Lookup lookup = MethodHandles.lookup();
241-
MethodHandle eat = lookup.findStatic(GarbageUtils.class, "eatMemoryImpl", mt);
242252
return (int) eat.invoke(stresser, gp, initialFactor, minMemoryChunk, factor, type);
243253
} catch (OutOfMemoryError e) {
244254
return numberOfOOMEs++;

0 commit comments

Comments
 (0)