test/serviceability/dcmd/compiler/CodelistTest.java
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File hotspot Sdiff test/serviceability/dcmd/compiler

test/serviceability/dcmd/compiler/CodelistTest.java

Print this page
rev 7093 : 8058891: serviceability/dcmd/CodelistTest.java - fails on all platforms
Summary: Fix can not reflect MethodHandles
Reviewed-by:


   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 /*
  25  * @test CodelistTest
  26  * @bug 8054889

  27  * @build DcmdUtil MethodIdentifierParser CodelistTest
  28  * @run main CodelistTest
  29  * @summary Test of diagnostic command Compiler.codelist
  30  */
  31 
  32 import java.io.BufferedReader;
  33 import java.io.StringReader;
  34 import java.lang.reflect.Method;
  35 
  36 public class CodelistTest {
  37 
  38     /**
  39      * This test calls Jcmd (diagnostic command tool) Compiler.codelist and then parses the output,
  40      * making sure that the first methods in the list is valid by reflection.
  41      *
  42      * Output example:
  43      *
  44      * 6 0 java.lang.System.arraycopy(Ljava/lang/Object;ILjava/lang/Object;II)V [0x00007f7b49200910, 0x00007f7b49200aa0 - 0x00007f7b49200d30]
  45      * 2 3 java.lang.String.indexOf(II)I [0x00007f7b49200d90, 0x00007f7b49200f60 - 0x00007f7b49201490]
  46      * 7 3 java.lang.Math.min(II)I [0x00007f7b4922f010, 0x00007f7b4922f180 - 0x00007f7b4922f338]


  60 
  61         // Grab a method name from the output
  62         String line;
  63         int count = 0;
  64 
  65         while((line = r.readLine()) != null) {
  66             count++;
  67 
  68             String[] parts = line.split(" ");
  69             // int compileID = Integer.parseInt(parts[0]);
  70             // int compileLevel = Integer.parseInt(parts[1]);
  71             String methodPrintedInLogFormat = parts[2];
  72 
  73             // skip inits and clinits - they can not be reflected
  74             if (methodPrintedInLogFormat.contains("<init>")) {
  75                 continue;
  76             }
  77             if (methodPrintedInLogFormat.contains("<clinit>")) {
  78                 continue;
  79             }



  80 
  81             MethodIdentifierParser mf = new MethodIdentifierParser(methodPrintedInLogFormat);
  82             Method m;
  83             try {
  84                 m = mf.getMethod();
  85             } catch (NoSuchMethodException e) {
  86                 m = null;
  87             }
  88             if (m == null) {
  89                 throw new Exception("Test failed");
  90             }
  91             if (count > 10) {
  92                 // Testing 10 entries is enough. Lets not waste time.
  93                 break;
  94             }
  95         }
  96     }
  97 }


   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 /*
  25  * @test CodelistTest
  26  * @bug 8054889
  27  * @library ..
  28  * @build DcmdUtil MethodIdentifierParser CodelistTest
  29  * @run main CodelistTest
  30  * @summary Test of diagnostic command Compiler.codelist
  31  */
  32 
  33 import java.io.BufferedReader;
  34 import java.io.StringReader;
  35 import java.lang.reflect.Method;
  36 
  37 public class CodelistTest {
  38 
  39     /**
  40      * This test calls Jcmd (diagnostic command tool) Compiler.codelist and then parses the output,
  41      * making sure that the first methods in the list is valid by reflection.
  42      *
  43      * Output example:
  44      *
  45      * 6 0 java.lang.System.arraycopy(Ljava/lang/Object;ILjava/lang/Object;II)V [0x00007f7b49200910, 0x00007f7b49200aa0 - 0x00007f7b49200d30]
  46      * 2 3 java.lang.String.indexOf(II)I [0x00007f7b49200d90, 0x00007f7b49200f60 - 0x00007f7b49201490]
  47      * 7 3 java.lang.Math.min(II)I [0x00007f7b4922f010, 0x00007f7b4922f180 - 0x00007f7b4922f338]


  61 
  62         // Grab a method name from the output
  63         String line;
  64         int count = 0;
  65 
  66         while((line = r.readLine()) != null) {
  67             count++;
  68 
  69             String[] parts = line.split(" ");
  70             // int compileID = Integer.parseInt(parts[0]);
  71             // int compileLevel = Integer.parseInt(parts[1]);
  72             String methodPrintedInLogFormat = parts[2];
  73 
  74             // skip inits and clinits - they can not be reflected
  75             if (methodPrintedInLogFormat.contains("<init>")) {
  76                 continue;
  77             }
  78             if (methodPrintedInLogFormat.contains("<clinit>")) {
  79                 continue;
  80             }
  81             if (methodPrintedInLogFormat.contains("MethodHandle")) {
  82                 continue;
  83             }
  84 
  85             MethodIdentifierParser mf = new MethodIdentifierParser(methodPrintedInLogFormat);
  86             Method m;
  87             try {
  88                 m = mf.getMethod();
  89             } catch (NoSuchMethodException e) {
  90                 m = null;
  91             }
  92             if (m == null) {
  93                 throw new Exception("Test failed on: " + methodPrintedInLogFormat);
  94             }
  95             if (count > 10) {
  96                 // Testing 10 entries is enough. Lets not waste time.
  97                 break;
  98             }
  99         }
 100     }
 101 }
test/serviceability/dcmd/compiler/CodelistTest.java
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File