< prev index next >

src/share/tools/LogCompilation/src/com/sun/hotspot/tools/compiler/Method.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.

@@ -24,20 +24,62 @@
 
 package com.sun.hotspot.tools.compiler;
 
 import java.util.Arrays;
 
-public class Method implements Constants {
+import static com.sun.hotspot.tools.compiler.Constants.*;
 
+/**
+ * Representation of a Java method in a compilation log.
+ */
+public class Method {
+
+    /**
+     * The name of the class holding the method.
+     */
     private String holder;
+    
+    /**
+     * The method's name.
+     */
     private String name;
+    
+    /**
+     * The return type of the method, as a fully qualified (source-level) class
+     * or primitive type name.
+     */
     private String returnType;
-    private String arguments;
+    
+    /**
+     * The method's signature, in internal form.
+     */
+    private String signature;
+    
+    /**
+     * The length of the method's byte code.
+     */
     private String bytes;
+    
+    /**
+     * The number of times this method was invoked in the interpreter.
+     */
     private String iicount;
+    
+    /**
+     * The method's flags, in the form of a {@code String} representing the
+     * {@code int} encoding them.
+     */
     private String flags;
 
+    /**
+     * Decode the {@link flags} numerical string to a format for console
+     * output. The result does not honour all possible flags but includes
+     * information about OSR compilation.
+     * 
+     * @param osr_bci the byte code index at which an OSR compilation takes
+     * place, or -1 if the compilation is not an OSR one.
+     */
     String decodeFlags(int osr_bci) {
         int f = Integer.parseInt(getFlags());
         char[] c = new char[4];
         Arrays.fill(c, ' ');
         if (osr_bci >= 0) {

@@ -47,10 +89,16 @@
             c[1] = 's';
         }
         return new String(c);
     }
 
+    /**
+     * Format this method for console output.
+     * 
+     * @param osr_bci the byte code index at which OSR takes place, or -1 if no
+     * OSR compilation is going on.
+     */
     String format(int osr_bci) {
         if (osr_bci >= 0) {
             return getHolder() + "::" + getName() + " @ " + osr_bci + " (" + getBytes() + " bytes)";
         } else {
             return getHolder() + "::" + getName() + " (" + getBytes() + " bytes)";

@@ -60,10 +108,14 @@
     @Override
     public String toString() {
         return getHolder() + "::" + getName() + " (" + getBytes() + " bytes)";
     }
 
+    public String getFullName() {
+        return getHolder().replace('/', '.') + "." + getName() + signature;
+    }
+
     public String getHolder() {
         return holder;
     }
 
     public void setHolder(String holder) {

@@ -84,16 +136,20 @@
 
     public void setReturnType(String returnType) {
         this.returnType = returnType;
     }
 
-    public String getArguments() {
-        return arguments;
+    public String getSignature() {
+        return signature;
+    }
+
+    public void setSignature(String signature) {
+        this.signature = signature.replace('/', '.');
     }
 
-    public void setArguments(String arguments) {
-        this.arguments = arguments;
+    public String getArguments() {
+        return signature.substring(0, signature.indexOf(')') + 1);
     }
 
     public String getBytes() {
         return bytes;
     }

@@ -119,12 +175,15 @@
     }
 
     @Override
     public boolean equals(Object o) {
         if (o instanceof Method) {
-            Method other = (Method)o;
-            return holder.equals(other.holder) && name.equals(other.name) &&
-                arguments.equals(other.arguments) && returnType.equals(other.returnType);
+            Method other = (Method) o;
+            return holder.equals(other.holder) && name.equals(other.name) && signature.equals(other.signature);
         }
         return false;
     }
+    
+    public int hashCode() {
+        return holder.hashCode() ^ name.hashCode();
+    }
 }
< prev index next >