< prev index next >

test/hotspot/jtreg/runtime/HiddenClasses/StressHiddenClasses.java

Print this page




  39 
  40 // This test is based on vmTestbase/vm/mlvm/anonloader/share/StressClassLoadingTest.java
  41 public class StressHiddenClasses {
  42 
  43     private static final int PARSE_TIMEOUT = 0;
  44     private static final int ITERATIONS = 40000;
  45 
  46     static byte klassbuf[] = InMemoryJavaCompiler.compile("TestClass",
  47         "public class TestClass { " +
  48         "    public static void concat(String one, String two) throws Throwable { " +
  49         "        System.out.println(one + two);" +
  50         " } } ");
  51 
  52 
  53     public void run() throws Exception {
  54         for (int x = 0; x < ITERATIONS; x++) {
  55             Thread parserThread  = new Thread() {
  56                 public void run() {
  57                     try {
  58                         Lookup lookup = MethodHandles.lookup();
  59                         Class<?> c = lookup.defineHiddenClass(klassbuf, true, NESTMATE, WEAK).lookupClass();
  60                     } catch (Throwable e) {
  61                         throw new RuntimeException("Unexpected exception: " + e.toString());
  62                     }
  63                 }
  64             };
  65 
  66             parserThread.start();
  67             parserThread.join(PARSE_TIMEOUT);
  68 
  69             if (parserThread.isAlive()) {
  70                 System.out.println("parser thread may be hung!");
  71                 StackTraceElement[] stack = parserThread.getStackTrace();
  72                 System.out.println("parser thread stack len: " + stack.length);
  73                 System.out.println(parserThread + " stack trace:");
  74                 for (int i = 0; i < stack.length; ++i) {
  75                     System.out.println(parserThread + "\tat " + stack[i]);
  76                 }
  77 
  78                 parserThread.join(); // Wait until either thread finishes or test times out.
  79             }


  39 
  40 // This test is based on vmTestbase/vm/mlvm/anonloader/share/StressClassLoadingTest.java
  41 public class StressHiddenClasses {
  42 
  43     private static final int PARSE_TIMEOUT = 0;
  44     private static final int ITERATIONS = 40000;
  45 
  46     static byte klassbuf[] = InMemoryJavaCompiler.compile("TestClass",
  47         "public class TestClass { " +
  48         "    public static void concat(String one, String two) throws Throwable { " +
  49         "        System.out.println(one + two);" +
  50         " } } ");
  51 
  52 
  53     public void run() throws Exception {
  54         for (int x = 0; x < ITERATIONS; x++) {
  55             Thread parserThread  = new Thread() {
  56                 public void run() {
  57                     try {
  58                         Lookup lookup = MethodHandles.lookup();
  59                         Class<?> c = lookup.defineHiddenClass(klassbuf, true, NESTMATE).lookupClass();
  60                     } catch (Throwable e) {
  61                         throw new RuntimeException("Unexpected exception: " + e.toString());
  62                     }
  63                 }
  64             };
  65 
  66             parserThread.start();
  67             parserThread.join(PARSE_TIMEOUT);
  68 
  69             if (parserThread.isAlive()) {
  70                 System.out.println("parser thread may be hung!");
  71                 StackTraceElement[] stack = parserThread.getStackTrace();
  72                 System.out.println("parser thread stack len: " + stack.length);
  73                 System.out.println(parserThread + " stack trace:");
  74                 for (int i = 0; i < stack.length; ++i) {
  75                     System.out.println(parserThread + "\tat " + stack[i]);
  76                 }
  77 
  78                 parserThread.join(); // Wait until either thread finishes or test times out.
  79             }
< prev index next >