@@ -52,12 +52,11 @@ TEST_SOURCE=${TEST_CLASS}.java
5252
5353# ##################################################################################
5454
55-
5655cat > ${TESTCLASSES}${FS} $TEST_SOURCE << EOF
5756import com.alibaba.wisp.engine.WispEngine;
5857import java.util.concurrent.CountDownLatch;
5958import java.util.concurrent.atomic.AtomicBoolean;
60- import sun .misc.SharedSecrets;
59+ import jdk.internal .misc.SharedSecrets;
6160import java.util.concurrent.Executors;
6261import java.util.concurrent.*;
6362
@@ -76,6 +75,7 @@ public class TmpThreadStackTrace {
7675 }
7776 });
7877 AtomicBoolean result = new AtomicBoolean(true);
78+ String[] errMsg = new String[1];
7979 CountDownLatch done = new CountDownLatch(1);
8080 Thread mainThread = Thread.currentThread();
8181 Thread[] ts = new Thread[1];
@@ -84,14 +84,13 @@ public class TmpThreadStackTrace {
8484 try {
8585 if (ts[0].getStackTrace().length == 0 || mainThread.getStackTrace().length == 0
8686 || Thread.currentThread().getStackTrace().length == 0) {
87+ errMsg[0] = "unexpected stacktrace length";
8788 result.set(false);
8889 }
8990 runningCoroutine.getStackTrace();
90- result.set(false);
9191 } catch (Exception e) {
92- if (!(e instanceof UnsupportedOperationException)) {
93- result.set(false);
94- }
92+ errMsg[0] = "unexpected exception";
93+ result.set(false);
9594 } finally {
9695 done.countDown();
9796 }
@@ -101,13 +100,14 @@ public class TmpThreadStackTrace {
101100 System.out.println("in main");
102101 executor.shutdown();
103102 if (!result.get()) {
103+ System.out.println(errMsg[0]);
104104 throw new Error("test failure");
105105 }
106106 }
107107
108108 public static void main(String[] args) throws Exception {
109109 final CountDownLatch latch = new CountDownLatch(1);
110- WispEngine.current().execute (() -> {
110+ WispEngine.dispatch (() -> {
111111 for (int i = 0; i < 5; i++) {
112112 System.out.println(i);
113113 Thread.currentThread().getStackTrace();
@@ -123,7 +123,7 @@ public class TmpThreadStackTrace {
123123EOF
124124
125125# Do compilation
126- ${JAVAC} -cp ${TESTCLASSES} -d ${TESTCLASSES} ${TESTCLASSES}${FS} $TEST_SOURCE >> /dev/null 2>&1
126+ ${JAVAC} --add-exports java.base/jdk.internal.misc=ALL-UNNAMED - cp ${TESTCLASSES} -d ${TESTCLASSES} ${TESTCLASSES}${FS} $TEST_SOURCE >> /dev/null 2>&1
127127if [ $? != ' 0' ]
128128then
129129 printf " Failed to compile ${TESTCLASSES}${FS}${TEST_SOURCE} "
132132
133133# run
134134${JAVA} -XX:+PrintSafepointStatistics -XX:PrintSafepointStatisticsCount=1 -XX:+UnlockExperimentalVMOptions -XX:+UseWisp2 -Dcom.alibaba.wisp.carrierEngines=1 -cp ${TESTCLASSES} ${TEST_CLASS} > output.txt 2>&1
135+ rm -f $TEST_WISP_CONFIG
135136cat output.txt
136137
137- function assert()
138- {
139- line=` cat output.txt | grep ThreadDump | wc -l`
140- echo $line
141- if [[ $line -eq " 2" ]]; then
142- echo " success"
143- else
144- echo " failure"
145- exit -1
146- fi
147- }
148-
149- assert
138+ line=` cat output.txt | grep ThreadDump | wc -l`
139+ echo $line
140+ if [ $line -eq " 2" ]; then
141+ echo " success"
142+ else
143+ echo " failure"
144+ exit -1
145+ fi
0 commit comments