sa-jdi

te Color nextColor(Color c)
  {
    return colors[((findColorIndex(c) + 1) % colors.length)];
  }
  
  private int findColorIndex(Color c)
  {
    for (int i = 0; i < colors.length; i++) {
      if (colors[i] == c) {
        return i;
      }
    }
    throw new IllegalArgumentException();
  }
  
  public static void main(String[] args)
  {
    JFrame frame = new JFrame();
    DummyDebugger debugger = new DummyDebugger(new MachineDescriptionIntelX86());
    AnnotatedMemoryPanel anno = new AnnotatedMemoryPanel(debugger);
    frame.getContentPane().add(anno);
    anno.addAnnotation(new Annotation(debugger.parseAddress("0x80000000"), debugger.parseAddress("0x80000040"), "Stack Frame for \"foo\""));
    
    anno.addAnnotation(new Annotation(debugger.parseAddress("0x80000010"), debugger.parseAddress("0x80000020"), "Locals for \"foo\""));
    
    anno.addAnnotation(new Annotation(debugger.parseAddress("0x80000020"), debugger.parseAddress("0x80000030"), "Expression stack for \"foo\""));
    
    frame.setSize(400, 300);
    frame.addWindowListener(new WindowAdapter()
    {
      public void windowClosed(WindowEvent e)
      {
        System.exit(0);
      }
      
      public void windowClosing(WindowEvent e)
      {
        System.exit(0);
      }
    });
    frame.setVisible(true);
  }
}

