sa-jdi

ne();
    scroller.getViewport().add(editor);
    add(scroller, "Center");
    
    editor.getDocument().addDocumentListener(new DocumentListener()
    {
      public void changedUpdate(DocumentEvent e) {}
      
      public void insertUpdate(DocumentEvent e)
      {
        if (updating) {
          return;
        }
        DebuggerConsolePanel.this.beginUpdate();
        editor.setCaretPosition(editor.getDocument().getLength());
        if (DebuggerConsolePanel.this.insertContains(e, '\n'))
        {
          String cmd = getMarkedText();
          if ((cmd.length() == 0) || (cmd.charAt(cmd.length() - 1) != '\\'))
          {
            cmd = DebuggerConsolePanel.this.trimContinuations(cmd);
            
            final String result = debugger.consoleExecuteCommand(cmd);
            
            SwingUtilities.invokeLater(new Runnable()
            {
              public void run()
              {
                DebuggerConsolePanel.this.print(result);
                DebuggerConsolePanel.this.printPrompt();
                setMark();
                DebuggerConsolePanel.this.endUpdate();
              }
            });
          }
        }
        else
        {
          DebuggerConsolePanel.this.endUpdate();
        }
      }
      
      public void removeUpdate(DocumentEvent e) {}
    });
    editor.addCaretListener(new CaretListener()
    {
      public void caretUpdate(CaretEvent e)
      {
        int len = editor.getDocument().getLength();
        if (e.getDot() > len) {
          editor.setCaretPosition(len);
        }
      }
    });
    Box hbox = Box.createHorizontalBox();
    hbox.add(Box.createGlue());
    JButton button = new JButton("Clear Saved Text");
    button.addActionListener(new ActionListener()
    {
      public void actionPerformed(ActionEvent e)
      {
        clear();
      }
    });
    hbox.add(button);
    hbox.add(Box.createGlue());
    add(hbox, "South");
    
    clear();
  }
  
  public void requestFocus()
  {
    editor.requestFocus();
  }
  
  public void clear()
  {
    EditableAtEndDocument d = (EditableAtEndDocument)editor.getDocument();
    d.clear();
    printPrompt();
    setMark();
    editor.requestFocus();
  }
  
  public void setMark()
  {
    ((EditableAtEndDocument)editor.getDocument()).setMark();
  }
  
  public String getMarkedText()
  {
    try
    {
      String s = ((EditableAtEndDocument)editor.getDocument()).getMarkedText();
      int i = s.length();
      while ((i > 0) && (s.charAt(i - 1) == '\n')) {
        i--;
      }
      return s.substring(0, i);
    }
    catch (BadLocationException e)
    {
      e.printStackTrace();
    }
    return null;
  }
  
  private void beginUpdate()
  {
    updating = true;
  }
  
  private void endUpdate()
  {
    updating = false;
  }
  
  private void print(String s)
  {
    Document d = editor.getDocument();
    try
    {
      d.insertString(d.getLength(), s, null);
    }
    catch (BadLocationException e)
    {
      e.printStackTrace();
    }
  }
  
  private void printPrompt()
  {
    print(debugger.getConsolePrompt());
  }
  
  private boolean insertContains(DocumentEvent e, char c)
  {
    String s = null;
    try
    {
      s = editor.getText(e.getOffset(), e.getLength());
      for (int i = 0; i < e.getLength(); i++) {
        if (s.charAt(i) == c) {
          return true;
        }
      }
    }
    catch (BadLocationException ex)
    {
      ex.printStackTrace();
    }
    return false;
  }
  
  private String trimContinuations(String text)
  {
    int i;
    while ((i = text.indexOf("\\\n")) >= 0) {
      text = text.substring(0, i) + text.substring(i + 2, text.length());
    }
    return text;
  }
  
  public static void main(String[] args)
  {
    JFrame frame = new JFrame();
    frame.getContentPane().setLayout(new BorderLayout());
    DebuggerConsolePanel panel = new DebuggerConsolePanel(null);
    frame.getContentPane().add(panel, "Center");
    frame.addWindowListener(new WindowAdapter()
    {
      public void windowClosing(WindowEvent e)
      {
        System.exit(0);
      }
    });
    frame.setSize(500, 500);
    frame.setVisible(true);
    panel.requestFocus();
  }
}

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

import javax.swing.text.AttributeSet;
import javax.swing.text.BadLocationException;
import javax.swing.text.PlainDocument;

