forked from dragonwell-project/dragonwell17
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Summary: Provides a way to run thread as wisp using configuration Test Plan: TestThreadAsWispWhiteList Reviewed-by: yulei Issue: dragonwell-project#146
- Loading branch information
Showing
3 changed files
with
49 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* @test | ||
* @library /test/lib | ||
* @summary test thread as wisp white list | ||
* @modules java.base/jdk.internal.access | ||
* @modules java.base/com.alibaba.wisp.engine:+open | ||
* @run main/othervm -XX:+UseWisp2 -Dcom.alibaba.wisp.enableThreadAsWisp=true -Dcom.alibaba.wisp.allThreadAsWisp=false -Dcom.alibaba.wisp.threadAsWisp.white=name:wisp-* TestThreadAsWispWhiteList | ||
*/ | ||
|
||
import jdk.internal.access.SharedSecrets; | ||
|
||
import java.util.concurrent.FutureTask; | ||
|
||
import static jdk.test.lib.Asserts.assertFalse; | ||
import static jdk.test.lib.Asserts.assertTrue; | ||
|
||
public class TestThreadAsWispWhiteList { | ||
public static void main(String[] args) throws Exception { | ||
FutureTask<Boolean> future = new FutureTask<>(TestThreadAsWispWhiteList::isRealThread); | ||
new Thread(future, "wisp-1").start(); | ||
assertFalse(future.get()); | ||
future = new FutureTask<>(TestThreadAsWispWhiteList::isRealThread); | ||
new Thread(future, "thread-1").start(); | ||
assertTrue(future.get()); | ||
} | ||
|
||
private static boolean isRealThread() { | ||
return SharedSecrets.getJavaLangAccess().currentThread0() == Thread.currentThread(); | ||
} | ||
} |