11/*
2- * Copyright (c) 2020, 2022 , Oracle and/or its affiliates. All rights reserved.
2+ * Copyright (c) 2020, 2023 , Oracle and/or its affiliates. All rights reserved.
33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44 *
55 * This code is free software; you can redistribute it and/or modify it
2121 * questions.
2222 */
2323
24- /* @test
24+ /*
25+ * @test id=default
26+ * @bug 8284161
2527 * @summary Test JNI IsVirtualThread
2628 * @library /test/lib
27- * @compile --enable-preview -source ${jdk.version} IsVirtualThread.java
28- * @run main/native/othervm --enable-preview IsVirtualThread
29+ * @enablePreview
30+ * @run main/native/othervm IsVirtualThread
31+ */
32+
33+ /*
34+ * @test id=no-vmcontinuations
35+ * @requires vm.continuations
36+ * @library /test/lib
37+ * @enablePreview
38+ * @run main/native/othervm -XX:+UnlockExperimentalVMOptions -XX:-VMContinuations IsVirtualThread
2939 */
3040
3141import jdk .test .lib .Asserts ;
@@ -40,18 +50,24 @@ public static void main(String[] args) throws Exception {
4050 Thread thread = Thread .ofPlatform ().unstarted (LockSupport ::park );
4151 test (thread ); // not started
4252 thread .start ();
43- test (thread ); // started, probably parked
44- LockSupport .unpark (thread );
45- thread .join ();
53+ try {
54+ test (thread ); // started, probably parked
55+ } finally {
56+ LockSupport .unpark (thread );
57+ thread .join ();
58+ }
4659 test (thread ); // terminated
4760
4861 // test virtual thread
4962 Thread vthread = Thread .ofVirtual ().unstarted (LockSupport ::park );
5063 test (vthread ); // not started
5164 vthread .start ();
52- test (vthread ); // started, probably parked
53- LockSupport .unpark (vthread );
54- vthread .join ();
65+ try {
66+ test (vthread ); // started, probably parked
67+ } finally {
68+ LockSupport .unpark (vthread );
69+ vthread .join ();
70+ }
5571 test (vthread ); // terminated
5672 }
5773
0 commit comments