public class EditableAtEndDocument
  extends PlainDocument
{
  private int mark;
  
  public void insertString(int offset, String text, AttributeSet a)
    throws BadLocationException
  {
    int len = getLength();
    super.insertString(len, text, a);
  }
  
  public void remove(int offs, int len)
    throws BadLocationException
  {
    int start = offs;
    int end = offs + len;
    
    int markStart = mark;
    int markEnd = getLength();
    if ((end < markStart) || (start > markEnd)) {
      return;
    }
    int cutStart = Math.max(start, markStart);
    int cutEnd = Math.min(end, markEnd);
    super.remove(cutStart, cutEnd - cutStart);
  }
  
  public void setMark()
  {
    mark = getLength();
  }
  
  public String getMarkedText()
    throws BadLocationException
  {
    return getText(mark, getLength() - mark);
  }
  
  public void clear()
  {
    try
    {
      super.remove(0, getLength());
      setMark();
    }
    catch (BadLocationException e) {}
  }
}

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

public abstract interface Editor
{
  public abstract String getSourceFileName();
  
  public abstract int getCurrentLineNumber();
  
  public abstract void showLineNumber(int paramInt);
  
  public abstract void highlightLineNumber(int paramInt);
  
  public abstract void showBreakpointAtLine(int paramInt);
  
  public abstract boolean hasBreakpointAtLine(int paramInt);
  
  public abstract void clearBreakpointAtLine(int paramInt);
  
  public abstract void clearBreakpoints();
  
  public abstract void setUserData(Object paramObject);
  
  public abstract Object getUserData();
  
  public abstract void toFront();
}

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

public abstract interface EditorCommands
{
  public abstract void windowClosed(Editor paramEditor);
  
  public abstract void toggleBreakpointAtLine(Editor paramEditor, int paramInt);
}

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

public abstract interface EditorFactory
{
  public abstract Editor openFile(String paramString, EditorCommands paramEditorCommands);
  
  public abstract Editor getCurrentEditor();
}

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

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.debugger.JVMDebugger;
import sun.jvm.hotspot.debugger.OopHandle;
import sun.jvm.hotspot.oops.ObjectHeap;
import sun.jvm.hotspot.runtime.VM;

final class FindByQueryPanel$1
  implements HyperlinkListener
{
  private final FindByQueryPanel this$0;
  
  FindByQueryPanel$1(FindByQueryPanel paramFindByQueryPanel) {}
  
  public void hyperlinkUpdate(HyperlinkEvent e)
  {
    if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED)
    {
      VM vm = VM.getVM();
      OopHandle handle = vm.getDebugger().parseAddress(e.getDescription()).addOffsetToAsOopHandle(0L);
      this$0.showInspector(vm.getObjectHeap().newOop(handle));
    }
  }
}

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

import sun.jvm.hotspot.oops.Oop;
import sun.jvm.hotspot.utilities.soql.JSJavaObject;
import sun.jvm.hotspot.utilities.soql.ObjectVisitor;

final class FindByQueryPanel$2$1
  implements ObjectVisitor
{
  private final FindByQueryPanel.2 this$1;
  
  FindByQueryPanel$2$1(FindByQueryPanel.2 param2, StringBuffer paramStringBuffer) {}
  
  public void visit(Object o)
  {
    if ((o != null) && ((o instanceof JSJavaObject)))
    {
      String oopAddr = ((JSJavaObject)o).getOop().getHandle().toString();
      val$buf.append("<a href='");
      val$buf.append(oopAddr);
      val$buf.append("'>");
      val$buf.append(oopAddr);
      val$buf.append("</a>");
    }
    else
    {
      val$buf.append(o == null ? "null" : o.toString());
    }
    val$buf.append("<br>");
  }
}

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

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JEditorPane;
import javax.swing.JTextArea;
import sun.jvm.hotspot.oops.Oop;
import sun.jvm.hotspot.utilities.soql.JSJavaObject;
import sun.jvm.hotspot.utilities.soql.ObjectVisitor;
import sun.jvm.hotspot.utilities.soql.SOQLEngine;

final class FindByQueryPanel$2
  implements ActionListener
{
  private final FindByQueryPanel this$0;
  
  FindByQueryPanel$2(FindByQueryPanel paramFindByQueryPanel) {}
  
  public void actionPerformed(ActionEvent ae)
  {
    final StringBuffer buf = new StringBuffer();
    buf.append("<html><body>");
    try
    {
      FindByQueryPanel.access$100(this$0).executeQuery(FindByQueryPanel.access$000(this$0).getText(), new ObjectVisitor()
      {
        public void visit(Object o)
        {
          if ((o != null) && ((o instanceof JSJavaObject)))
          {
            String oopAddr = ((JSJavaObject)o).getOop().getHandle().toString();
            buf.append("<a href='");
            buf.append(oopAddr);
            buf.append("'>");
            buf.append(oopAddr);
            buf.append("</a>");
          }
          else
          {
            buf.append(o == null ? "null" : o.toString());
          }
          buf.append("<br>");
        }
      });
    }
    catch (Exception e)
    {
      e.printStackTrace();
      buf.append("<b>");
      buf.append(e.getMessage());
      buf.append("</b>");
    }
    buf.append("</body></html>");
    FindByQueryPanel.access$200(this$0).setText(buf.toString());
  }
}

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

