|
29 | 29 | * @modules java.base/jdk.internal.misc java.compiler
|
30 | 30 | * @run main/othervm -Xmx1G -XX:MaxMetaspaceSize=200M
|
31 | 31 | * -XX:StartFlightRecording -Xshare:off
|
| 32 | + * -Xlog:gc+metaspace*=debug |
32 | 33 | * jdk.jfr.event.runtime.TestMetaspaceAllocationFailure
|
33 |
| - * @run main/othervm -Xmx1G -XX:CompressedClassSpaceSize=200M |
| 34 | + * @run main/othervm -Xmx1G -XX:CompressedClassSpaceSize=10M |
34 | 35 | * -XX:StartFlightRecording -Xshare:off
|
| 36 | + * -Xlog:gc+metaspace*=debug |
35 | 37 | * jdk.jfr.event.runtime.TestMetaspaceAllocationFailure
|
36 | 38 | */
|
37 | 39 | package jdk.jfr.event.runtime;
|
|
40 | 42 | import jdk.jfr.consumer.RecordingStream;
|
41 | 43 | import jdk.test.lib.classloader.GeneratingCompilingClassLoader;
|
42 | 44 | import jdk.test.lib.Asserts;
|
43 |
| - |
| 45 | +import jtreg.SkippedException; |
44 | 46 |
|
45 | 47 | public class TestMetaspaceAllocationFailure {
|
| 48 | + private static final int MAX_ITERATIONS = 100; |
| 49 | + |
46 | 50 | public static void main(String... args) throws Exception {
|
47 | 51 | AtomicBoolean eventArrived = new AtomicBoolean(false);
|
| 52 | + |
48 | 53 | try (RecordingStream r = new RecordingStream()) {
|
49 | 54 | r.onEvent("jdk.MetaspaceAllocationFailure", e -> eventArrived.set(true));
|
50 | 55 | r.startAsync();
|
51 | 56 |
|
52 | 57 | try {
|
| 58 | + int iteration = 0; |
53 | 59 | while (!eventArrived.get()) {
|
54 | 60 | GeneratingCompilingClassLoader cl = new GeneratingCompilingClassLoader();
|
55 | 61 | cl.getGeneratedClasses(50, 20);
|
56 |
| - Thread.sleep(100); |
57 |
| - System.out.println("Iteration"); |
| 62 | + System.out.println("Iteration:" + iteration++); |
| 63 | + if (iteration > MAX_ITERATIONS) { |
| 64 | + throw new SkippedException("Exceeded MAX_ITERATIONS of " + MAX_ITERATIONS); |
| 65 | + } |
58 | 66 | }
|
59 | 67 | System.gc();
|
60 | 68 | System.out.println("main(): Event arrived");
|
|
0 commit comments