< prev index next >

src/share/tools/LogCompilation/src/com/sun/hotspot/tools/compiler/LogCleanupReader.java

Print this page
rev 8632 : 6900757: minor bug fixes to LogCompilation tool
* improve internal error reporting (point to XML element causing trouble)
* fix comparator for sorting by name and start
* make tool more robust wrt. incorrect options and files not found
* make inlining decision output more clear
* adopt uncommon traps history printing
* properly mention compiler in generated logs
* add options for printing time stamps and omitting compilation IDs
* add option for comparing compilation logs
* overall code cleanup and API documentation

@@ -1,7 +1,7 @@
 /*
- * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2015, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.

@@ -29,14 +29,13 @@
 
 /**
  * This class is a filter class to deal with malformed XML that used
  * to be produced by the JVM when generating LogCompilation.  In 1.6
  * and later releases it shouldn't be required.
- * @author never
  */
-
 class LogCleanupReader extends Reader {
+    
     private Reader reader;
 
     private char[] buffer = new char[4096];
 
     private int bufferCount;

@@ -53,36 +52,42 @@
 
     LogCleanupReader(Reader r) {
         reader = r;
     }
 
-    static final private Matcher pattern = Pattern.compile(".+ compile_id='[0-9]+'.*( compile_id='[0-9]+)").matcher("");
-    static final private Matcher pattern2 = Pattern.compile("' (C[12]) compile_id=").matcher("");
-    static final private Matcher pattern3 = Pattern.compile("'(destroy_vm)/").matcher("");
-
+    static final private Matcher duplicateCompileID = Pattern.compile(".+ compile_id='[0-9]+'.*( compile_id='[0-9]+)").matcher("");
+    static final private Matcher compilerName = Pattern.compile("' (C[12]) compile_id=").matcher("");    
+    static final private Matcher destroyVM = Pattern.compile("'(destroy_vm)/").matcher("");
+
+    /**
+     * The log cleanup takes place in this method. If any of the three patterns
+     * ({@link #duplicateCompileID}, {@link #compilerName}, {@link #destroyVM})
+     * match, that indicates a problem in the log. The cleanup is performed by
+     * correcting the input line and writing it back into the {@link #line}
+     * buffer.
+     */
     private void fill() throws IOException {
         rawFill();
         if (length != -1) {
             boolean changed = false;
             String s = new String(line, 0, length);
-            String orig = s;
 
-            pattern2.reset(s);
-            if (pattern2.find()) {
-                s = s.substring(0, pattern2.start(1)) + s.substring(pattern2.end(1) + 1);
+            compilerName.reset(s);
+            if (compilerName.find()) {
+                s = s.substring(0, compilerName.start(1)) + s.substring(compilerName.end(1) + 1);
                 changed = true;
             }
 
-            pattern.reset(s);
-            if (pattern.lookingAt()) {
-                s = s.substring(0, pattern.start(1)) + s.substring(pattern.end(1) + 1);
+            duplicateCompileID.reset(s);
+            if (duplicateCompileID.lookingAt()) {
+                s = s.substring(0, duplicateCompileID.start(1)) + s.substring(duplicateCompileID.end(1) + 1);
                 changed = true;
             }
 
-            pattern3.reset(s);
-            if (pattern3.find()) {
-                s = s.substring(0, pattern3.start(1)) + s.substring(pattern3.end(1));
+            destroyVM.reset(s);
+            if (destroyVM.find()) {
+                s = s.substring(0, destroyVM.start(1)) + s.substring(destroyVM.end(1));
                 changed = true;
             }
 
             if (changed) {
                 s.getChars(0, s.length(), line, 0);
< prev index next >