import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JEditorPane;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JSplitPane;
import javax.swing.JTextArea;
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.debugger.JVMDebugger;
import sun.jvm.hotspot.debugger.OopHandle;
import sun.jvm.hotspot.oops.ObjectHeap;
import sun.jvm.hotspot.oops.Oop;
import sun.jvm.hotspot.runtime.VM;
import sun.jvm.hotspot.utilities.soql.JSJavaObject;
import sun.jvm.hotspot.utilities.soql.ObjectVisitor;
import sun.jvm.hotspot.utilities.soql.SOQLEngine;

public class FindByQueryPanel
  extends SAPanel
{
  private JTextArea queryEditor;
  private JEditorPane objectsEditor;
  private SOQLEngine queryEngine;
  
  public FindByQueryPanel()
  {
    queryEngine = SOQLEngine.getEngine();
    HyperlinkListener hyperListener = new HyperlinkListener()
    {
      public void hyperlinkUpdate(HyperlinkEvent e)
      {
        if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED)
        {
          VM vm = VM.getVM();
          OopHandle handle = vm.getDebugger().parseAddress(e.getDescription()).addOffsetToAsOopHandle(0L);
          showInspector(vm.getObjectHeap().newOop(handle));
        }
      }
    };
    objectsEditor = new JEditorPane();
    objectsEditor.setContentType("text/html");
    objectsEditor.setEditable(false);
    objectsEditor.addHyperlinkListener(hyperListener);
    
    queryEditor = new JTextArea();
    JButton queryButton = new JButton("Execute");
    queryButton.addActionListener(new ActionListener()
    {
      public void actionPerformed(ActionEvent ae)
      {
        final StringBuffer buf = new StringBuffer();
        buf.append("<html><body>");
        try
        {
          queryEngine.executeQuery(queryEditor.getText(), new ObjectVisitor()
          {
            public void visit(Object o)
            {
              if ((o != null) && ((o instanceof JSJavaObject)))
              {
                String oopAddr = ((JSJavaObject)o).getOop().getHandle().toString();
                buf.append("<a href='");
                buf.append(oopAddr);
                buf.append("'>");
                buf.append(oopAddr);
                buf.append("</a>");
              }
              else
              {
                buf.append(o == null ? "null" : o.toString());
              }
              buf.append("<br>");
            }
          });
        }
        catch (Exception e)
        {
          e.printStackTrace();
          buf.append("<b>");
          buf.append(e.getMessage());
          buf.append("</b>");
        }
        buf.append("</body></html>");
        objectsEditor.setText(buf.toString());
      }
    });
    JPanel topPanel = new JPanel();
    topPanel.setLayout(new BorderLayout());
    topPanel.add(new JLabel("SOQL Query :"), "West");
    topPanel.add(new JScrollPane(queryEditor), "Center");
    topPanel.add(queryButton, "East");
    
    JPanel bottomPanel = new JPanel();
    bottomPanel.setLayout(new BorderLayout());
    bottomPanel.add(new JScrollPane(objectsEditor), "Center");
    
    JSplitPane splitPane = new JSplitPane(0, topPanel, bottomPanel);
    splitPane.setDividerLocation(0.3D);
    
    setLayout(new BorderLayout());
    add(splitPane, "Center");
  }
}

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

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

final class FindInCodeCachePanel$1
  implements ActionListener
{
  private final FindInCodeCachePanel this$0;
  
  FindInCodeCachePanel$1(FindInCodeCachePanel paramFindInCodeCachePanel) {}
  
  public void actionPerformed(ActionEvent e)
  {
    FindInCodeCachePanel.Visitor.access$1100(FindInCodeCachePanel.access$800(this$0));
  }
}

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

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.debugger.JVMDebugger;
import sun.jvm.hotspot.runtime.VM;

