On Fri, 13 Feb 2026 15:48:18 GMT, Leonid Mesnik <[email protected]> wrote:
>> test/hotspot/jtreg/vmTestbase/nsk/share/gc/Memory.java line 40: >> >>> 38: private static int objectExtraSize = 0; >>> 39: >>> 40: private static final boolean previewEnabled = >> >> I think there are some more robust ways to check for preview. >> * The best way is probably `jdk.internal.misc.PreviewFeatures.isEnabled` >> which checks if the current VM is preview-enabled. Needs `@modules >> java.base/jdk.internal.misc`. >> * Alternatively, if the above is not possible, >> `jdk.test.lib.Utils.getTestJavaOpts` which you can check in a Stream for >> `--enable-preview`. This consolidates all of the `test.vm.opts` and >> `test.java.opts` for you. > > That's an actual problem with these vmTestbase jtreg tests. > To use jdk.internal.misc.PreviewFeatures.isEnabled it is needed to add > `@modules java.base/jdk.internal.misc`to every test. The same for > `jdk.test.lib.Utils.getTestJavaOpts`. It is needed to ensure that `/test/lib` > is used by every test. > > This file has `TODO: somehow determine the real value`. > It would be really great to find single solution. I wonder if run something > like VMProps in external process to obtain data would be better solution. So > we don't need to change every single test. I understand. Maybe we can check both `test.java.opts` and `test.vm.opts` for `--enable-preview` then? I'm not sure we check for `--preview` anywhere else. ------------- PR Review Comment: https://git.openjdk.org/valhalla/pull/2099#discussion_r2804890326