/* Location:
 * Qualified Name:     sun.jvm.hotspot.ui.AnnotatedMemoryPanel
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package sun.jvm.hotspot.ui;

import java.awt.Color;
import java.awt.Graphics;
import java.awt.Rectangle;
import java.awt.geom.Rectangle2D;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.StringTokenizer;
import sun.jvm.hotspot.debugger.Address;
import sun.jvm.hotspot.utilities.AddressOps;
import sun.jvm.hotspot.utilities.Interval;

public class Annotation
{
  private Interval interval;
  private List strings;
  private List heights;
  private Color baseColor;
  private int width;
  private int height;
  private int x;
  private int y;
  
  public Annotation(Address lowAddress, Address highAddress, String s)
  {
    strings = new ArrayList();
    heights = new ArrayList();
    for (StringTokenizer tok = new StringTokenizer(s, "\n"); tok.hasMoreTokens();) {
      strings.add(tok.nextToken());
    }
    if (AddressOps.lessThan(highAddress, lowAddress))
    {
      Address temp = lowAddress;
      lowAddress = highAddress;
      highAddress = temp;
    }
    interval = new Interval(lowAddress, highAddress);
  }
  
  public Interval getInterval()
  {
    return interval;
  }
  
  public Address getLowAddress()
  {
    return (Address)getInterval().getLowEndpoint();
  }
  
  public Address getHighAddress()
  {
    return (Address)getInterval().getHighEndpoint();
  }
  
  public void draw(Graphics g)
  {
    g.setColor(baseColor);
    int tmpY = y;
    for (int i = 0; i < strings.size(); i++)
    {
      String s = (String)strings.get(i);
      Integer h = (Integer)heights.get(i);
      g.drawString(s, x, tmpY);
      tmpY += h.intValue();
    }
  }
  
  public void setColor(Color c)
  {
    baseColor = c;
  }
  
  public Color getColor()
  {
    return baseColor;
  }
  
  public void computeWidthAndHeight(Graphics g)
  {
    width = 0;
    height = 0;
    heights.clear();
    for (Iterator iter = strings.iterator(); iter.hasNext();)
    {
      String s = (String)iter.next();
      Rectangle2D bounds = GraphicsUtilities.getStringBounds(s, g);
      width = Math.max(width, (int)bounds.getWidth());
      height += (int)bounds.getHeight();
      heights.add(new Integer((int)bounds.getHeight()));
    }
  }
  
  public int getWidth()
  {
    return width;
  }
  
  public int getHeight()
  {
    return height;
  }
  
  public void setXAndY(int x, int y)
  {
    this.x = x;this.y = y;
  }
  
  public void setX(int x)
  {
    this.x = x;
  }
  
  public int getX()
  {
    return x;
  }
  
  public void setY(int y)
  {
    this.y = y;
  }
  
  public int getY()
  {
    return y;
  }
  
  public Rectangle getBounds()
  {
    return new Rectangle(x, y, width, height);
  }
  
  public String toString()
  {
    String result = "Annotation: lowAddr: " + getLowAddress() + " highAddr: " + getHighAddress() + " strings: " + strings.size();
    for (int i = 0; i < strings.size(); i++) {
      result = result + "\n" + (String)strings.get(i);
    }
    return result;
  }
}

/* Location:
 * Qualified Name:     sun.jvm.hotspot.ui.Annotation
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package sun.jvm.hotspot.ui.classbrowser;

import javax.swing.event.HyperlinkEvent;
import javax.swing.event.HyperlinkEvent.EventType;
import javax.swing.event.HyperlinkListener;
import sun.jvm.hotspot.ui.SAEditorPane;

final class ClassBrowserPanel$1
  implements HyperlinkListener
{
  private final ClassBrowserPanel this$0;
  
  ClassBrowserPanel$1(ClassBrowserPanel paramClassBrowserPanel) {}
  
  public void hyperlinkUpdate(HyperlinkEvent e)
  {
    if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
      ClassBrowserPanel.access$100(this$0).setText(ClassBrowserPanel.access$000(this$0).genHTMLForHyperlink(e.getDescription()));
    }
  }
}

/* Location:
 * Qualified Name:     sun.jvm.hotspot.ui.classbrowser.ClassBrowserPanel.1
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package sun.jvm.hotspot.ui.classbrowser;

import com.sun.java.swing.action.ActionManager;
import com.sun.java.swing.ui.CommonToolBar;
import com.sun.java.swing.ui.StatusBar;
import javax.swing.ActionMap;
import javax.swing.InputMap;
import javax.swing.JTextField;
import javax.swing.KeyStroke;
import sun.jvm.hotspot.ui.action.HSDBActionManager;

class ClassBrowserPanel$ClassBrowserToolBar
  extends CommonToolBar
{
  private JTextField searchTF;
  private final ClassBrowserPanel this$0;
  
  public ClassBrowserPanel$ClassBrowserToolBar(ClassBrowserPanel paramClassBrowserPanel, StatusBar status)
  {
    super(HSDBActionManager.getInstance(), status);
  }
  
  protected void addComponents()
  {
    searchTF = new JTextField();
    searchTF.setToolTipText("Find classes");
    
    InputMap im = searchTF.getInputMap();
    im.put(KeyStroke.getKeyStroke("ENTER"), "enterPressed");
    ActionMap am = searchTF.getActionMap();
    am.put("enterPressed", manager.getAction("find-classes-command"));
    
    add(searchTF);
    addButton(manager.getAction("find-classes-command"));
  }
  
  public String getFindText()
  {
    return searchTF.getText();
  }
}

/* Location:
 * Qualified Name:     sun.jvm.hotspot.ui.classbrowser.ClassBrowserPanel.ClassBrowserToolBar
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package sun.jvm.hotspot.ui.classbrowser;

import com.sun.java.swing.action.ActionManager;
import com.sun.java.swing.action.DelegateAction;
import com.sun.java.swing.ui.CommonToolBar;
import com.sun.java.swing.ui.StatusBar;
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.ActionMap;
import javax.swing.InputMap;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JSplitPane;
import javax.swing.JTextField;
import javax.swing.KeyStroke;
import javax.swing.event.HyperlinkEvent;
import javax.swing.event.HyperlinkEvent.EventType;
import javax.swing.event.HyperlinkListener;
import sun.jvm.hotspot.oops.InstanceKlass;
import sun.jvm.hotspot.ui.SAEditorPane;
import sun.jvm.hotspot.ui.action.HSDBActionManager;
import sun.jvm.hotspot.utilities.SystemDictionaryHelper;

public class ClassBrowserPanel
  extends JPanel
  implements ActionListener
{
  private StatusBar statusBar;
  private ClassBrowserToolBar toolBar;
  private JSplitPane splitPane;
  private SAEditorPane classesEditor;
  private SAEditorPane contentEditor;
  private HTMLGenerator htmlGen;
  
  public ClassBrowserPanel()
  {
    htmlGen = new HTMLGenerator();
    
    HyperlinkListener hyperListener = new HyperlinkListener()
    {
      public void hyperlinkUpdate(HyperlinkEvent e)
      {
        if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
          contentEditor.setText(htmlGen.genHTMLForHyperlink(e.getDescription()));
        }
      }
    };
    classesEditor = new SAEditorPane();
    classesEditor.addHyperlinkListener(hyperListener);
    
    contentEditor = new SAEditorPane();
    contentEditor.addHyperlinkListener(hyperListener);
    
    JPanel topPanel = new JPanel();
    topPanel.setLayout(new BorderLayout());
    topPanel.add(new JScrollPane(classesEditor), "Center");
    
    JPanel bottomPanel = new JPanel();
    bottomPanel.setLayout(new BorderLayout());
    bottomPanel.add(new JScrollPane(contentEditor), "Center");
    
    splitPane = new JSplitPane(0, topPanel, bottomPanel);
    splitPane.setDividerLocation(0);
    
    setLayout(new BorderLayout());
    add(splitPane, "Center");
    statusBar = new StatusBar();
    add(statusBar, "South");
    toolBar = new ClassBrowserToolBar(statusBar);
    add(toolBar, "North");
    registerActions();
  }
  
  public void setClassesText(String text)
  {
    classesEditor.setText(text);
    splitPane.setDividerLocation(0.5D);
  }
  
  public void setContentText(String text)
  {
    contentEditor.setText(text);
    splitPane.setDividerLocation(0.5D);
  }
  
  private class ClassBrowserToolBar
    extends CommonToolBar
  {
    private JTextField searchTF;
    
    public ClassBrowserToolBar(StatusBar status)
    {
      super(status);
    }
    
    protected void addComponents()
    {
      searchTF = new JTextField();
      searchTF.setToolTipText("Find classes");
      
      InputMap im = searchTF.getInputMap();
      im.put(KeyStroke.getKeyStroke("ENTER"), "enterPressed");
      ActionMap am = searchTF.getActionMap();
      am.put("enterPressed", manager.getAction("find-classes-command"));
      
      add(searchTF);
      addButton(manager.getAction("find-classes-command"));
    }
    
    public String getFindText()
    {
      return searchTF.getText();
    }
  }
  
  public void actionPerformed(ActionEvent evt)
  {
    String command = evt.getActionCommand();
    if (command.equals("find-classes-command")) {
      findClasses();
    }
  }
  
  protected void registerActions()
  {
    registerAction("find-classes-command");
  }
  
  private void registerAction(String actionName)
  {
    ActionManager manager = ActionManager.getInstance();
    DelegateAction action = manager.getDelegateAction(actionName);
    action.addActionListener(this);
  }
  
  private void findClasses()
  {
    String findText = toolBar.getFindText();
    if ((findText == null) || (findText.equals(""))) {
      return;
    }
    setContentText(htmlGen.genHTMLForWait("Finding classes ..."));
    InstanceKlass[] klasses = SystemDictionaryHelper.findInstanceKlasses(findText);
    if (klasses.length == 0) {
      setContentText(htmlGen.genHTMLForMessage("No class found with name containing '" + findText + "'"));
    } else {
      setContentText(htmlGen.genHTMLForKlassNames(klasses));
    }
  }
}

/* Location:
 * Qualified Name:     sun.jvm.hotspot.ui.classbrowser.ClassBrowserPanel
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package sun.jvm.hotspot.ui.classbrowser;

import javax.swing.event.HyperlinkEvent;
import javax.swing.event.HyperlinkEvent.EventType;
import javax.swing.event.HyperlinkListener;
import sun.jvm.hotspot.ui.HistoryComboBox;
import sun.jvm.hotspot.ui.SAEditorPane;

final class CodeViewerPanel$1
  implements HyperlinkListener
{
  private final CodeViewerPanel this$0;
  
  CodeViewerPanel$1(CodeViewerPanel paramCodeViewerPanel) {}
  
  public void hyperlinkUpdate(HyperlinkEvent e)
  {
    if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED)
    {
      String description = e.getDescription();
      int equalToIndex = description.indexOf('=');
      if (equalToIndex != -1)
      {
        String item = description.substring(0, equalToIndex);
        if ((item.equals("pc")) || (item.equals("klass")) || (item.equals("method"))) {
          this$0.address.setText(description.substring(equalToIndex + 1));
        }
      }
      this$0.contentEditor.setText(this$0.htmlGen.genHTMLForHyperlink(description));
    }
  }
}

/* Location:
 * Qualified Name:     sun.jvm.hotspot.ui.classbrowser.CodeViewerPanel.1
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package sun.jvm.hotspot.ui.classbrowser;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

final class CodeViewerPanel$2
  implements ActionListener
{
  private final CodeViewerPanel this$0;
  
  CodeViewerPanel$2(CodeViewerPanel paramCodeViewerPanel) {}
  
  public void actionPerformed(ActionEvent e)
  {
    CodeViewerPanel.access$000(this$0);
  }
}

/* Location:
 * Qualified Name:     sun.jvm.hotspot.ui.classbrowser.CodeViewerPanel.2
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package sun.jvm.hotspot.ui.classbrowser;

import java.awt.BorderLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.event.HyperlinkEvent;
import javax.swing.event.HyperlinkEvent.EventType;
import javax.swing.event.HyperlinkListener;
import sun.jvm.hotspot.debugger.Address;
import sun.jvm.hotspot.ui.HistoryComboBox;
import sun.jvm.hotspot.ui.SAEditorPane;

public class CodeViewerPanel
  extends JPanel
{
  protected SAEditorPane contentEditor;
  protected HistoryComboBox address;
  protected HTMLGenerator htmlGen;
  protected JScrollPane scrollPane;
  
  public CodeViewerPanel()
  {
    htmlGen = new HTMLGenerator();
    contentEditor = new SAEditorPane();
    
    HyperlinkListener hyperListener = new HyperlinkListener()
    {
      public void hyperlinkUpdate(HyperlinkEvent e)
      {
        if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED)
        {
          String description = e.getDescription();
          int equalToIndex = description.indexOf('=');
          if (equalToIndex != -1)
          {
            String item = description.substring(0, equalToIndex);
            if ((item.equals("pc")) || (item.equals("klass")) || (item.equals("method"))) {
              address.setText(description.substring(equalToIndex + 1));
            }
          }
          contentEditor.setText(htmlGen.genHTMLForHyperlink(description));
        }
      }
    };
    setLayout(new BorderLayout());
    
    JPanel topPanel = new JPanel();
    topPanel.setLayout(new BorderLayout());
    topPanel.add(new JLabel("Enter PC or methodOop/klassOop Address: "), "West");
    address = new HistoryComboBox();
    topPanel.add(address, "Center");
    
    JPanel bottomPanel = new JPanel();
    bottomPanel.setLayout(new GridLayout(1, 1));
    contentEditor = new SAEditorPane();
    contentEditor.addHyperlinkListener(hyperListener);
    scrollPane = new JScrollPane(contentEditor);
    bottomPanel.add(scrollPane);
    
    add(topPanel, "North");
    add(bottomPanel, "Center");
    
    address.addActionListener(new ActionListener()
    {
      public void actionPerformed(ActionEvent e)
      {
        CodeViewerPanel.this.viewAddress();
      }
    });
  }
  
  private void viewAddress()
  {
    if ((address.getText() != null) && (!address.getText().equals(""))) {
      contentEditor.setText(htmlGen.genHTMLForAddress(address.getText()));
    }
  }
  
  public void viewAddress(Address addr)
  {
    address.setText(addr.toString());
    viewAddress();
  }
}

/* Location:
 * Qualified Name:     sun.jvm.hotspot.ui.classbrowser.CodeViewerPanel
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package sun.jvm.hotspot.ui.classbrowser;

import java.util.Observable;
import java.util.Observer;

final class HTMLGenerator$1
  implements Observer
{
  public void update(Observable o, Object data) {}
}

/* Location:
 * Qualified Name:     sun.jvm.hotspot.ui.classbrowser.HTMLGenerator.1
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package sun.jvm.hotspot.ui.classbrowser;

import sun.jvm.hotspot.asm.Address;
import sun.jvm.hotspot.asm.CallInstruction;
import sun.jvm.hotspot.asm.Instruction;
import sun.jvm.hotspot.asm.InstructionVisitor;
import sun.jvm.hotspot.asm.SymbolFinder;
import sun.jvm.hotspot.code.CodeBlob;
import sun.jvm.hotspot.compiler.OopMap;
import sun.jvm.hotspot.compiler.OopMapSet;

class HTMLGenerator$1CodeBlobVisitor
  implements InstructionVisitor
{
  OopMapSet maps;
  OopMap curMap;
  int curMapIndex;
  long curMapOffset;
  private final HTMLGenerator this$0;
  
  HTMLGenerator$1CodeBlobVisitor(HTMLGenerator paramHTMLGenerator, CodeBlob paramCodeBlob, HTMLGenerator.Formatter paramFormatter, SymbolFinder paramSymbolFinder, long paramLong) {}
  
  public void prologue()
  {
    maps = val$blob.getOopMaps();
    if ((maps != null) && (maps.getSize() > 0L))
    {
      curMap = maps.getMapAt(0);
      if (curMap != null) {
        curMapOffset = curMap.getOffset();
      }
    }
  }
  
  public void visit(long currentPc, Instruction instr)
  {
    String href = null;
    if (instr.isCall())
    {
      CallInstruction call = (CallInstruction)instr;
      Address addr = call.getBranchDestination();
      href = this$0.genPCHref(currentPc, addr);
    }
    val$buf.append("0x");
    val$buf.append(Long.toHexString(currentPc));
    val$buf.append(':');
    val$buf.append(HTMLGenerator.access$200(this$0));
    if (href != null) {
      val$buf.link(href, instr.asString(currentPc, val$symFinder));
    } else {
      val$buf.append(instr.asString(currentPc, val$symFinder));
    }
    val$buf.br();
    if (curMap != null)
    {
      long curOffset = currentPc - val$startPc;
      if (curOffset == curMapOffset)
      {
        val$buf.append(this$0.genOopMapInfo(curMap));
        if (++curMapIndex >= maps.getSize())
        {
          curMap = null;
        }
        else
        {
          curMap = maps.getMapAt(curMapIndex);
          if (curMap != null) {
            curMapOffset = curMap.getOffset();
          }
        }
      }
    }
  }
  
  public void epilogue() {}
}

/* Location:
 * Qualified Name:     sun.jvm.hotspot.ui.classbrowser.HTMLGenerator.1CodeBlobVisitor
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package sun.jvm.hotspot.ui.classbrowser;

import java.util.Map;
import sun.jvm.hotspot.asm.Address;
import sun.jvm.hotspot.asm.CallInstruction;
import sun.jvm.hotspot.asm.Instruction;
import sun.jvm.hotspot.asm.InstructionVisitor;
import sun.jvm.hotspot.asm.SymbolFinder;
import sun.jvm.hotspot.code.NMethod;
import sun.jvm.hotspot.code.PCDesc;

class HTMLGenerator$1NMethodVisitor
  implements InstructionVisitor
{
  private final HTMLGenerator this$0;
  
  HTMLGenerator$1NMethodVisitor(HTMLGenerator paramHTMLGenerator, long paramLong1, HTMLGenerator.Formatter paramFormatter, long paramLong2, Map paramMap, NMethod paramNMethod, SymbolFinder paramSymbolFinder) {}
  
  public void prologue() {}
  
  public void visit(long currentPc, Instruction instr)
  {
    String href = null;
    if (instr.isCall())
    {
      CallInstruction call = (CallInstruction)instr;
      Address addr = call.getBranchDestination();
      href = this$0.genPCHref(currentPc, addr);
    }
    if (currentPc == val$verifiedEntryPoint)
    {
      val$buf.bold("Verified Entry Point");val$buf.br();
    }
    if (currentPc == val$entryPoint)
    {
      val$buf.bold(">Entry Point");val$buf.br();
    }
    PCDesc pcDesc = (PCDesc)val$safepoints.get(this$0.longToAddress(currentPc));
    if (pcDesc != null) {
      val$buf.append(this$0.genSafepointInfo(val$nmethod, pcDesc));
    }
    val$buf.append("0x");
    val$buf.append(Long.toHexString(currentPc));
    val$buf.append(':');
    val$buf.append(HTMLGenerator.access$200(this$0));
    if (href != null) {
      val$buf.link(href, instr.asString(currentPc, val$symFinder));
    } else {
      val$buf.append(instr.asString(currentPc, val$symFinder));
    }
    val$buf.br();
  }
  
  public void epilogue() {}
}

/* Location:
 * Qualified Name:     sun.jvm.hotspot.ui.classbrowser.HTMLGenerator.1NMethodVisitor
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package sun.jvm.hotspot.ui.classbrowser;

import sun.jvm.hotspot.code.VMRegImpl;
import sun.jvm.hotspot.compiler.OopMapStream;
import sun.jvm.hotspot.compiler.OopMapValue;
import sun.jvm.hotspot.runtime.VMReg;

final class HTMLGenerator$1OopMapValueIterator
{
  private final HTMLGenerator this$0;
  
  HTMLGenerator$1OopMapValueIterator(HTMLGenerator paramHTMLGenerator, int paramInt) {}
  
  final HTMLGenerator.Formatter iterate(OopMapStream oms, String type, boolean printContentReg)
  {
    HTMLGenerator.Formatter tmpBuf = new HTMLGenerator.Formatter(HTMLGenerator.access$300(this$0));
    boolean found = false;
    tmpBuf.beginTag("tr");
    tmpBuf.beginTag("td");
    tmpBuf.append(type);
    for (; !oms.isDone(); oms.next())
    {
      OopMapValue omv = oms.getCurrent();
      if (omv != null)
      {
        found = true;
        VMReg vmReg = omv.getReg();
        int reg = vmReg.getValue();
        if (reg < val$stack0)
        {
          tmpBuf.append(VMRegImpl.getRegisterName(reg));
        }
        else
        {
          tmpBuf.append('[');
          tmpBuf.append(Integer.toString((reg - val$stack0) * 4));
          tmpBuf.append(']');
        }
        if (printContentReg)
        {
          tmpBuf.append(" = ");
          VMReg vmContentReg = omv.getContentReg();
          int contentReg = vmContentReg.getValue();
          if (contentReg < val$stack0)
          {
            tmpBuf.append(VMRegImpl.getRegisterName(contentReg));
          }
          else
          {
            tmpBuf.append('[');
            tmpBuf.append(Integer.toString((contentReg - val$stack0) * 4));
            tmpBuf.append(']');
          }
        }
        tmpBuf.append(HTMLGenerator.access$100(this$0));
      }
    }
    tmpBuf.endTag("td");
    tmpBuf.endTag("tr");
    return found ? tmpBuf : new HTMLGenerator.Formatter(HTMLGenerator.access$300(this$0));
  }
}

/* Location:
 * Qualified Name:     sun.jvm.hotspot.ui.classbrowser.HTMLGenerator.1OopMapValueIterator
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package sun.jvm.hotspot.ui.classbrowser;

import sun.jvm.hotspot.interpreter.Bytecode;
import sun.jvm.hotspot.interpreter.BytecodeGetPut;
import sun.jvm.hotspot.interpreter.BytecodeInvoke;
import sun.jvm.hotspot.interpreter.BytecodeLoadConstant;
import sun.jvm.hotspot.interpreter.BytecodeNew;
import sun.jvm.hotspot.interpreter.BytecodeVisitor;
import sun.jvm.hotspot.oops.Field;
import sun.jvm.hotspot.oops.InstanceKlass;
import sun.jvm.hotspot.oops.Klass;
import sun.jvm.hotspot.oops.Method;
import sun.jvm.hotspot.oops.Oop;

final class HTMLGenerator$2
  implements BytecodeVisitor
{
  private Method method;
  private final HTMLGenerator this$0;
  
  HTMLGenerator$2(HTMLGenerator paramHTMLGenerator, HTMLGenerator.Formatter paramFormatter, boolean paramBoolean) {}
  
  public void prologue(Method m)
  {
    method = m;
    val$buf.beginTable(0);
    val$buf.beginTag("tr");
    if (val$hasLineNumbers) {
      val$buf.headerCell("line");
    }
    val$buf.headerCell("bci" + HTMLGenerator.access$100(this$0));
    val$buf.headerCell("bytecode");
    val$buf.endTag("tr");
  }
  
  public void visit(Bytecode instr)
  {
    int curBci = instr.bci();
    val$buf.beginTag("tr");
    if (val$hasLineNumbers)
    {
      int lineNumber = method.getLineNumberFromBCI(curBci);
      val$buf.cell(Integer.toString(lineNumber) + HTMLGenerator.access$100(this$0));
    }
    val$buf.cell(Integer.toString(curBci) + HTMLGenerator.access$100(this$0));
    
    val$buf.beginTag("td");
    String instrStr = null;
    try
    {
      instrStr = this$0.escapeHTMLSpecialChars(instr.toString());
    }
    catch (RuntimeException re)
    {
      val$buf.append("exception during bytecode processing");
      val$buf.endTag("td");
      val$buf.endTag("tr");
      re.printStackTrace();
      return;
    }
    if ((instr instanceof BytecodeNew))
    {
      BytecodeNew newBytecode = (BytecodeNew)instr;
      InstanceKlass klass = newBytecode.getNewKlass();
      if (klass != null) {
        val$buf.link(this$0.genKlassHref(klass), instrStr);
      } else {
        val$buf.append(instrStr);
      }
    }
    else if ((instr instanceof BytecodeInvoke))
    {
      BytecodeInvoke invokeBytecode = (BytecodeInvoke)instr;
      Method m = invokeBytecode.getInvokedMethod();
      if (m != null)
      {
        val$buf.link(this$0.genMethodHref(m), instrStr);
        val$buf.append(" of ");
        InstanceKlass klass = (InstanceKlass)m.getMethodHolder();
        val$buf.link(this$0.genKlassHref(klass), this$0.genKlassTitle(klass));
      }
      else
      {
        val$buf.append(instrStr);
      }
    }
    else if ((instr instanceof BytecodeGetPut))
    {
      BytecodeGetPut getPut = (BytecodeGetPut)instr;
      Field f = getPut.getField();
      val$buf.append(instrStr);
      if (f != null)
      {
        InstanceKlass klass = f.getFieldHolder();
        val$buf.append(" of ");
        val$buf.link(this$0.genKlassHref(klass), this$0.genKlassTitle(klass));
      }
    }
    else if ((instr instanceof BytecodeLoadConstant))
    {
      BytecodeLoadConstant ldc = (BytecodeLoadConstant)instr;
      if (ldc.isKlassConstant())
      {
        Oop oop = ldc.getKlass();
        if ((oop instanceof Klass))
        {
          val$buf.append("<a href='");
          val$buf.append(this$0.genKlassHref((InstanceKlass)oop));
          val$buf.append("'>");
          val$buf.append(instrStr);
          val$buf.append("</a>");
        }
        else
        {
          val$buf.append(instrStr);
        }
      }
      else
      {
        val$buf.append(instrStr);
      }
    }
    else
    {
      val$buf.append(instrStr);
    }
    val$buf.endTag("td");
    val$buf.endTag("tr");
  }
  
  public void epilogue()
  {
    val$buf.endTable();
  }
}

/* Location:
 * Qualified Name:     sun.jvm.hotspot.ui.classbrowser.HTMLGenerator.2
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package sun.jvm.hotspot.ui.classbrowser;

class HTMLGenerator$Formatter
{
  boolean html;
  StringBuffer buf = new StringBuffer();
  
  HTMLGenerator$Formatter(boolean h)
  {
    html = h;
  }
  
  void append(String s)
  {
    buf.append(s);
  }
  
  void append(int s)
  {
    buf.append(s);
  }
  
  void append(char s)
  {
    buf.append(s);
  }
  
  void append(StringBuffer s)
  {
    buf.append(s);
  }
  
  void append(Formatter s)
  {
    buf.append(s);
  }
  
  StringBuffer getBuffer()
  {
    return buf;
  }
  
  public String toString()
  {
    return buf.toString();
  }
  
  void wrap(String tag, String text)
  {
    wrap(tag, tag, text);
  }
  
  void wrap(String before, String after, String text)
  {
    beginTag(before);
    append(text);
    endTag(after);
  }
  
  void h1(String s)
  {
    nl();wrap("h1", s);nl();
  }
  
  void h2(String s)
  {
    nl();wrap("h2", s);nl();
  }
  
  void h3(String s)
  {
    nl();wrap("h3", s);nl();
  }
  
  void h4(String s)
  {
    nl();wrap("h4", s);nl();
  }
  
  void beginList()
  {
    beginTag("ul");nl();
  }
  
  void endList()
  {
    endTag("ul");nl();
  }
  
  void beginListItem()
  {
    beginTag("li");
  }
  
  void endListItem()
  {
    endTag("li");nl();
  }
  
  void li(String s)
  {
    wrap("li", s);nl();
  }
  
  void beginTable(int border)
  {
    beginTag("table border='" + border + "'");
  }
  
  void cell(String s)
  {
    wrap("td", s);
  }
  
  void headerCell(String s)
  {
    wrap("th", s);
  }
  
  void endTable()
  {
    endTag("table");
  }
  
  void link(String href, String text)
  {
    wrap("a href='" + href + "'", "a", text);
  }
  
  void beginTag(String s)
  {
    if (html)
    {
      append("<");append(s);append(">");
    }
  }
  
  void endTag(String s)
  {
    if (html)
    {
      append("</");append(s);append(">");
    }
    else
    {
      if ((s.equals("table")) || (s.equals("tr"))) {
        nl();
      }
      if ((s.equals("td")) || (s.equals("th"))) {
        append(" ");
      }
    }
  }
  
  void bold(String s)
  {
    wrap("b", s);
  }
  
  void nl()
  {
    if (!html) {
      buf.append("\n");
    }
  }
  
  void br()
  {
    if (html) {
      append("<br>");
    } else {
      append("\n");
    }
  }
  
  void genEmptyHTML()
  {
    if (html) {
      append("<html></html>");
    }
  }
  
  void genHTMLPrologue()
  {
    if (html) {
      append("<html><body>");
    }
  }
  
  void genHTMLPrologue(String title)
  {
    if (html)
    {
      append("<html><head><title>");
      append(title);
      append("</title></head>");
      append("<body>");
    }
    h2(title);
  }
  
  void genHTMLEpilogue()
  {
    if (html) {
      append("</body></html>");
    }
  }
}

/* Location:
 * Qualified Name:     sun.jvm.hotspot.ui.classbrowser.HTMLGenerator.Formatter
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package sun.jvm.hotspot.ui.classbrowser;

import sun.jvm.hotspot.asm.Address;
import sun.jvm.hotspot.asm.CallInstruction;
import sun.jvm.hotspot.asm.Instruction;
import sun.jvm.hotspot.asm.InstructionVisitor;
import sun.jvm.hotspot.asm.SymbolFinder;

class HTMLGenerator$RawCodeVisitor
  implements InstructionVisitor
{
  private int instrSize = 0;
  private HTMLGenerator.Formatter buf;
  private SymbolFinder symFinder = this$0.createSymbolFinder();
  private final HTMLGenerator this$0;
  
  HTMLGenerator$RawCodeVisitor(HTMLGenerator paramHTMLGenerator, HTMLGenerator.Formatter buf)
  {
    this.buf = buf;
  }
  
  public int getInstructionSize()
  {
    return instrSize;
  }
  
  public void prologue() {}
  
  public void visit(long currentPc, Instruction instr)
  {
    String href = null;
    if (instr.isCall())
    {
      CallInstruction call = (CallInstruction)instr;
      Address addr = call.getBranchDestination();
      href = this$0.genPCHref(currentPc, addr);
    }
    instrSize += instr.getSize();
    buf.append("0x");
    buf.append(Long.toHexString(currentPc));
    buf.append(':');
    buf.append(HTMLGenerator.access$200(this$0));
    if (href != null) {
      buf.link(href, instr.asString(currentPc, symFinder));
    } else {
      buf.append(instr.asString(currentPc, symFinder));
    }
    buf.br();
  }
  
  public void epilogue() {}
}

/* Location:
 * Qualified Name:     sun.jvm.hotspot.ui.classbrowser.HTMLGenerator.RawCodeVisitor
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package sun.jvm.hotspot.ui.classbrowser;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.List;
import java.util.Map;
import java.util.Observable;
import java.util.Observer;
import java.util.StringTokenizer;
import sun.jvm.hotspot.asm.CPUHelper;
import sun.jvm.hotspot.asm.CallInstruction;
import sun.jvm.hotspot.asm.DirectAddress;
import sun.jvm.hotspot.asm.Disassembler;
import sun.jvm.hotspot.asm.DummySymbolFinder;
import sun.jvm.hotspot.asm.Instruction;
import sun.jvm.hotspot.asm.InstructionVisitor;
import sun.jvm.hotspot.asm.PCRelativeAddress;
import sun.jvm.hotspot.asm.SymbolFinder;
import sun.jvm.hotspot.asm.amd64.AMD64Helper;
import sun.jvm.hotspot.asm.ia64.IA64Helper;
import sun.jvm.hotspot.asm.sparc.SPARCHelper;
import sun.jvm.hotspot.asm.x86.X86Helper;
import sun.jvm.hotspot.code.CodeBlob;
import sun.jvm.hotspot.code.CodeCache;
import sun.jvm.hotspot.code.ConstantDoubleValue;
import sun.jvm.hotspot.code.ConstantIntValue;
import sun.jvm.hotspot.code.ConstantLongValue;
import sun.jvm.hotspot.code.ConstantOopReadValue;
import sun.jvm.hotspot.code.Location;
import sun.jvm.hotspot.code.Location.Type;
import sun.jvm.hotspot.code.Location.Where;
import sun.jvm.hotspot.code.LocationValue;
import sun.jvm.hotspot.code.MonitorValue;
import sun.jvm.hotspot.code.NMethod;
import sun.jvm.hotspot.code.ObjectValue;
import sun.jvm.hotspot.code.PCDesc;
import sun.jvm.hotspot.code.ScopeDesc;
import sun.jvm.hotspot.code.ScopeValue;
import sun.jvm.hotspot.code.Stub;
import sun.jvm.hotspot.code.StubQueue;
import sun.jvm.hotspot.code.VMRegImpl;
import sun.jvm.hotspot.compiler.OopMap;
import sun.jvm.hotspot.compiler.OopMapSet;
import sun.jvm.hotspot.compiler.OopMapStream;
import sun.jvm.hotspot.compiler.OopMapValue;
import sun.jvm.hotspot.compiler.OopMapValue.OopTypes;
import sun.jvm.hotspot.debugger.JVMDebugger;
import sun.jvm.hotspot.debugger.OopHandle;
import sun.jvm.hotspot.interpreter.Bytecode;
import sun.jvm.hotspot.interpreter.BytecodeDisassembler;
import sun.jvm.hotspot.interpreter.BytecodeGetPut;
import sun.jvm.hotspot.interpreter.BytecodeInvoke;
import sun.jvm.hotspot.interpreter.BytecodeLoadConstant;
import sun.jvm.hotspot.interpreter.BytecodeNew;
import sun.jvm.hotspot.interpreter.BytecodeVisitor;
import sun.jvm.hotspot.interpreter.Interpreter;
import sun.jvm.hotspot.interpreter.InterpreterCodelet;
import sun.jvm.hotspot.oops.AccessFlags;
import sun.jvm.hotspot.oops.CheckedExceptionElement;
import sun.jvm.hotspot.oops.ConstantPool;
import sun.jvm.hotspot.oops.Field;
import sun.jvm.hotspot.oops.InstanceKlass;
import sun.jvm.hotspot.oops.Klass;
import sun.jvm.hotspot.oops.Method;
import sun.jvm.hotspot.oops.NamedFieldIdentifier;
import sun.jvm.hotspot.oops.ObjArray;
import sun.jvm.hotspot.oops.ObjArrayKlass;
import sun.jvm.hotspot.oops.ObjectHeap;
import sun.jvm.hotspot.oops.Oop;
import sun.jvm.hotspot.oops.OopUtilities;
import sun.jvm.hotspot.oops.Symbol;
import sun.jvm.hotspot.oops.TypeArray;
import sun.jvm.hotspot.oops.TypeArrayKlass;
import sun.jvm.hotspot.runtime.ClassConstants;
import sun.jvm.hotspot.runtime.Frame;
import sun.jvm.hotspot.runtime.JavaThread;
import sun.jvm.hotspot.runtime.JavaThreadState;
import sun.jvm.hotspot.runtime.JavaVFrame;
import sun.jvm.hotspot.runtime.SignatureConverter;
import sun.jvm.hotspot.runtime.VM;
import sun.jvm.hotspot.runtime.VMObjectFactory;
import sun.jvm.hotspot.runtime.VMReg;
import sun.jvm.hotspot.tools.jcore.ClassWriter;
import sun.jvm.hotspot.utilities.Assert;

public class HTMLGenerator
  implements ClassConstants
{
  private static final String DUMP_KLASS_OUTPUT_DIR = ".";
  private static final int NATIVE_CODE_SIZE = 200;
  private final String spaces;
  private final String tab;
  
  static class Formatter
  {
    boolean html;
    StringBuffer buf = new StringBuffer();
    
    Formatter(boolean h)
    {
      html = h;
    }
    
    void append(String s)
    {
      buf.append(s);
    }
    
    void append(int s)
    {
      buf.append(s);
    }
    
    void append(char s)
    {
      buf.append(s);
    }
    
    void append(StringBuffer s)
    {
      buf.append(s);
    }
    
    void append(Formatter s)
    {
      buf.append(s);
    }
    
    StringBuffer getBuffer()
    {
      return buf;
    }
    
    public String toString()
    {
      return buf.toString();
    }
    
    void wrap(String tag, String text)
    {
      wrap(tag, tag, text);
    }
    
    void wrap(String before, String after, String text)
    {
      beginTag(before);
      append(text);
      endTag(after);
    }
    
    void h1(String s)
    {
      nl();wrap("h1", s);nl();
    }
    
    void h2(String s)
    {
      nl();wrap("h2", s);nl();
    }
    
    void h3(String s)
    {
      nl();wrap("h3", s);nl();
    }
    
    void h4(String s)
    {
      nl();wrap("h4", s);nl();
    }
    
    void beginList()
    {
      beginTag("ul");nl();
    }
    
    void endList()
    {
      endTag("ul");nl();
    }
    
    void beginListItem()
    {
      beginTag("li");
    }
    
    void endListItem()
    {
      endTag("li");nl();
    }
    
    void li(String s)
    {
      wrap("li", s);nl();
    }
    
    void beginTable(int border)
    {
      beginTag("table border='" + border + "'");
    }
    
    void cell(String s)
    {
      wrap("td", s);
    }
    
    void headerCell(String s)
    {
      wrap("th", s);
    }
    
    void endTable()
    {
      endTag("table");
    }
    
    void link(String href, String text)
    {
      wrap("a href='" + href + "'", "a", text);
    }
    
    void beginTag(String s)
    {
      if (html)
      {
        append("<");append(s);append(">");
      }
    }
    
    void endTag(String s)
    {
      if (html)
      {
        append("</");append(s);append(">");
      }
      else
      {
        if ((s.equals("table")) || (s.equals("tr"))) {
          nl();
        }
        if ((s.equals("td")) || (s.equals("th"))) {
          append(" ");
        }
      }
    }
    
    void bold(String s)
    {
      wrap("b", s);
    }
    
    void nl()
    {
      if (!html) {
        buf.append("\n");
      }
    }
    
    void br()
    {
      if (html) {
        append("<br>");
      } else {
        append("\n");
      }
    }
    
    void genEmptyHTML()
    {
      if (html) {
        append("<html></html>");
      }
    }
    
    void genHTMLPrologue()
    {
      if (html) {
        append("<html><body>");
      }
    }
    
    void genHTMLPrologue(String title)
    {
      if (html)
      {
        append("<html><head><title>");
        append(title);
        append("</title></head>");
        append("<body>");
      }
      h2(title);
    }
    
    void genHTMLEpilogue()
    {
      if (html) {
        append("</body></html>");
      }
    }
  }
  
  private boolean genHTML = true;
  private static CPUHelper cpuHelper;
  
  public HTMLGenerator()
  {
    this(true);
  }
  
  public HTMLGenerator(boolean html)
  {
    genHTML = html;
    if (html)
    {
      spaces = "&nbsp;&nbsp;";
      tab = "&nbsp;&nbsp;&nbsp;&nbsp;";
    }
    else
    {
      spaces = "  ";
      tab = "    ";
    }
  }
  
  static
  {
    VM.registerVMInitializedObserver(new Observer()
    {
      public void update(Observable o, Object data) {}
    });
  }
  
  private static synchronized void initialize()
  {
    String cpu = VM.getVM().getCPU();
    if (cpu.equals("sparc")) {
      cpuHelper = new SPARCHelper();
    } else if (cpu.equals("x86")) {
      cpuHelper = new X86Helper();
    } else if (cpu.equals("amd64")) {
      cpuHelper = new AMD64Helper();
    } else if (cpu.equals("ia64")) {
      cpuHelper = new IA64Helper();
    } else {
      throw new RuntimeException("cpu '" + cpu + "' is not yet supported!");
    }
  }
  
  protected static synchronized CPUHelper getCPUHelper()
  {
    return cpuHelper;
  }
  
  protected String escapeHTMLSpecialChars(String value)
  {
    if (!genHTML) {
      return value;
    }
    Formatter buf = new Formatter(genHTML);
    int len = value.length();
    for (int i = 0; i < len; i++)
    {
      char c = value.charAt(i);
      switch (c)
      {
      case '<': 
        buf.append("&lt;");
        break;
      case '>': 
        buf.append("&gt;");
        break;
      case '&': 
        buf.append("&amp;");
        break;
      default: 
        buf.append(c);
      }
    }
    return buf.toString();
  }
  
  public String genHTMLForMessage(String message)
  {
    Formatter buf = new Formatter(genHTML);
    buf.genHTMLPrologue(message);
    buf.genHTMLEpilogue();
    return buf.toString();
  }
  
  public String genHTMLErrorMessage(Exception exp)
  {
    exp.printStackTrace();
    return genHTMLForMessage(exp.getClass().getName() + " : " + exp.getMessage());
  }
  
  public String genHTMLForWait(String message)
  {
    Formatter buf = new Formatter(genHTML);
    buf.genHTMLPrologue("Please wait ..");
    buf.h2(message);
    return buf.toString();
  }
  
  protected String genKlassTitle(InstanceKlass klass)
  {
    Formatter buf = new Formatter(genHTML);
    AccessFlags acc = klass.getAccessFlagsObj();
    if (acc.isPublic()) {
      buf.append("public ");
    } else if (acc.isProtected()) {
      buf.append("protected ");
    } else if (acc.isPrivate()) {
      buf.append("private ");
    }
    if (acc.isStatic()) {
      buf.append("s
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114

Further reading...

For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.

New!JAR listings


Copyright 2006-2019. Infinite Loop Ltd