The test failed if GC happens somewhere between Class<?> c = Class.forName("TestClass", true, dummyloader); and OutputAnalyzer output = executor.execute("VM.classloader_stats");
The fix is to make hc static as Chris proposed. To verfiy fix I add System.gc() before executor.execute("VM.classloader_stats"); ------------- Commit messages: - fix Changes: https://git.openjdk.java.net/jdk/pull/8438/files Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=8438&range=00 Issue: https://bugs.openjdk.java.net/browse/JDK-8278123 Stats: 4 lines in 1 file changed: 1 ins; 0 del; 3 mod Patch: https://git.openjdk.java.net/jdk/pull/8438.diff Fetch: git fetch https://git.openjdk.java.net/jdk pull/8438/head:pull/8438 PR: https://git.openjdk.java.net/jdk/pull/8438