final class FindInCodeCachePanel$2
  implements HyperlinkListener
{
  private final FindInCodeCachePanel this$0;
  
  FindInCodeCachePanel$2(FindInCodeCachePanel paramFindInCodeCachePanel) {}
  
  public void hyperlinkUpdate(HyperlinkEvent e)
  {
    if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED)
    {
      String description = e.getDescription();
      int index = description.indexOf(':');
      if (index != -1)
      {
        String item = description.substring(0, index);
        if (item.equals("blob"))
        {
          Address blob = VM.getVM().getDebugger().parseAddress(description.substring(index + 1));
          this$0.showCodeViewer(blob);
        }
      }
    }
  }
}

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

final class FindInCodeCachePanel$3
  implements Runnable
{
  private final FindInCodeCachePanel this$0;
  
  FindInCodeCachePanel$3(FindInCodeCachePanel paramFindInCodeCachePanel) {}
  
  public void run()
  {
    FindInCodeCachePanel.access$700(this$0).setText("");
  }
}

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

import javax.swing.JButton;

final class FindInCodeCachePanel$4
  implements Runnable
{
  private final FindInCodeCachePanel this$0;
  
  FindInCodeCachePanel$4(FindInCodeCachePanel paramFindInCodeCachePanel, StringBuffer paramStringBuffer) {}
  
  public void run()
  {
    FindInCodeCachePanel.access$1200(this$0).setValue(FindInCodeCachePanel.access$100(this$0) / FindInCodeCachePanel.access$000(this$0));
    if (val$result != null)
    {
      String s = "<html> <head> </head> <body>\n" + val$result + " </body> </html>";
      FindInCodeCachePanel.access$700(this$0).setText(s);
      FindInCodeCachePanel.access$900(this$0).setEnabled(true);
    }
  }
}

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

import sun.jvm.hotspot.code.CodeCache;
import sun.jvm.hotspot.runtime.VM;

final class FindInCodeCachePanel$Visitor$1
  implements Runnable
{
  private final FindInCodeCachePanel.Visitor this$1;
  
  FindInCodeCachePanel$Visitor$1(FindInCodeCachePanel.Visitor paramVisitor) {}
  
  public void run()
  {
    synchronized (FindInCodeCachePanel.access$800(FindInCodeCachePanel.Visitor.access$1000(this$1)))
    {
      try
      {
        VM.getVM().getCodeCache().iterate(FindInCodeCachePanel.access$800(FindInCodeCachePanel.Visitor.access$1000(this$1)));
      }
      finally
      {
        FindInCodeCachePanel.access$800(FindInCodeCachePanel.Visitor.access$1000(this$1)).cleanup();
      }
    }
  }
}

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

import java.io.PrintStream;
import javax.swing.JButton;
import sun.jvm.hotspot.code.CodeBlob;
import sun.jvm.hotspot.code.CodeCache;
import sun.jvm.hotspot.code.CodeCacheVisitor;
import sun.jvm.hotspot.debugger.Address;
import sun.jvm.hotspot.debugger.JVMDebugger;
import sun.jvm.hotspot.runtime.VM;
import sun.jvm.hotspot.utilities.AddressOps;

class FindInCodeCachePanel$Visitor
  implements CodeCacheVisitor
{
  Address base;
  StringBuffer result;
  boolean searching;
  private final FindInCodeCachePanel this$0;
  
  FindInCodeCachePanel$Visitor(FindInCodeCachePanel paramFindInCodeCachePanel) {}
  
  public void prologue(Address start, Address end)
  {
    searching = true;
    base = start;
    FindInCodeCachePanel.access$002(this$0, end.minus(start));
    FindInCodeCachePanel.access$102(this$0, 0L);
    result = new StringBuffer();
    FindInCodeCachePanel.access$200(this$0);
  }
  
  public void visit(CodeBlob blob)
  {
    Address begin = blob.headerBegin();
    Address end = begin.addOffsetTo(blob.getSize());
    long addressSize = VM.getVM().getAddressSize();
    
    boolean found = false;
    while ((!found) && (begin.lessThan(end)))
    {
      Address val = begin.getAddressAt(0L);
      if (AddressOps.equal(val, FindInCodeCachePanel.access$300(this$0)))
      {
        FindInCodeCachePanel.access$400(this$0, result, blob);
        found = true;
      }
      begin = begin.addOffsetTo(addressSize);
    }
    FindInCodeCachePanel.access$102(this$0, end.minus(base));
    FindInCodeCachePanel.access$500(this$0, null);
  }
  
  public void epilogue() {}
  
  public void cleanup()
  {
    FindInCodeCachePanel.access$102(this$0, 0L);
    FindInCodeCachePanel.access$500(this$0, result);
    searching = false;
    result = null;
  }
  
  private void search()
  {
    Address val = null;
    try
    {
      val = VM.getVM().getDebugger().parseAddress(FindInCodeCachePanel.access$600(this$0).getText());
    }
    catch (Exception ex)
    {
      FindInCodeCachePanel.access$700(this$0).setText("<b>Error parsing address</b>");
      return;
    }
    synchronized (FindInCodeCachePanel.access$800(this$0))
    {
      if ((searching) && (FindInCodeCachePanel.access$300(this$0).equals(val))) {
        return;
      }
      FindInCodeCachePanel.access$302(this$0, val);
      FindInCodeCachePanel.access$700(this$0).setText("");
      FindInCodeCachePanel.access$900(this$0).setEnabled(false);
      
      System.out.println("Searching " + FindInCodeCachePanel.access$300(this$0));
      Thread t = new Thread(new Runnable()
      {
        public void run()
        {
          synchronized (FindInCodeCachePanel.access$800(this$0))
          {
            try
            {
              VM.getVM().getCodeCache().iterate(FindInCodeCachePanel.access$800(this$0));
            }
            finally
            {
              FindInCodeCachePanel.access$800(this$0).cleanup();
            }
          }
        }
      });
      t.start();
    }
  }
}

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

