The class https://github.com/openjdk/jdk/blob/master/test/jtreg-ext/requires/VMProps.java uses WhiteBox to query many internal properties of HotSpot. The properties are currently used only for filtering tests using the "@requires" keyword.
Many HotSpot tests need to find out internal VM properties. Today they must use the WhiteBox class, which is very cumbersome. For example, many CDS tests need to know if the JVM can use a default CDS archive from JAVA_HOME. They have to resort to this:
https://github.com/openjdk/jdk/blob/0460978e7c769624cacdb528277a99914b327e30/test/lib/jdk/test/lib/cds/CDSAppTester.java#L257-L268
This adds a lot of bloat into the "@test" block:
https://github.com/openjdk/jdk/blob/0460978e7c769624cacdb528277a99914b327e30/test/hotspot/jtreg/runtime/cds/appcds/applications/JavacBench.java#L38-L40
======================
Proposal:
To simplify the test cases, and make them run faster, we should add a new API VMPropsGetter.get():
import jdk.test.lib.Asserts;
import jdk.test.lib.VMPropsGetter;
public class VMPropsGetterTest {
public static void main(String[] args) throws Exception {
String key = "vm.flagless";
String value = VMPropsGetter.get(key);
Asserts.assertEQ(value, "true");
}
}
Many HotSpot tests need to find out internal VM properties. Today they must use the WhiteBox class, which is very cumbersome. For example, many CDS tests need to know if the JVM can use a default CDS archive from JAVA_HOME. They have to resort to this:
https://github.com/openjdk/jdk/blob/0460978e7c769624cacdb528277a99914b327e30/test/lib/jdk/test/lib/cds/CDSAppTester.java#L257-L268
This adds a lot of bloat into the "@test" block:
https://github.com/openjdk/jdk/blob/0460978e7c769624cacdb528277a99914b327e30/test/hotspot/jtreg/runtime/cds/appcds/applications/JavacBench.java#L38-L40
======================
Proposal:
To simplify the test cases, and make them run faster, we should add a new API VMPropsGetter.get():
import jdk.test.lib.Asserts;
import jdk.test.lib.VMPropsGetter;
public class VMPropsGetterTest {
public static void main(String[] args) throws Exception {
String key = "vm.flagless";
String value = VMPropsGetter.get(key);
Asserts.assertEQ(value, "true");
}
}
- relates to
-
JDK-8352528 Move CDS WhiteBox APIs to jdk.internal.test.cds.WhiteBox
-
- New
-
-
CODETOOLS-7903975 Expose @requires properties to test cases
-
- Closed
-
- links to
-
Review(master) openjdk/jdk/24071