< prev index next >

src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/ui/classbrowser/HTMLGenerator.java

Print this page




  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 package sun.jvm.hotspot.ui.classbrowser;
  26 
  27 import java.io.*;
  28 import java.util.*;
  29 import sun.jvm.hotspot.asm.*;
  30 import sun.jvm.hotspot.code.*;
  31 import sun.jvm.hotspot.compiler.*;
  32 import sun.jvm.hotspot.debugger.*;
  33 import sun.jvm.hotspot.interpreter.*;
  34 import sun.jvm.hotspot.oops.*;
  35 import sun.jvm.hotspot.runtime.*;
  36 import sun.jvm.hotspot.tools.jcore.*;
  37 import sun.jvm.hotspot.utilities.*;
  38 
  39 public class HTMLGenerator implements /* imports */ ClassConstants {





  40     static class Formatter {
  41         boolean html;
  42         StringBuffer buf = new StringBuffer();
  43 
  44         Formatter(boolean h) {
  45             html = h;
  46         }
  47 
  48         void append(String s) {
  49             buf.append(s);
  50         }
  51 
  52         void append(int s) {
  53             buf.append(s);
  54         }
  55 
  56         void append(char s) {
  57             buf.append(s);
  58         }
  59 


1931             OopHandle oopHandle = vf.getLocals().oopHandleAt(0);
1932 
1933             if (oopHandle != null) {
1934                buf.append(", oop = ");
1935                buf.append(oopHandle.toString());
1936             }
1937          }
1938 
1939          if (vf.isCompiledFrame()) {
1940             buf.append(" (Compiled");
1941          }
1942          else if (vf.isInterpretedFrame()) {
1943             buf.append(" (Interpreted");
1944          }
1945 
1946          if (vf.mayBeImpreciseDbg()) {
1947             buf.append("; information may be imprecise");
1948          }
1949          buf.append(")");
1950          buf.br();







1951       }
1952 
1953       buf.endTag("pre");
1954       buf.genHTMLEpilogue();
1955       return buf.toString();
1956    }
1957 
1958    public String genHTMLForHyperlink(String href) {
1959       if (href.startsWith("klass=")) {
1960          href = href.substring(href.indexOf('=') + 1);
1961          Klass k = getKlassAtAddress(href);
1962          if (Assert.ASSERTS_ENABLED) {
1963             Assert.that(k instanceof InstanceKlass, "class= href with improper InstanceKlass!");
1964          }
1965          return genHTML((InstanceKlass) k);
1966       } else if (href.startsWith("method=")) {
1967          href = href.substring(href.indexOf('=') + 1);
1968          Method obj = getMethodAtAddress(href);
1969          if (Assert.ASSERTS_ENABLED) {
1970             Assert.that(obj instanceof Method, "method= href with improper Method!");




  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 package sun.jvm.hotspot.ui.classbrowser;
  26 
  27 import java.io.*;
  28 import java.util.*;
  29 import sun.jvm.hotspot.asm.*;
  30 import sun.jvm.hotspot.code.*;
  31 import sun.jvm.hotspot.compiler.*;
  32 import sun.jvm.hotspot.debugger.*;
  33 import sun.jvm.hotspot.interpreter.*;
  34 import sun.jvm.hotspot.oops.*;
  35 import sun.jvm.hotspot.runtime.*;
  36 import sun.jvm.hotspot.tools.jcore.*;
  37 import sun.jvm.hotspot.utilities.*;
  38 
  39 public class HTMLGenerator implements /* imports */ ClassConstants {
  40 
  41     private static final String ADDRESS_FORMAT = VM.getVM().isLP64() ? "0x%016x" : "0x%08x";
  42 
  43     private static final String LOCK_OUTPUT = "    - locked <" + ADDRESS_FORMAT + "> (a %s)";
  44 
  45     static class Formatter {
  46         boolean html;
  47         StringBuffer buf = new StringBuffer();
  48 
  49         Formatter(boolean h) {
  50             html = h;
  51         }
  52 
  53         void append(String s) {
  54             buf.append(s);
  55         }
  56 
  57         void append(int s) {
  58             buf.append(s);
  59         }
  60 
  61         void append(char s) {
  62             buf.append(s);
  63         }
  64 


1936             OopHandle oopHandle = vf.getLocals().oopHandleAt(0);
1937 
1938             if (oopHandle != null) {
1939                buf.append(", oop = ");
1940                buf.append(oopHandle.toString());
1941             }
1942          }
1943 
1944          if (vf.isCompiledFrame()) {
1945             buf.append(" (Compiled");
1946          }
1947          else if (vf.isInterpretedFrame()) {
1948             buf.append(" (Interpreted");
1949          }
1950 
1951          if (vf.mayBeImpreciseDbg()) {
1952             buf.append("; information may be imprecise");
1953          }
1954          buf.append(")");
1955          buf.br();
1956 
1957          vf.getMonitors()
1958            .stream()
1959            .map(m -> m.ownerIsScalarReplaced() ? m.ownerKlass() : m.owner())
1960            .map(m -> String.format(LOCK_OUTPUT, m.asLongValue(), Oop.getKlassForOopHandle(m).getName().asString().replace('/', '.')))
1961            .peek(buf::append)
1962            .forEach(s -> buf.br());
1963       }
1964 
1965       buf.endTag("pre");
1966       buf.genHTMLEpilogue();
1967       return buf.toString();
1968    }
1969 
1970    public String genHTMLForHyperlink(String href) {
1971       if (href.startsWith("klass=")) {
1972          href = href.substring(href.indexOf('=') + 1);
1973          Klass k = getKlassAtAddress(href);
1974          if (Assert.ASSERTS_ENABLED) {
1975             Assert.that(k instanceof InstanceKlass, "class= href with improper InstanceKlass!");
1976          }
1977          return genHTML((InstanceKlass) k);
1978       } else if (href.startsWith("method=")) {
1979          href = href.substring(href.indexOf('=') + 1);
1980          Method obj = getMethodAtAddress(href);
1981          if (Assert.ASSERTS_ENABLED) {
1982             Assert.that(obj instanceof Method, "method= href with improper Method!");


< prev index next >