import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.PrintStream;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.SwingUtilities;
import javax.swing.event.HyperlinkEvent;
import javax.swing.event.HyperlinkEvent.EventType;
import javax.swing.event.HyperlinkListener;
import sun.jvm.hotspot.code.CodeBlob;
import sun.jvm.hotspot.code.CodeCache;
import sun.jvm.hotspot.code.CodeCacheVisitor;
import sun.jvm.hotspot.debugger.Address;
import sun.jvm.hotspot.debugger.JVMDebugger;
import sun.jvm.hotspot.runtime.VM;
import sun.jvm.hotspot.utilities.AddressOps;

public class FindInCodeCachePanel
  extends SAPanel
{
  private Visitor iterator;
  private long usedSize;
  private long iterated;
  private Address value;
  private ProgressBarPanel progressBar;
  private HistoryComboBox addressField;
  private JButton findButton;
  private SAEditorPane contentEditor;
  
  class Visitor
    implements CodeCacheVisitor
  {
    Address base;
    StringBuffer result;
    boolean searching;
    
    Visitor() {}
    
    public void prologue(Address start, Address end)
    {
      searching = true;
      base = start;
      usedSize = end.minus(start);
      iterated = 0L;
      result = new StringBuffer();
      FindInCodeCachePanel.this.clearResultWindow();
    }
    
    public void visit(CodeBlob blob)
    {
      Address begin = blob.headerBegin();
      Address end = begin.addOffsetTo(blob.getSize());
      long addressSize = VM.getVM().getAddressSize();
      
      boolean found = false;
      while ((!found) && (begin.lessThan(end)))
      {
        Address val = begin.getAddressAt(0L);
        if (AddressOps.equal(val, value))
        {
          FindInCodeCachePanel.this.reportResult(result, blob);
          found = true;
        }
        begin = begin.addOffsetTo(addressSize);
      }
      iterated = end.minus(base);
      FindInCodeCachePanel.this.updateProgressBar(null);
    }
    
    public void epilogue() {}
    
    public void cleanup()
    {
      iterated = 0L;
      FindInCodeCachePanel.this.updateProgressBar(result);
      searching = false;
      result = null;
    }
    
    private void search()
    {
      Address val = null;
      try
      {
        val = VM.getVM().getDebugger().parseAddress(addressField.getText());
      }
      catch (Exception ex)
      {
        contentEditor.setText("<b>Error parsing address</b>");
        return;
      }
      synchronized (iterator)
      {
        if ((searching) && (value.equals(val))) {
          return;
        }
        value = val;
        contentEditor.setText("");
        findButton.setEnabled(false);
        
        System.out.println("Searching " + value);
        Thread t = new Thread(new Runnable()
        {
          public void run()
          {
            synchronized (iterator)
            {
              try
              {
                VM.getVM().getCodeCache().iterate(iterator);
              }
              finally
              {
                iterator.cleanup();
              }
            }
          }
        });
        t.start();
      }
    }
  }
  
  public FindInCodeCachePanel()
  {
    setLayout(new BorderLayout());
    
    JPanel topPanel = new JPanel();
    topPanel.setLayout(new BoxLayout(topPanel, 1));
    
    JPanel panel = new JPanel();
    panel.setLayout(new BoxLayout(panel, 0));
    panel.add(new JLabel("Address to search for:"));
    
    addressField = new HistoryComboBox();
    panel.add(addressField);
    
    iterator = new Visitor();
    
    findButton = new JButton("Find");
    ActionListener listener = new ActionListener()
    {
      public void actionPerformed(ActionEvent e)
      {
        iterator.search();
      }
    };
    panel.add(findButton);
    findButton.addActionListener(listener);
    addressField.addActionListener(listener);
    topPanel.add(panel);
    
    progressBar = new ProgressBarPanel(1, "Search progress:");
    topPanel.add(progressBar);
    
    add(topPanel, "North");
    
    contentEditor = new SAEditorPane();
    
    HyperlinkListener hyperListener = new HyperlinkListener()
    {
      public void hyperlinkUpdate(HyperlinkEvent e)
      {
        if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED)
        {
          String description = e.getDescription();
          int index = description.indexOf(':');
          if (index != -1)
          {
            String item = description.substring(0, index);
            if (item.equals("blob"))
            {
              Address blob = VM.getVM().getDebugger().parseAddress(description.substring(index + 1));
              showCodeViewer(blob);
            }
          }
        }
      }
    };
    contentEditor.addHyperlinkListener(hyperListener);
    
    JScrollPane scroller = new JScrollPane(contentEditor);
    add(scroller, "Center");
  }
  
  private void reportResult(StringBuffer result, CodeBlob blob)
  {
    result.append("<a href='blob:");
    result.append(blob.contentBegin().toString());
    result.append("'>");
    result.append(blob.getName());
    result.append("@");
    result.append(blob.contentBegin());
    result.append("</a><br>");
  }
  
  private void clearResultWindow()
  {
    SwingUtilities.invokeLater(new Runnable()
    {
      public void run()
      {
        contentEditor.setText("");
      }
    });
  }
  
  private void updateProgressBar(final StringBuffer result)
  {
    SwingUtilities.invokeLater(new Runnable()
    {
      public void run()
      {
        progressBar.setValue(iterated / usedSize);
        if (result != null)
        {
          String s = "<html> <head> </head> <body>\n" + result + " </body> </html>";
          contentEditor.setText(s);
          findButton.setEnabled(true);
        }
      }
    });
  }
}

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

