1 /*
   2  * @test
   3  * @bug 6434117
   4  * @summary debug info for native methods illegally references register
   5  * @run main/othervm -server -XX:+UseBiasedLocking -XX:BiasedLockingStartupDelay=50 TestNativeRevocation
   6 */
   7 
   8 import java.util.*;
   9 
  10 public class TestNativeRevocation {
  11   private static String tmp;
  12 
  13   static class RevokerThread extends Thread {
  14     private List queue = new ArrayList();
  15 
  16     volatile boolean cont = true;
  17     public void run() {
  18       while (cont) {
  19         synchronized (queue) {
  20           if (queue.size() > 0) {
  21             // Remove element from the end of the list to keep
  22             // the list small (avoid elements shift to keep up
  23             // with queue.add(t)).
  24             Throwable t = (Throwable) queue.remove(queue.size()-1);
  25             synchronized (t) {
  26               tmp = t.getMessage();
  27             }
  28           }
  29           while (cont && queue.size() == 0) {
  30             try {
  31               queue.wait();
  32             } catch (InterruptedException e) {
  33               cont = false;
  34             }
  35           }
  36         }
  37       }
  38     }
  39 
  40     public void give(Throwable t) {
  41       synchronized (queue) {
  42         queue.add(t);
  43         queue.notifyAll();
  44       }
  45     }
  46   }
  47 
  48   public static void main(String[] args) {
  49     RevokerThread revoker = new RevokerThread();
  50     revoker.start();
  51 
  52     // Warm up fillInStackTrace
  53     for (int i = 0; i < 30000; i++) {
  54       new Throwable();
  55     }
  56 
  57     // Start revocation
  58     for (int i = 0; i < 1000000; i++) {
  59       revoker.give(new Throwable());
  60       if(i%100000 == 0)
  61         System.out.println(i);
  62     }
  63     revoker.stop();
  64   }
  65 }