37 static final long JAVA_BIRTH_YEAR = 1995; 38 39 static volatile boolean earlyretDone = false; 40 static volatile int errCode = Consts.TEST_PASSED; 41 private PrintStream out; 42 private earlyretThread earlyretThr; 43 static Object barrier = new Object(); 44 static Wicket startingBarrier; 45 46 static { 47 try { 48 System.loadLibrary("earlyretbase"); 49 } catch (UnsatisfiedLinkError e) { 50 System.err.println("Could not load earlyretbase library"); 51 System.err.println("java.library.path:" + 52 System.getProperty("java.library.path")); 53 throw e; 54 } 55 } 56 57 native static int doForceEarlyReturn(Class targCls, 58 Thread earlyretThr, long valToRet); 59 native static int suspThread(earlyretThread earlyretThr); 60 native static int resThread(earlyretThread earlyretThr); 61 native static int check(); 62 63 public static void main(String[] argv) { 64 argv = nsk.share.jvmti.JVMTITest.commonInit(argv); 65 66 System.exit(run(argv, System.out) + Consts.JCK_STATUS_BASE); 67 } 68 69 public static int run(String argv[], PrintStream out) { 70 return new earlyretbase().runIt(argv, out); 71 } 72 73 private int runIt(String argv[], PrintStream out) { 74 int retCode = 0; 75 76 this.out = out; 77 78 earlyretThr = new earlyretThread("Tested Thread"); 79 startingBarrier = new Wicket(); 80 81 // start the child thread 82 earlyretThr.start(); 83 startingBarrier.waitFor(); 84 85 // pause until the child thread exits notification-block 86 synchronized (barrier) { 87 } 88 89 out.println("Going to suspend the thread..."); 90 retCode = suspThread(earlyretThr); 91 if (retCode != Consts.TEST_PASSED) { 92 out.println("TEST: failed to suspend thread"); 93 return Consts.TEST_FAILED; 94 } 95 96 out.println("Forcing early return..."); 97 98 // force return from a top frame of the child thread 99 retCode = doForceEarlyReturn(earlyretThread.class, 100 earlyretThr, JAVA_BIRTH_YEAR); 101 earlyretDone = true; 102 earlyretThr.letItGo(); 103 if (retCode != Consts.TEST_PASSED) { 104 out.println("TEST: failed to force early return"); 105 resThread(earlyretThr); 106 return Consts.TEST_FAILED; 107 } 108 109 out.println("Going to resume the thread..."); 110 111 retCode = resThread(earlyretThr); 112 if (retCode != Consts.TEST_PASSED) { 113 out.println("TEST: failed to resume thread"); 114 return Consts.TEST_FAILED; 115 } 116 117 try { 118 earlyretThr.join(); 119 } catch (InterruptedException e) { 120 out.println("TEST INCOMPLETE: caught " + e); | 37 static final long JAVA_BIRTH_YEAR = 1995; 38 39 static volatile boolean earlyretDone = false; 40 static volatile int errCode = Consts.TEST_PASSED; 41 private PrintStream out; 42 private earlyretThread earlyretThr; 43 static Object barrier = new Object(); 44 static Wicket startingBarrier; 45 46 static { 47 try { 48 System.loadLibrary("earlyretbase"); 49 } catch (UnsatisfiedLinkError e) { 50 System.err.println("Could not load earlyretbase library"); 51 System.err.println("java.library.path:" + 52 System.getProperty("java.library.path")); 53 throw e; 54 } 55 } 56 57 native static int doForceEarlyReturn(Thread earlyretThr, long valToRet); 58 native static int suspThread(earlyretThread earlyretThr); 59 native static int resThread(earlyretThread earlyretThr); 60 native static int check(); 61 62 public static void main(String[] argv) { 63 argv = nsk.share.jvmti.JVMTITest.commonInit(argv); 64 65 System.exit(run(argv, System.out) + Consts.JCK_STATUS_BASE); 66 } 67 68 public static int run(String argv[], PrintStream out) { 69 return new earlyretbase().runIt(argv, out); 70 } 71 72 private int runIt(String argv[], PrintStream out) { 73 int retCode = 0; 74 75 this.out = out; 76 77 earlyretThr = new earlyretThread("Tested Thread"); 78 startingBarrier = new Wicket(); 79 80 // start the child thread 81 earlyretThr.start(); 82 startingBarrier.waitFor(); 83 84 // pause until the child thread exits notification-block 85 synchronized (barrier) { 86 } 87 88 out.println("Going to suspend the thread..."); 89 retCode = suspThread(earlyretThr); 90 if (retCode != Consts.TEST_PASSED) { 91 out.println("TEST: failed to suspend thread"); 92 return Consts.TEST_FAILED; 93 } 94 95 out.println("Forcing early return..."); 96 97 // force return from a top frame of the child thread 98 retCode = doForceEarlyReturn(earlyretThr, JAVA_BIRTH_YEAR); 99 earlyretDone = true; 100 earlyretThr.letItGo(); 101 if (retCode != Consts.TEST_PASSED) { 102 out.println("TEST: failed to force early return"); 103 resThread(earlyretThr); 104 return Consts.TEST_FAILED; 105 } 106 107 out.println("Going to resume the thread..."); 108 109 retCode = resThread(earlyretThr); 110 if (retCode != Consts.TEST_PASSED) { 111 out.println("TEST: failed to resume thread"); 112 return Consts.TEST_FAILED; 113 } 114 115 try { 116 earlyretThr.join(); 117 } catch (InterruptedException e) { 118 out.println("TEST INCOMPLETE: caught " + e); |