import java.util.ArrayList;
import javax.swing.JButton;
import sun.jvm.hotspot.debugger.Address;
import sun.jvm.hotspot.oops.RawHeapVisitor;
import sun.jvm.hotspot.utilities.AddressOps;

final class FindInHeapPanel$1
  implements RawHeapVisitor
{
  boolean error = false;
  private final FindInHeapPanel this$0;
  
  FindInHeapPanel$1(FindInHeapPanel paramFindInHeapPanel) {}
  
  public void prologue(long used)
  {
    FindInHeapPanel.access$002(this$0, used);
    FindInHeapPanel.access$102(this$0, 0L);
    FindInHeapPanel.access$202(this$0, 0.0D);
    error = false;
    FindInHeapPanel.access$302(this$0, new ArrayList());
  }
  
  public void visitAddress(Address addr)
  {
    if (error) {
      return;
    }
    Address val = addr.getAddressAt(0L);
    if (AddressOps.equal(val, FindInHeapPanel.access$400(this$0))) {
      error = FindInHeapPanel.access$500(this$0, addr);
    }
    FindInHeapPanel.access$114(this$0, FindInHeapPanel.access$600(this$0));
    FindInHeapPanel.access$700(this$0);
  }
  
  public void visitCompOopAddress(Address addr)
  {
    if (error) {
      return;
    }
    Address val = addr.getCompOopAddressAt(0L);
    if (AddressOps.equal(val, FindInHeapPanel.access$400(this$0))) {
      error = FindInHeapPanel.access$500(this$0, addr);
    }
    FindInHeapPanel.access$114(this$0, FindInHeapPanel.access$600(this$0));
    FindInHeapPanel.access$700(this$0);
  }
  
  public void epilogue()
  {
    FindInHeapPanel.access$102(this$0, 0L);
    FindInHeapPanel.access$700(this$0);
    FindInHeapPanel.access$800(this$0).setEnabled(true);
  }
}

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

import javax.swing.JButton;

final class FindInHeapPanel$2$1$1
  implements Runnable
{
  private final FindInHeapPanel.2.1 this$2;
  
  FindInHeapPanel$2$1$1(FindInHeapPanel.2.1 param1) {}
  
  public void run()
  {
    FindInHeapPanel.access$800(FindInHeapPanel.2.access$1100(FindInHeapPanel.2.1.access$1300(this$2))).setEnabled(true);
  }
}

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

