sa-jdi

ressField = new HistoryComboBox();
    hbox.add(addressField);
    statusLabel = new JLabel();
    hbox.add(statusLabel);
    
    Box hboxDown = Box.createHorizontalBox();
    hboxDown.add(Box.createGlue());
    
    livenessButton = new JButton("Compute Liveness");
    livenessButtonListener = new ActionListener()
    {
      public void actionPerformed(ActionEvent e)
      {
        if (currentOop != null) {
          Inspector.this.fireComputeLiveness();
        }
      }
    };
    showLivenessListener = new ActionListener()
    {
      public void actionPerformed(ActionEvent e)
      {
        Inspector.this.fireShowLiveness();
      }
    };
    livenessButton.addActionListener(livenessButtonListener);
    hboxDown.add(livenessButton);
    hboxDown.add(Box.createGlue());
    
    liveStatus = new JLabel();
    hboxDown.add(liveStatus);
    hboxDown.add(Box.createGlue());
    
    add(hbox, "North");
    add(hboxDown, "South");
    
    addressField.addActionListener(new ActionListener()
    {
      public void actionPerformed(ActionEvent e)
      {
        String text = addressField.getText();
        try
        {
          Address a = VM.getVM().getDebugger().parseAddress(text);
          int max_searches = 1000;
          int searches = 0;
          int offset = 0;
          Oop oop = null;
          if (a != null)
          {
            OopHandle handle = a.addOffsetToAsOopHandle(0L);
            while (searches < max_searches)
            {
              searches++;
              if (RobustOopDeterminator.oopLooksValid(handle)) {
                try
                {
                  oop = VM.getVM().getObjectHeap().newOop(handle);
                  addressField.setText(handle.toString());
                }
                catch (UnknownOopException ex) {}catch (RuntimeException ex)
                {
                  ex.printStackTrace();
                }
              }
              offset -= 4;
              handle = a.addOffsetToAsOopHandle(offset);
            }
          }
          if (oop != currentOop)
          {
            currentOop = oop;
            liveStatus.setText("");
            list = null;
            if (livenessButton.getText().equals("Show Liveness"))
            {
              livenessButton.setText("Compute Liveness");
              livenessButton.removeActionListener(showLivenessListener);
              livenessButton.addActionListener(livenessButtonListener);
            }
          }
          if (oop != null)
          {
            statusLabel.setText("");
            Inspector.this.setRoot(new OopTreeNodeAdapter(oop, null));
            return;
          }
          Type t = VM.getVM().getTypeDataBase().guessTypeForAddress(a);
          if (t != null)
          {
            statusLabel.setText("");
            Inspector.this.setRoot(new CTypeTreeNodeAdapter(a, t, null));
            return;
          }
          statusLabel.setText("<bad oop or unknown C++ object " + text + ">");
        }
        catch (NumberFormatException ex)
        {
          currentOop = null;
          liveStatus.setText("");
          list = null;
          if (livenessButton.getText().equals("Show Liveness"))
          {
            livenessButton.setText("Compute Liveness");
            livenessButton.removeActionListener(showLivenessListener);
            livenessButton.addActionListener(livenessButtonListener);
          }
          CPPExpressions.CastExpr cast = CPPExpressions.parseCast(text);
          if (cast != null)
          {
            TypeDataBase db = VM.getVM().getTypeDataBase();
            Type t = db.lookupType(cast.getType());
            if (t == null) {
              statusLabel.setText("<unknown C++ type \"" + cast.getType() + "\">");
            } else {
              try
              {
                Address a = VM.getVM().getDebugger().parseAddress(cast.getAddress());
                statusLabel.setText("");
                Inspector.this.setRoot(new CTypeTreeNodeAdapter(a, t, null));
              }
              catch (NumberFormatException ex2)
              {
                statusLabel.setText("<bad address " + cast.getAddress() + ">");
              }
            }
            return;
          }
          CPPExpressions.StaticFieldExpr stat = CPPExpressions.parseStaticField(text);
          if (stat != null)
          {
            TypeDataBase db = VM.getVM().getTypeDataBase();
            Type t = db.lookupType(stat.getContainingType());
            if (t == null)
            {
              statusLabel.setText("<unknown C++ type \"" + stat.getContainingType() + "\">");
            }
            else
            {
              Field f = t.getField(stat.getFieldName(), true, false);
              if (f == null)
              {
                statusLabel.setText("<unknown field \"" + stat.getFieldName() + "\" in type \"" + stat.getContainingType() + "\">");
              }
              else if (!f.isStatic())
              {
                statusLabel.setText("<field \"" + stat.getContainingType() + "::" + stat.getFieldName() + "\" was not static>");
              }
              else
              {
                Type fieldType = f.getType();
                if (fieldType.isPointerType())
                {
                  fieldType = ((PointerType)fieldType).getTargetType();
                  
                  Type typeGuess = db.guessTypeForAddress(f.getAddress());
                  if (typeGuess != null) {
                    fieldType = typeGuess;
                  }
                  statusLabel.setText("");
                  Inspector.this.setRoot(new CTypeTreeNodeAdapter(f.getAddress(), fieldType, new NamedFieldIdentifier(text)));
                }
                else
                {
                  statusLabel.setText("");
                  Inspector.this.setRoot(new CTypeTreeNodeAdapter(f.getStaticFieldAddress(), f.getType(), new NamedFieldIdentifier(text)));
                }
              }
            }
            return;
          }
          statusLabel.setText("<parse error>");
        }
        catch (AddressException ex)
        {
          ex.printStackTrace();
          currentOop = null;
          liveStatus.setText("");
          list = null;
          if (livenessButton.getText().equals("Show Liveness"))
          {
            livenessButton.setText("Compute Liveness");
            livenessButton.removeActionListener(showLivenessListener);
            livenessButton.addActionListener(livenessButtonListener);
          }
          statusLabel.setText("<bad address>");
        }
        catch (Exception ex)
        {
          ex.printStackTrace();
          currentOop = null;
          liveStatus.setText("");
          list = null;
          if (livenessButton.getText().equals("Show Liveness"))
          {
            livenessButton.setText("Compute Liveness");
            livenessButton.removeActionListener(showLivenessListener);
            livenessButton.addActionListener(livenessButtonListener);
          }
          statusLabel.setText("<error constructing oop>");
        }
      }
    });
    MouseListener ml = new MouseAdapter()
    {
      public void mousePressed(MouseEvent e)
      {
        int selRow = tree.getRowForLocation(e.getX(), e.getY());
        TreePath selPath = tree.getPathForLocation(e.getX(), e.getY());
        if ((selRow != -1) && 
          (e.getClickCount() == 1) && ((e.getModifiersEx() & 0x40) != 0))
        {
          Object node = tree.getLastSelectedPathComponent();
          if ((node != null) && ((node instanceof SimpleTreeNode))) {
            showInspector((SimpleTreeNode)node);
          }
        }
      }
    };
    tree.addMouseListener(ml);
    
    JScrollPane scrollPane = new JScrollPane(tree);
    
    add(scrollPane, "Center");
  }
  
  public Inspector(final SimpleTreeNode root)
  {
    this();
    SwingUtilities.invokeLater(new Runnable()
    {
      public void run()
      {
        if ((root instanceof OopTreeNodeAdapter))
        {
          Oop oop = ((OopTreeNodeAdapter)root).getOop();
          addressField.setText(oop.getHandle().toString());
        }
        Inspector.this.setRoot(root);
      }
    });
  }
  
  private void setRoot(SimpleTreeNode root)
  {
    model.setRoot(root);
  }
  
  private void fireComputeLiveness()
  {
    final Runnable cutoverButtonRunnable = new Runnable()
    {
      public void run()
      {
        list = LivenessAnalysis.computeAllLivenessPaths(currentOop);
        if (list == null)
        {
          liveStatus.setText("Oop is Dead");
        }
        else
        {
          liveStatus.setText("Oop is Alive");
          livenessButton.removeActionListener(livenessButtonListener);
          livenessButton.addActionListener(showLivenessListener);
          
          livenessButton.setEnabled(true);
          livenessButton.setText("Show Liveness");
        }
      }
    };
    if (VM.getVM().getRevPtrs() != null)
    {
      cutoverButtonRunnable.run();
    }
    else
    {
      final WorkerThread worker = new WorkerThread();
      worker.invokeLater(new Runnable()
      {
        public void run()
        {
          try
          {
            ReversePtrsAnalysis rev = new ReversePtrsAnalysis();
            rev.run();
            cutoverButtonRunnable.run();
          }
          finally
          {
            worker.shutdown();
          }
        }
      });
    }
  }
  
  private void fireShowLiveness()
  {
    if (list == null) {
      return;
    }
    for (Iterator iter = listeners.iterator(); iter.hasNext();)
    {
      SAListener listener = (SAListener)iter.next();
      listener.showLiveness(currentOop, list);
    }
  }
}

