< prev index next >

test/hotspot/jtreg/runtime/LoadClass/TestResize.java

Print this page




  53       } else {
  54         break;
  55       }
  56     }
  57     int end = start;
  58     for (int i = end; i < string.length(); i++) {
  59       if (Character.isDigit(string.charAt(i))) {
  60         end++;
  61       } else {
  62         break;
  63       }
  64     }
  65     return Integer.parseInt(string.substring(start, end));
  66   }
  67 
  68   static void analyzeOutputOn(ProcessBuilder pb) throws Exception {
  69     pb.redirectErrorStream(true);
  70     Process process = pb.start();
  71     BufferedReader rd = new BufferedReader(new InputStreamReader(process.getInputStream()));
  72     String line = rd.readLine();

  73     while (line != null) {

  74       if (line.startsWith("Java dictionary (")) {
  75         // ex. "Java dictionary (table_size=107, classes=6)"
  76         // ex. "Java dictionary (table_size=20201, classes=50002)"
  77         Scanner scanner = new Scanner(line);
  78         scanner.next();
  79         scanner.next();
  80         int table_size = getInt(scanner.next());
  81         int classes = getInt(scanner.next());
  82         scanner.close();
  83 
  84         double loadFactor = (double)classes / (double)table_size;
  85         if (loadFactor > MAX_LOAD_FACTOR) {
  86           throw new RuntimeException("Load factor too high, expected MAX "+MAX_LOAD_FACTOR+", got "+loadFactor);





  87         } else {
  88           System.out.println("PASS table_size:"+table_size+", classes:"+classes+" OK");
  89         }
  90       }
  91       line = rd.readLine();
  92     }
  93     int retval = process.waitFor();
  94     if (retval != 0) {
  95       throw new RuntimeException("Error: test returned non-zero value");
  96     }
  97   }
  98 
  99   public static void main(String[] args) throws Exception {
 100     if (Platform.isDebugBuild()) {
 101       ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+PrintSystemDictionaryAtExit",
 102                                                                 "TriggerResize",
 103                                                                 "50000");
 104       analyzeOutputOn(pb);
 105     }
 106   }


  53       } else {
  54         break;
  55       }
  56     }
  57     int end = start;
  58     for (int i = end; i < string.length(); i++) {
  59       if (Character.isDigit(string.charAt(i))) {
  60         end++;
  61       } else {
  62         break;
  63       }
  64     }
  65     return Integer.parseInt(string.substring(start, end));
  66   }
  67 
  68   static void analyzeOutputOn(ProcessBuilder pb) throws Exception {
  69     pb.redirectErrorStream(true);
  70     Process process = pb.start();
  71     BufferedReader rd = new BufferedReader(new InputStreamReader(process.getInputStream()));
  72     String line = rd.readLine();
  73     String string_out = "";
  74     while (line != null) {
  75       string_out += line+"\n";
  76       if (line.startsWith("Java dictionary (")) {
  77         // ex. "Java dictionary (table_size=107, classes=6)"
  78         // ex. "Java dictionary (table_size=20201, classes=50002)"
  79         Scanner scanner = new Scanner(line);
  80         scanner.next();
  81         scanner.next();
  82         int table_size = getInt(scanner.next());
  83         int classes = getInt(scanner.next());
  84         scanner.close();
  85 
  86         double loadFactor = (double)classes / (double)table_size;
  87         if (loadFactor > MAX_LOAD_FACTOR) {
  88           System.out.println(string_out);
  89           while (line != null) {
  90             line = rd.readLine();
  91             System.out.println(line);
  92           }
  93           throw new RuntimeException("Load factor too high, expected MAX "+MAX_LOAD_FACTOR+", got "+loadFactor+" [table size "+table_size+", number of clases "+classes+"]");
  94         } else {
  95           System.out.println("PASS table_size:"+table_size+", classes:"+classes+" OK");
  96         }
  97       }
  98       line = rd.readLine();
  99     }
 100     int retval = process.waitFor();
 101     if (retval != 0) {
 102       throw new RuntimeException("Error: test returned non-zero value");
 103     }
 104   }
 105 
 106   public static void main(String[] args) throws Exception {
 107     if (Platform.isDebugBuild()) {
 108       ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+PrintSystemDictionaryAtExit",
 109                                                                 "TriggerResize",
 110                                                                 "50000");
 111       analyzeOutputOn(pb);
 112     }
 113   }
< prev index next >