import javax.swing.JButton;
import javax.swing.SwingUtilities;
import sun.jvm.hotspot.oops.ObjectHeap;
import sun.jvm.hotspot.runtime.VM;

final class FindInHeapPanel$2$1
  implements Runnable
{
  private final FindInHeapPanel.2 this$1;
  
  FindInHeapPanel$2$1(FindInHeapPanel.2 param2) {}
  
  public void run()
  {
    try
    {
      VM.getVM().getObjectHeap().iterateRaw(FindInHeapPanel.access$1200(FindInHeapPanel.2.access$1100(this$1)));
    }
    finally
    {
      SwingUtilities.invokeLater(new Runnable()
      {
        public void run()
        {
          FindInHeapPanel.access$800(FindInHeapPanel.2.access$1100(this$1)).setEnabled(true);
        }
      });
    }
  }
}

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

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JTextArea;
import javax.swing.SwingUtilities;
import sun.jvm.hotspot.debugger.Address;
import sun.jvm.hotspot.debugger.JVMDebugger;
import sun.jvm.hotspot.oops.ObjectHeap;
import sun.jvm.hotspot.runtime.VM;

final class FindInHeapPanel$2
  implements ActionListener
{
  private final FindInHeapPanel this$0;
  
  FindInHeapPanel$2(FindInHeapPanel paramFindInHeapPanel) {}
  
  public void actionPerformed(ActionEvent e)
  {
    FindInHeapPanel.access$900(this$0);
    try
    {
      Address val = VM.getVM().getDebugger().parseAddress(FindInHeapPanel.access$1000(this$0).getText());
      FindInHeapPanel.access$402(this$0, val);
      
      FindInHeapPanel.access$800(this$0).setEnabled(false);
      
      Thread t = new Thread(new Runnable()
      {
        public void run()
        {
          try
          {
            VM.getVM().getObjectHeap().iterateRaw(FindInHeapPanel.access$1200(this$0));
          }
          finally
          {
            SwingUtilities.invokeLater(new Runnable()
            {
              public void run()
              {
                FindInHeapPanel.access$800(this$0).setEnabled(true);
              }
            });
          }
        }
      });
      t.start();
    }
    catch (Exception ex)
    {
      FindInHeapPanel.access$1400(this$0).setText("Error parsing address");
    }
  }
}

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

final class FindInHeapPanel$3
  implements Runnable
{
  private final FindInHeapPanel this$0;
  
  FindInHeapPanel$3(FindInHeapPanel paramFindInHeapPanel) {}
  
  public void run()
  {
    FindInHeapPanel.access$1500(this$0);
  }
}

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

import javax.swing.JTextArea;
import javax.swing.text.BadLocationException;
import javax.swing.text.Document;

final class FindInHeapPanel$4
  implements Runnable
{
  private final FindInHeapPanel this$0;
  
  FindInHeapPanel$4(FindInHeapPanel paramFindInHeapPanel) {}
  
  public void run()
  {
    Document d = FindInHeapPanel.access$1400(this$0).getDocument();
    try
    {
      d.remove(0, d.getLength());
    }
    catch (BadLocationException e) {}
  }
}

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

final class FindInHeapPanel$5
  implements Runnable
{
  private final FindInHeapPanel this$0;
  
  FindInHeapPanel$5(FindInHeapPanel paramFindInHeapPanel, double paramDouble) {}
  
  public void run()
  {
    FindInHeapPanel.access$1600(this$0).setValue(val$frac);
  }
}

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

import java.awt.BorderLayout;
import java.awt.EventQueue;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Iterator;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.SwingUtilities;
import javax.swing.text.BadLocationException;
import javax.swing.text.Document;
import sun.jvm.hotspot.debugger.Address;
import sun.jvm.hotspot.debugger.JVMDebugger;
import sun.jvm.hotspot.oops.ObjectHeap;
import sun.jvm.hotspot.oops.RawHeapVisitor;
import sun.jvm.hotspot.runtime.VM;
import sun.jvm.hotspot.utilities.AddressOps;