/* Location:
 * Qualified Name:     sun.jvm.hotspot.ui.Inspector
 * 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.ui.classbrowser.HTMLGenerator;

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

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

import java.awt.BorderLayout;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JSplitPane;
import javax.swing.event.HyperlinkEvent;
import javax.swing.event.HyperlinkEvent.EventType;
import javax.swing.event.HyperlinkListener;
import sun.jvm.hotspot.runtime.JavaThread;
import sun.jvm.hotspot.ui.classbrowser.HTMLGenerator;

public class JavaStackTracePanel
  extends JPanel
{
  private JSplitPane splitPane;
  private SAEditorPane stackTraceEditor;
  private SAEditorPane contentEditor;
  private HTMLGenerator htmlGen = new HTMLGenerator();
  
  public JavaStackTracePanel()
  {
    initUI();
  }
  
  private void initUI()
  {
    setLayout(new BorderLayout());
    HyperlinkListener hyperListener = new HyperlinkListener()
    {
      public void hyperlinkUpdate(HyperlinkEvent e)
      {
        if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
          JavaStackTracePanel.this.setContentText(htmlGen.genHTMLForHyperlink(e.getDescription()));
        }
      }
    };
    stackTraceEditor = new SAEditorPane();
    stackTraceEditor.addHyperlinkListener(hyperListener);
    
    contentEditor = new SAEditorPane();
    contentEditor.addHyperlinkListener(hyperListener);
    
    JPanel topPanel = new JPanel();
    topPanel.setLayout(new BorderLayout());
    topPanel.add(new JScrollPane(stackTraceEditor), "Center");
    
    JPanel bottomPanel = new JPanel();
    bottomPanel.setLayout(new BorderLayout());
    bottomPanel.add(new JScrollPane(contentEditor), "Center");
    
    splitPane = new JSplitPane(0, topPanel, bottomPanel);
    splitPane.setDividerLocation(0.4D);
    
    setLayout(new BorderLayout());
    add(splitPane, "Center");
  }
  
  public void setJavaThread(JavaThread thread)
  {
    setStackTraceText(htmlGen.genHTMLForJavaStackTrace(thread));
  }
  
  private void setStackTraceText(String text)
  {
    stackTraceEditor.setText(text);
  }
  
  private void setContentText(String text)
  {
    contentEditor.setText(text);
  }
}

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

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

final class JavaThreadsPanel$1
  implements Observer
{
  private final JavaThreadsPanel this$0;
  
  JavaThreadsPanel$1(JavaThreadsPanel paramJavaThreadsPanel) {}
  
  public void update(Observable o, Object data)
  {
    JavaThreadsPanel.access$000(this$0);
  }
}

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

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

final class JavaThreadsPanel$2
  implements Observer
{
  private final JavaThreadsPanel this$0;
  
  JavaThreadsPanel$2(JavaThreadsPanel paramJavaThreadsPanel) {}
  
  public void update(Observable o, Object data)
  {
    JavaThreadsPanel.access$100(this$0);
  }
}

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

import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

final class JavaThreadsPanel$3
  extends MouseAdapter
{
  private final JavaThreadsPanel this$0;
  
  JavaThreadsPanel$3(JavaThreadsPanel paramJavaThreadsPanel) {}
  
  public void mouseClicked(MouseEvent evt)
  {
    if (evt.getClickCount() == 2) {
      JavaThreadsPanel.access$200(this$0);
    }
  }
}

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

import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
import sun.jvm.hotspot.runtime.JavaThread;

class JavaThreadsPanel$CachedThread
{
  private JavaThread thread;
  private String threadID;
  private String threadName;
  private boolean computed;
  private final JavaThreadsPanel this$0;
  
  public JavaThreadsPanel$CachedThread(JavaThreadsPanel paramJavaThreadsPanel, JavaThread thread)
  {
    this.thread = thread;
  }
  
  public JavaThread getThread()
  {
    return thread;
  }
  
  public String getThreadID()
  {
    if (!computed) {
      compute();
    }
    return threadID;
  }
  
  public String getThreadName()
  {
    if (!computed) {
      compute();
    }
    return threadName;
  }
  
  private void compute()
  {
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    thread.printThreadIDOn(new PrintStream(bos));
    threadID = bos.toString();
    threadName = thread.getThreadName();
    
    computed = true;
  }
}

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

import javax.swing.table.DefaultTableColumnModel;
import javax.swing.table.TableColumn;

class JavaThreadsPanel$JavaThreadsColumnModel
  extends DefaultTableColumnModel
{
  private String[] columnNames = { "OS Thread ID", "Java Thread Name" };
  private final JavaThreadsPanel this$0;
  
  public JavaThreadsPanel$JavaThreadsColumnModel(JavaThreadsPanel arg1)
  {
    int PREF_WIDTH = 80;
    int MAX_WIDTH = 100;
    int HUGE_WIDTH = 140;
    
    TableColumn column = new TableColumn(0, MAX_WIDTH);
    column.setHeaderValue(columnNames[0]);
    column.setMaxWidth(MAX_WIDTH);
    column.setResizable(false);
    addColumn(column);
    
    column = new TableColumn(1, HUGE_WIDTH);
    column.setHeaderValue(columnNames[1]);
    column.setResizable(false);
    addColumn(column);
  }
}

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

import java.util.List;
import javax.swing.table.AbstractTableModel;
import sun.jvm.hotspot.debugger.AddressException;
import sun.jvm.hotspot.runtime.JavaThread;

class JavaThreadsPanel$JavaThreadsTableModel
  extends AbstractTableModel
{
  private String[] columnNames = { "OS Thread ID", "Java Thread Name" };
  private List elements;
  private final JavaThreadsPanel this$0;
  
  public JavaThreadsPanel$JavaThreadsTableModel(JavaThreadsPanel paramJavaThreadsPanel, List threads)
  {
    elements = threads;
  }
  
  public int getColumnCount()
  {
    return columnNames.length;
  }
  
  public int getRowCount()
  {
    return elements.size();
  }
  
  public String getColumnName(int col)
  {
    return columnNames[col];
  }
  
  public Object getValueAt(int row, int col)
  {
    JavaThreadsPanel.CachedThread thread = getRow(row);
    switch (col)
    {
    case 0: 
      return thread.getThreadID();
    case 1: 
      return thread.getThreadName();
    }
    throw new RuntimeException("Index (" + col + ", " + row + ") out of bounds");
  }
  
  public JavaThread getJavaThread(int index)
  {
    return getRow(index).getThread();
  }
  
  private JavaThreadsPanel.CachedThread getRow(int row)
  {
    return (JavaThreadsPanel.CachedThread)elements.get(row);
  }
  
  private String threadIDAt(int index)
  {
    return ((JavaThreadsPanel.CachedThread)JavaThreadsPanel.access$900(this$0).get(index)).getThreadID();
  }
  
  private String threadNameAt(int index)
  {
    try
    {
      return ((JavaThreadsPanel.CachedThread)JavaThreadsPanel.access$900(this$0).get(index)).getThreadName();
    }
    catch (AddressException e)
    {
      return "<Error: AddressException>";
    }
    catch (NullPointerException e) {}
    return "<Error: NullPointerException>";
  }
}

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

import com.sun.java.swing.action.ActionManager;
import com.sun.java.swing.ui.CommonToolBar;
import com.sun.java.swing.ui.StatusBar;
import sun.jvm.hotspot.ui.action.HSDBActionManager;

class JavaThreadsPanel$JavaThreadsToolBar
  extends CommonToolBar
{
  private final JavaThreadsPanel this$0;
  
  public JavaThreadsPanel$JavaThreadsToolBar(JavaThreadsPanel paramJavaThreadsPanel, StatusBar status)
  {
    super(HSDBActionManager.getInstance(), status);
  }
  
  protected void addComponents()
  {
    addButton(manager.getAction("inspect-command"));
    addButton(manager.getAction("memory-command"));
    addButton(manager.getAction("jstack-command"));
    
    addToggleButton(manager.getStateChangeAction("thread-info-command"));
    addButton(manager.getAction("find-crashes-command"));
  }
}

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

import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;

final class JavaThreadsPanel$ThreadPanel$1
  implements ItemListener
{
  private final JavaThreadsPanel.ThreadPanel this$1;
  
  JavaThreadsPanel$ThreadPanel$1(JavaThreadsPanel.ThreadPanel paramThreadPanel, JavaThreadsPanel paramJavaThreadsPanel) {}
  
  public void itemStateChanged(ItemEvent evt)
  {
    if (evt.getStateChange() == 1) {
      JavaThreadsPanel.ThreadPanel.access$300(this$1);
    } else {
      JavaThreadsPanel.ThreadPanel.access$400(this$1);
    }
  }
}

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

import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;

final class JavaThreadsPanel$ThreadPanel$2
  implements ListSelectionListener
{
  private final JavaThreadsPanel.ThreadPanel this$1;
  
  JavaThreadsPanel$ThreadPanel$2(JavaThreadsPanel.ThreadPanel paramThreadPanel, JavaThreadsPanel paramJavaThreadsPanel) {}
  
  public void valueChanged(ListSelectionEvent evt)
  {
    if (!evt.getValueIsAdjusting())
    {
      JavaThreadsPanel.ThreadPanel.access$500(this$1, true);
      if (JavaThreadsPanel.ThreadPanel.access$600(this$1)) {
        JavaThreadsPanel.ThreadPanel.access$700(this$1);
      }
    }
  }
}

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

import com.sun.java.swing.action.ActionManager;
import java.awt.Dimension;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import javax.swing.JPanel;
import javax.swing.JSplitPane;
import javax.swing.JTable;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;

class JavaThreadsPanel$ThreadPanel
  extends JPanel
{
  private JSplitPane splitPane;
  private JTable threadTable;
  private ThreadInfoPanel threadInfo;
  private int dividerSize;
  private int dividerLocation;
  private boolean actionsEnabled;
  private final JavaThreadsPanel this$0;
  
  /* Error */
  public JavaThreadsPanel$ThreadPanel(JavaThreadsPanel arg1, JTable table)
  {
    // Byte code:
    //   0: aload_0
    //   1: aload_1
    //   2: putfield 6	sun/jvm/hotspot/ui/JavaThreadsPanel$ThreadPanel:this$0	Lsun/jvm/hotspot/ui/JavaThreadsPanel;
    //   5: aload_0
    //   6: invokespecial 7	javax/swing/JPanel:<init>	()V
    //   9: aload_0
    //   10: iconst_m1
    //   11: putfield 8	sun/jvm/hotspot/ui/JavaThreadsPanel$ThreadPanel:dividerLocation	I
    //   14: aload_0
    //   15: iconst_0
    //   16: putfield 9	sun/jvm/hotspot/ui/JavaThreadsPanel$ThreadPanel:actionsEnabled	Z
    //   19: aload_0
    //   20: new 10	java/awt/BorderLayout
    //   23: dup
    //   24: invokespecial 11	java/awt/BorderLayout:<init>	()V
    //   27: invokevirtual 12	sun/jvm/hotspot/ui/JavaThreadsPanel$ThreadPanel:setLayout	(Ljava/awt/LayoutManager;)V
    //   30: aload_0
    //   31: new 13	sun/jvm/hotspot/ui/ThreadInfoPanel
    //   34: dup
    //   35: invokespecial 14	sun/jvm/hotspot/ui/ThreadInfoPanel:<init>	()V
    //   38: putfield 15	sun/jvm/hotspot/ui/JavaThreadsPanel$ThreadPanel:threadInfo	Lsun/jvm/hotspot/ui/ThreadInfoPanel;
    //   41: aload_0
    //   42: aload_2
    //   43: putfield 16	sun/jvm/hotspot/ui/JavaThreadsPanel$ThreadPanel:threadTable	Ljavax/swing/JTable;
    //   46: aload_0
    //   47: new 17	javax/swing/JSplitPane
    //   50: dup
    //   51: iconst_0
    //   52: invokespecial 18	javax/swing/JSplitPane:<init>	(I)V
    //   55: putfield 19	sun/jvm/hotspot/ui/JavaThreadsPanel$ThreadPanel:splitPane	Ljavax/swing/JSplitPane;
    //   58: aload_0
    //   59: getfield 19	sun/jvm/hotspot/ui/JavaThreadsPanel$ThreadPanel:splitPane	Ljavax/swing/JSplitPane;
    //   62: iconst_1
    //   63: invokevirtual 20	javax/swing/JSplitPane:setOneTouchExpandable	(Z)V
    //   66: aload_0
    //   67: getfield 19	sun/jvm/hotspot/ui/JavaThreadsPanel$ThreadPanel:splitPane	Ljavax/swing/JSplitPane;
    //   70: new 21	javax/swing/JScrollPane
    //   73: dup
    //   74: aload_2
    //   75: invokespecial 22	javax/swing/JScrollPane:<init>	(Ljava/awt/Component;)V
    //   78: invokevirtual 23	javax/swing/JSplitPane:setTopComponent	(Ljava/awt/Component;)V
    //   81: aload_0
    //   82: aload_0
    //   83: getfield 19	sun/jvm/hotspot/ui/JavaThreadsPanel$ThreadPanel:splitPane	Ljavax/swing/JSplitPane;
    //   86: invokevirtual 24	javax/swing/JSplitPane:getDividerSize	()I
    //   89: putfield 25	sun/jvm/hotspot/ui/JavaThreadsPanel$ThreadPanel:dividerSize	I
    //   92: aload_0
    //   93: getfield 19	sun/jvm/hotspot/ui/JavaThreadsPanel$ThreadPanel:splitPane	Ljavax/swing/JSplitPane;
    //   96: iconst_0
    //   97: invokevirtual 26	javax/swing/JSplitPane:setDividerSize	(I)V
    //   100: aload_0
    //   101: aload_0
    //   102: getfield 19	sun/jvm/hotspot/ui/JavaThreadsPanel$ThreadPanel:splitPane	Ljavax/swing/JSplitPane;
    //   105: ldc 27
    //   107: invokevirtual 28	sun/jvm/hotspot/ui/JavaThreadsPanel$ThreadPanel:add	(Ljava/awt/Component;Ljava/lang/Object;)V
    //   110: invokestatic 29	sun/jvm/hotspot/ui/action/HSDBActionManager:getInstance	()Lcom/sun/java/swing/action/ActionManager;
    //   113: astore_3
    //   114: aload_3
    //   115: ldc 30
    //   117: invokevirtual 31	com/sun/java/swing/action/ActionManager:getStateChangeAction	(Ljava/lang/String;)Lcom/sun/java/swing/action/StateChangeAction;
    //   120: astore 4
    //   122: aload 4
    //   124: ifnull +17 -> 141
    //   127: aload 4
    //   129: new 32	sun/jvm/hotspot/ui/JavaThreadsPanel$ThreadPanel$1
    //   132: dup
    //   133: aload_0
    //   134: aload_1
    //   135: invokespecial 33	sun/jvm/hotspot/ui/JavaThreadsPanel$ThreadPanel$1:<init>	(Lsun/jvm/hotspot/ui/JavaThreadsPanel$ThreadPanel;Lsun/jvm/hotspot/ui/JavaThreadsPanel;)V
    //   138: invokevirtual 34	com/sun/java/swing/action/StateChangeAction:setItemListener	(Ljava/awt/event/ItemListener;)V
    //   141: aload_2
    //   142: invokevirtual 35	javax/swing/JTable:getSelectionModel	()Ljavax/swing/ListSelectionModel;
    //   145: astore 5
    //   147: aload 5
    //   149: new 36	sun/jvm/hotspot/ui/JavaThreadsPanel$ThreadPanel$2
    //   152: dup
    //   153: aload_0
    //   154: aload_1
    //   155: invokespecial 37	sun/jvm/hotspot/ui/JavaThreadsPanel$ThreadPanel$2:<init>	(Lsun/jvm/hotspot/ui/JavaThreadsPanel$ThreadPanel;Lsun/jvm/hotspot/ui/JavaThreadsPanel;)V
    //   158: invokeinterface 38 2 0
    //   163: return
    // Line number table:
    //   Java source line #116	-> byte code offset #0
    //   Java source line #113	-> byte code offset #9
    //   Java source line #114	-> byte code offset #14
    //   Java source line #117	-> byte code offset #19
    //   Java source line #118	-> byte code offset #30
    //   Java source line #119	-> byte code offset #41
    //   Java source line #121	-> byte code offset #46
    //   Java source line #122	-> byte code offset #58
    //   Java source line #123	-> byte code offset #66
    //   Java source line #126	-> byte code offset #81
    //   Java source line #127	-> byte code offset #92
    //   Java source line #129	-> byte code offset #100
    //   Java source line #133	-> byte code offset #110
    //   Java source line #134	-> byte code offset #114
    //   Java source line #135	-> byte code offset #122
    //   Java source line #136	-> byte code offset #127
    //   Java source line #149	-> byte code offset #141
    //   Java source line #150	-> byte code offset #147
    //   Java source line #160	-> byte code offset #163
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	164	0	this	ThreadPanel
    //   1	154	1	???	JavaThreadsPanel
    //   0	164	2	table	JTable
    //   113	51	3	manager	ActionManager
    //   120	8	4	action	com.sun.java.swing.action.StateChangeAction
    //   145	3	5	selModel	javax.swing.ListSelectionModel
  }
  
  private boolean isInfoVisible()
  {
    return splitPane.getBottomComponent() != null;
  }
  
  private void showOutputPane()
  {
    if (splitPane.getBottomComponent() == null)
    {
      splitPane.setBottomComponent(threadInfo);
      if (dividerLocation == -1)
      {
        Dimension pSize = getSize();
        dividerLocation = (height / 2);
      }
      splitPane.setDividerSize(dividerSize);
      splitPane.setDividerLocation(dividerLocation);
      showCurrentThreadInfo();
    }
  }
  
  private void hideOutputPane()
  {
    dividerLocation = splitPane.getDividerLocation();
    splitPane.remove(threadInfo);
    splitPane.setDividerSize(0);
  }
  
  private void showCurrentThreadInfo()
  {
    int row = threadTable.getSelectedRow();
    if (row >= 0) {
      threadInfo.setJavaThread(JavaThreadsPanel.access$800(this$0).getJavaThread(row));
    }
  }
  
  private void setActionsEnabled(boolean enabled)
  {
    if (actionsEnabled != enabled)
    {
      ActionManager manager = ActionManager.getInstance();
      manager.setActionEnabled("inspect-command", enabled);
      manager.setActionEnabled("memory-command", enabled);
      manager.setActionEnabled("jstack-command", enabled);
      actionsEnabled = enabled;
    }
  }
}

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

