8284556: Ensure reachability of classes in runtime/whitebox/TestHiddenClassIsAlive.java and serviceability/dcmd/vm/ClassLoaderHierarchyTest.java
Reviewed-by: cjplummer
This commit is contained in:
parent
662320a0ec
commit
a8c8752602
test/hotspot/jtreg
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2021, 2022, 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
|
||||
@ -38,6 +38,7 @@ import java.lang.invoke.MethodHandle;
|
||||
import java.lang.invoke.MethodHandles;
|
||||
import java.lang.invoke.MethodHandles.Lookup;
|
||||
import java.lang.invoke.MethodType;
|
||||
import java.lang.ref.Reference;
|
||||
|
||||
import sun.hotspot.WhiteBox;
|
||||
|
||||
@ -48,7 +49,6 @@ final class MyClass {
|
||||
|
||||
public class TestHiddenClassIsAlive {
|
||||
|
||||
|
||||
public static void main(String[] args) throws Throwable {
|
||||
byte[] classBytes = readClassFile("MyClass.class");
|
||||
Lookup lookup = MethodHandles.lookup();
|
||||
@ -56,6 +56,7 @@ public class TestHiddenClassIsAlive {
|
||||
if (!WhiteBox.getWhiteBox().isClassAlive("MyClass")) {
|
||||
throw new RuntimeException("Hidden class should be alive");
|
||||
}
|
||||
Reference.reachabilityFence(c);
|
||||
}
|
||||
|
||||
static byte[] readClassFile(String classFileName) throws Exception {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2014, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2014, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2018 SAP SE. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
@ -44,6 +44,7 @@ import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.channels.FileChannel;
|
||||
import java.lang.ref.Reference;
|
||||
|
||||
public class ClassLoaderHierarchyTest {
|
||||
|
||||
@ -93,6 +94,10 @@ public class ClassLoaderHierarchyTest {
|
||||
output.shouldMatch("Bill.*TestClassLoader");
|
||||
output.shouldContain("TestClass2");
|
||||
output.shouldContain("Hidden Classes:");
|
||||
|
||||
Reference.reachabilityFence(unnamed_cl);
|
||||
Reference.reachabilityFence(named_cl);
|
||||
Reference.reachabilityFence(named_child_cl);
|
||||
}
|
||||
|
||||
static class TestClassLoader extends ClassLoader {
|
||||
@ -163,4 +168,3 @@ class TestClass2 {
|
||||
r.run();
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user