public class FindInHeapPanel
  extends JPanel
{
  private RawHeapVisitor iterator;
  private long addressSize;
  private long usedSize;
  private long iterated;
  private Address value;
  private ProgressBarPanel progressBar;
  private HistoryComboBox addressField;
  private JButton findButton;
  private JTextArea textArea;
  private ArrayList updates;
  private double lastFrac;
  static final double minUpdateFraction = 0.05D;
  
  public FindInHeapPanel()
  {
    setLayout(new BorderLayout());
    
    JPanel topPanel = new JPanel();
    topPanel.setLayout(new BoxLayout(topPanel, 1));
    
    JPanel panel = new JPanel();
    panel.setLayout(new BoxLayout(panel, 0));
    panel.add(new JLabel("Address to search for:"));
    
    addressField = new HistoryComboBox();
    panel.add(addressField);
    
    addressSize = VM.getVM().getAddressSize();
    
    iterator = new RawHeapVisitor()
    {
      boolean error = false;
      
      public void prologue(long used)
      {
        usedSize = used;
        iterated = 0L;
        lastFrac = 0.0D;
        error = false;
        updates = new ArrayList();
      }
      
      public void visitAddress(Address addr)
      {
        if (error) {
          return;
        }
        Address val = addr.getAddressAt(0L);
        if (AddressOps.equal(val, value)) {
          error = FindInHeapPanel.this.reportResult(addr);
        }
        FindInHeapPanel.access$114(FindInHeapPanel.this, addressSize);
        FindInHeapPanel.this.updateProgressBar();
      }
      
      public void visitCompOopAddress(Address addr)
      {
        if (error) {
          return;
        }
        Address val = addr.getCompOopAddressAt(0L);
        if (AddressOps.equal(val, value)) {
          error = FindInHeapPanel.this.reportResult(addr);
        }
        FindInHeapPanel.access$114(FindInHeapPanel.this, addressSize);
        FindInHeapPanel.this.updateProgressBar();
      }
      
      public void epilogue()
      {
        iterated = 0L;
        FindInHeapPanel.this.updateProgressBar();
        findButton.setEnabled(true);
      }
    };
    findButton = new JButton("Find");
    ActionListener listener = new ActionListener()
    {
      public void actionPerformed(ActionEvent e)
      {
        FindInHeapPanel.this.clearResultWindow();
        try
        {
          Address val = VM.getVM().getDebugger().parseAddress(addressField.getText());
          value = val;
          
          findButton.setEnabled(false);
          
          Thread t = new Thread(new Runnable()
          {
            public void run()
            {
              try
              {
                VM.getVM().getObjectHeap().iterateRaw(iterator);
              }
              finally
              {
                SwingUtilities.invokeLater(new Runnable()
                {
                  public void run()
                  {
                    findButton.setEnabled(true);
                  }
                });
              }
            }
          });
          t.start();
        }
        catch (Exception ex)
        {
          textArea.setText("Error parsing address");
        }
      }
    };
    panel.add(findButton);
    findButton.addActionListener(listener);
    addressField.addActionListener(listener);
    topPanel.add(panel);
    
    progressBar = new ProgressBarPanel(1, "Search progress:");
    topPanel.add(progressBar);
    
    add(topPanel, "North");
    
    textArea = new JTextArea();
    JScrollPane scroller = new JScrollPane(textArea);
    add(scroller, "Center");
  }
  
  private boolean pendingUpdate = false;
  
  private boolean reportResult(Address addr)
  {
    synchronized (this)
    {
      try
      {
        updates.add("found at " + addr + "\n");
        if (!pendingUpdate)
        {
          pendingUpdate = true;
          SwingUtilities.invokeLater(new Runnable()
          {
            public void run()
            {
              FindInHeapPanel.this.updateResultWindow();
            }
          });
        }
      }
      catch (Throwable t)
      {
        t.printStackTrace();
        return true;
      }
    }
    return false;
  }
  
  private void clearResultWindow()
  {
    SwingUtilities.invokeLater(new Runnable()
    {
      public void run()
      {
        Document d = textArea.getDocument();
        try
        {
          d.remove(0, d.getLength());
        }
        catch (BadLocationException e) {}
      }
    });
  }
  
  private synchronized void updateResultWindow()
  {
    if (updates.size() > 0)
    {
      Iterator i = updates.iterator();
      while (i.hasNext()) {
        textArea.append((String)i.next());
      }
      updates = new ArrayList();
    }
    pendingUpdate = false;
  }
  
  private void invokeInDispatchThread(Runnable runnable)
  {
    if (EventQueue.isDispatchThread()) {
      runnable.run();
    } else {
      SwingUtilities.invokeLater(runnable);
    }
  }
  
  private void updateProgressBar()
  {
    final double frac = iterated / usedSize;
    if ((frac == 0.0D) || (frac - lastFrac > 0.05D))
    {
      lastFrac = frac;
      if (iterated > usedSize) {
        System.out.println("iterated " + iterated + " usedSize " + usedSize);
      }
      SwingUtilities.invokeLater(new Runnable()
      {
        public void run()
        {
       
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