import com.sun.java.swing.action.ActionManager;
import com.sun.java.swing.action.DelegateAction;
import com.sun.java.swing.action.StateChangeAction;
import com.sun.java.swing.ui.CommonToolBar;
import com.sun.java.swing.ui.StatusBar;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Observable;
import java.util.Observer;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JSplitPane;
import javax.swing.JTable;
import javax.swing.ListSelectionModel;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import javax.swing.table.AbstractTableModel;
import javax.swing.table.DefaultTableColumnModel;
import javax.swing.table.TableColumn;
import sun.jvm.hotspot.debugger.AddressException;
import sun.jvm.hotspot.runtime.Frame;
import sun.jvm.hotspot.runtime.JavaThread;
import sun.jvm.hotspot.runtime.RegisterMap;
import sun.jvm.hotspot.runtime.Threads;
import sun.jvm.hotspot.runtime.VM;
import sun.jvm.hotspot.ui.action.HSDBActionManager;

public class JavaThreadsPanel
  extends SAPanel
  implements ActionListener
{
  private JavaThreadsTableModel dataModel;
  private StatusBar statusBar;
  private JTable threadTable;
  private List cachedThreads = new ArrayList();
  
  public JavaThreadsPanel()
  {
    VM.getVM().registerVMResumedObserver(new Observer()
    {
      public void update(Observable o, Object data)
      {
        JavaThreadsPanel.this.decache();
      }
    });
    VM.getVM().registerVMSuspendedObserver(new Observer()
    {
      public void update(Observable o, Object data)
      {
        JavaThreadsPanel.this.cache();
      }
    });
    cache();
    
    setLayout(new BorderLayout());
    
    dataModel = new JavaThreadsTableModel(cachedThreads);
    statusBar = new StatusBar();
    
    threadTable = new JTable(dataModel, new JavaThreadsColumnModel());
    threadTable.setSelectionMode(0);
    threadTable.addMouseListener(new MouseAdapter()
    {
      public void mouseClicked(MouseEvent evt)
      {
        if (evt.getClickCount() == 2) {
          JavaThreadsPanel.this.fireShowThreadOopInspector();
        }
      }
    });
    add(new JavaThreadsToolBar(statusBar), "North");
    add(new ThreadPanel(threadTable), "Center");
    add(statusBar, "South");
    
    registerActions();
  }
  
  private class ThreadPanel
    extends JPanel
  {
    private JSplitPane splitPane;
    private JTable threadTable;
    private ThreadInfoPanel threadInfo;
    private int dividerSize;
    private int dividerLocation = -1;
    private boolean actionsEnabled = false;
    
    public ThreadPanel(JTable table)
    {
      setLayout(new BorderLayout());
      threadInfo = new ThreadInfoPanel();
      threadTable = table;
      
      splitPane = new JSplitPane(0);
      splitPane.setOneTouchExpandable(true);
      splitPane.setTopComponent(new JScrollPane(table));
      
      dividerSize = splitPane.getDividerSize();
      splitPane.setDividerSize(0);
      
      add(splitPane, "Center");
      
      ActionManager manager = HSDBActionManager.getInstance();
      StateChangeAction action = manager.getStateChangeAction("thread-info-command");
      if (action != null) {
        action.setItemListener(new ItemListener()
        {
          public void itemStateChanged(ItemEvent evt)
          {
            if (evt.getStateChange() == 1) {
              JavaThreadsPanel.ThreadPanel.this.showOutputPane();
            } else {
              JavaThreadsPanel.ThreadPanel.this.hideOutputPane();
            }
          }
        });
      }
      ListSelectionModel selModel = table.getSelectionModel();
      selModel.addListSelectionListener(new ListSelectionListener()
      {
        public void valueChanged(ListSelectionEvent evt)
        {
          if (!evt.getValueIsAdjusting())
          {
            JavaThreadsPanel.ThreadPanel.this.setActionsEnabled(true);
            if (JavaThreadsPanel.ThreadPanel.this.isInfoVisible()) {
              JavaThreadsPanel.ThreadPanel.this.showCurrentThreadInfo();
            }
          }
        }
      });
    }
    
    private boolean isInfoVisible()
    {
      return splitPane.getBottomComponent() != null;
    }
    
    private void showOutputPane()
    {
      if (splitPane.getBottomComponent() == null)
      {
        splitPane.setBottomComponent(threadInfo);
        if (dividerLocation == -1)
        {
          Dimension pSize = getSize();
          dividerLocation = (height / 2);
        }
        splitPane.setDividerSize(dividerSize);
        splitPane.setDividerLocation(dividerLocation);
        showCurrentThreadInfo();
      }
    }
    
    private void hideOutputPane()
    {
      dividerLocation = splitPane.getDividerLocation();
      splitPane.remove(threadInfo);
      splitPane.setDividerSize(0);
    }
    
    private void showCurrentThreadInfo()
    {
      int row = threadTable.getSelectedRow();
      if (row >= 0) {
        threadInfo.setJavaThread(dataModel.getJavaThread(row));
      }
    }
    
    private void setActionsEnabled(boolean enabled)
    {
      if (actionsEnabled != enabled)
      {
        ActionManager manager = ActionManager.getInstance();
        manager.setActionEnabled("inspect-command", enabled);
        manager.setActionEnabled("memory-command", enabled);
        manager.setActionEnabled("jstack-command", enabled);
        actionsEnabled = enabled;
      }
    }
  }
  
  private class JavaThreadsToolBar
    extends CommonToolBar
  {
    public JavaThreadsToolBar(StatusBar status)
    {
      super(status);
    }
    
    protected void addComponents()
    {
      addButton(manager.getAction("inspect-command"));
      addButton(manager.getAction("memory-command"));
      addButton(manager.getAction("jstack-command"));
      
      addToggleButton(manager.getStateChangeAction("thread-info-command"));
      addButton(manager.getAction("find-crashes-command"));
    }
  }
  
  private class JavaThreadsColumnModel
    extends DefaultTableColumnModel
  {
    private String[] columnNames = { "OS Thread ID", "Java Thread Name" };
    
    public JavaThreadsColumnModel()
    {
      int PREF_WIDTH = 80;
      int MAX_WIDTH = 100;
      int HUGE_WIDTH = 140;
      
      TableColumn column = new TableColumn(0, MAX_WIDTH);
      column.setHeaderValue(columnNames[0]);
      column.setMaxWidth(MAX_WIDTH);
      column.setResizable(false);
      addColumn(column);
      
      column = new TableColumn(1, HUGE_WIDTH);
      column.setHeaderValue(columnNames[1]);
      column.setResizable(false);
      addColumn(column);
    }
  }
  
  private class JavaThreadsTableModel
    extends AbstractTableModel
  {
    private String[] columnNames = { "OS Thread ID", "Java Thread Name" };
    private List elements;
    
    public JavaThreadsTableModel(List threads)
    {
      elements = threads;
    }
    
    public int getColumnCount()
    {
      return columnNames.length;
    }
    
    public int getRowCount()
    {
      return elements.size();
    }
    
    public String getColumnName(int col)
    {
      return columnNames[col];
    }
    
    public Object getValueAt(int row, int col)
    {
      JavaThreadsPanel.CachedThread thread = getRow(row);
      switch (col)
      {
      case 0: 
        return thread.getThreadID();
      case 1: 
        return thread.getThreadName();
      }
      throw new RuntimeException("Index (" + col + ", " + row + ") out of bounds");
    }
    
    public JavaThread getJavaThread(int index)
    {
      return getRow(index).getThread();
    }
    
    private JavaThreadsPanel.CachedThread getRow(int row)
    {
      return (JavaThreadsPanel.CachedThread)elements.get(row);
    }
    
    private String threadIDAt(int index)
    {
      return ((JavaThreadsPanel.CachedThread)cachedThreads.get(index)).getThreadID();
    }
    
    private String threadNameAt(int index)
    {
      try
      {
        return ((JavaThreadsPanel.CachedThread)cachedThreads.get(index)).getThreadName();
      }
      catch (AddressException e)
      {
        return "<Error: AddressException>";
      }
      catch (NullPointerException e) {}
      return "<Error: NullPointerException>";
    }
  }
  
  public void actionPerformed(ActionEvent evt)
  {
    String command = evt.getActionCommand();
    if (command.equals("inspect-command")) {
      fireShowThreadOopInspector();
    } else if (command.equals("memory-command")) {
      fireShowThreadStackMemory();
    } else if (command.equals("thread-info-command")) {
      fireShowThreadInfo();
    } else if (command.equals("find-crashes-command"))
    {
      if (fireShowThreadCrashes()) {
        statusBar.setMessage("Some thread crashes were encountered");
      } else {
        statusBar.setMessage("No thread crashes encountered");
      }
    }
    else if (command.equals("jstack-command")) {
      fireShowJavaStackTrace();
    }
  }
  
  private class CachedThread
  {
    private JavaThread thread;
    private String threadID;
    private String threadName;
    private boolean computed;
    
    public CachedThread(JavaThread thread)
    {
      this.thread = thread;
    }
    
    public JavaThread getThread()
    {
      return thread;
    }
    
    public String getThreadID()
    {
      if (!computed) {
        compute();
      }
      return threadID;
    }
    
    public String getThreadName()
    {
      if (!computed) {
        compute();
      }
      return threadName;
    }
    
    private void compute()
    {
      ByteArrayOutputStream bos = new ByteArrayOutputStream();
      thread.printThreadIDOn(new PrintStream(bos));
      threadID = bos.toString();
      threadName = thread.getThreadName();
      
      computed = true;
    }
  }
  
  protected void registerActions()
  {
    registerAction("inspect-command");
    registerAction("memory-command");
    registerAction("find-crashes-command");
    registerAction("jstack-command");
    
    ActionManager manager = ActionManager.getInstance();
    manager.setActionEnabled("inspect-command", false);
    manager.setActionEnabled("memory-command", false);
    manager.setActionEnabled("jstack-command", false);
  }
  
  private void registerAction(String actionName)
  {
    ActionManager manager = ActionManager.getInstance();
    DelegateAction action = manager.getDelegateAction(actionName);
    action.addActionListener(this);
  }
  
  private void fireShowThreadOopInspector()
  {
    int i = threadTable.getSelectedRow();
    if (i < 0) {
      return;
    }
    JavaThread t = dataModel.getJavaThread(i);
    showThreadOopInspector(t);
  }
  
  private void fireShowThreadStackMemory()
  {
    int i
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