annotate agent/src/share/classes/sun/jvm/hotspot/bugspot/StackTracePanel.java @ 1913:3b2dea75431e

6984311: JSR 292 needs optional bootstrap method parameters Summary: Allow CONSTANT_InvokeDynamic nodes to have any number of extra operands. Reviewed-by: twisti
author jrose
date Sat, 30 Oct 2010 13:08:23 -0700
parents c18cbe5936b8
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
2 * Copyright (c) 2001, Oracle and/or its affiliates. All rights reserved.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
21 * questions.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
a61af66fc99e Initial load
duke
parents:
diff changeset
25 package sun.jvm.hotspot.bugspot;
a61af66fc99e Initial load
duke
parents:
diff changeset
26
a61af66fc99e Initial load
duke
parents:
diff changeset
27 import java.awt.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
28 import java.awt.event.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
29 import java.util.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
30 import javax.swing.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
31 import sun.jvm.hotspot.debugger.cdbg.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
32 import sun.jvm.hotspot.runtime.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
33 import sun.jvm.hotspot.ui.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
34
a61af66fc99e Initial load
duke
parents:
diff changeset
35 /** This panel contains a ListBox with all of the stack frames in a
a61af66fc99e Initial load
duke
parents:
diff changeset
36 given thread. When a given entry is selected, an event is
a61af66fc99e Initial load
duke
parents:
diff changeset
37 fired. */
a61af66fc99e Initial load
duke
parents:
diff changeset
38
a61af66fc99e Initial load
duke
parents:
diff changeset
39 public class StackTracePanel extends JPanel {
a61af66fc99e Initial load
duke
parents:
diff changeset
40 public interface Listener {
a61af66fc99e Initial load
duke
parents:
diff changeset
41 public void frameChanged(CFrame fr, JavaVFrame jfr);
a61af66fc99e Initial load
duke
parents:
diff changeset
42 }
a61af66fc99e Initial load
duke
parents:
diff changeset
43
a61af66fc99e Initial load
duke
parents:
diff changeset
44 class Model extends AbstractListModel implements ComboBoxModel {
a61af66fc99e Initial load
duke
parents:
diff changeset
45 private Object selectedItem;
a61af66fc99e Initial load
duke
parents:
diff changeset
46 public Object getElementAt(int index) {
a61af66fc99e Initial load
duke
parents:
diff changeset
47 if (trace == null) return null;
a61af66fc99e Initial load
duke
parents:
diff changeset
48 return trace.get(index);
a61af66fc99e Initial load
duke
parents:
diff changeset
49 }
a61af66fc99e Initial load
duke
parents:
diff changeset
50 public int getSize() {
a61af66fc99e Initial load
duke
parents:
diff changeset
51 if (trace == null) return 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
52 return trace.size();
a61af66fc99e Initial load
duke
parents:
diff changeset
53 }
a61af66fc99e Initial load
duke
parents:
diff changeset
54 public Object getSelectedItem() {
a61af66fc99e Initial load
duke
parents:
diff changeset
55 return selectedItem;
a61af66fc99e Initial load
duke
parents:
diff changeset
56 }
a61af66fc99e Initial load
duke
parents:
diff changeset
57 public void setSelectedItem(Object item) {
a61af66fc99e Initial load
duke
parents:
diff changeset
58 selectedItem = item;
a61af66fc99e Initial load
duke
parents:
diff changeset
59 }
a61af66fc99e Initial load
duke
parents:
diff changeset
60 public void dataChanged() {
a61af66fc99e Initial load
duke
parents:
diff changeset
61 fireContentsChanged(this, 0, trace.size());
a61af66fc99e Initial load
duke
parents:
diff changeset
62 }
a61af66fc99e Initial load
duke
parents:
diff changeset
63 }
a61af66fc99e Initial load
duke
parents:
diff changeset
64
a61af66fc99e Initial load
duke
parents:
diff changeset
65 private java.util.List trace;
a61af66fc99e Initial load
duke
parents:
diff changeset
66 private Model model;
a61af66fc99e Initial load
duke
parents:
diff changeset
67 private JComboBox list;
a61af66fc99e Initial load
duke
parents:
diff changeset
68 private java.util.List listeners;
a61af66fc99e Initial load
duke
parents:
diff changeset
69
a61af66fc99e Initial load
duke
parents:
diff changeset
70 public StackTracePanel() {
a61af66fc99e Initial load
duke
parents:
diff changeset
71 super();
a61af66fc99e Initial load
duke
parents:
diff changeset
72
a61af66fc99e Initial load
duke
parents:
diff changeset
73 model = new Model();
a61af66fc99e Initial load
duke
parents:
diff changeset
74
a61af66fc99e Initial load
duke
parents:
diff changeset
75 // Build user interface
a61af66fc99e Initial load
duke
parents:
diff changeset
76 setLayout(new BorderLayout());
a61af66fc99e Initial load
duke
parents:
diff changeset
77 setBorder(GraphicsUtilities.newBorder(5));
a61af66fc99e Initial load
duke
parents:
diff changeset
78 list = new JComboBox(model);
a61af66fc99e Initial load
duke
parents:
diff changeset
79 list.setPrototypeDisplayValue("ZZZZZZZZZZZZZZZZZZZZZZZZZZZZ");
a61af66fc99e Initial load
duke
parents:
diff changeset
80 add(list, BorderLayout.CENTER);
a61af66fc99e Initial load
duke
parents:
diff changeset
81
a61af66fc99e Initial load
duke
parents:
diff changeset
82 // Add selection listener
a61af66fc99e Initial load
duke
parents:
diff changeset
83 list.addItemListener(new ItemListener() {
a61af66fc99e Initial load
duke
parents:
diff changeset
84 public void itemStateChanged(ItemEvent e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
85 if (e.getStateChange() == ItemEvent.SELECTED) {
a61af66fc99e Initial load
duke
parents:
diff changeset
86 fireFrameChanged();
a61af66fc99e Initial load
duke
parents:
diff changeset
87 }
a61af66fc99e Initial load
duke
parents:
diff changeset
88 }
a61af66fc99e Initial load
duke
parents:
diff changeset
89 });
a61af66fc99e Initial load
duke
parents:
diff changeset
90 }
a61af66fc99e Initial load
duke
parents:
diff changeset
91
a61af66fc99e Initial load
duke
parents:
diff changeset
92 /** Takes a List of StackTraceEntry objects */
a61af66fc99e Initial load
duke
parents:
diff changeset
93 public void setTrace(java.util.List trace) {
a61af66fc99e Initial load
duke
parents:
diff changeset
94 this.trace = trace;
a61af66fc99e Initial load
duke
parents:
diff changeset
95 model.dataChanged();
a61af66fc99e Initial load
duke
parents:
diff changeset
96 list.setSelectedIndex(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
97 fireFrameChanged();
a61af66fc99e Initial load
duke
parents:
diff changeset
98 }
a61af66fc99e Initial load
duke
parents:
diff changeset
99
a61af66fc99e Initial load
duke
parents:
diff changeset
100 public void addListener(Listener listener) {
a61af66fc99e Initial load
duke
parents:
diff changeset
101 if (listeners == null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
102 listeners = new ArrayList();
a61af66fc99e Initial load
duke
parents:
diff changeset
103 }
a61af66fc99e Initial load
duke
parents:
diff changeset
104 listeners.add(listener);
a61af66fc99e Initial load
duke
parents:
diff changeset
105 }
a61af66fc99e Initial load
duke
parents:
diff changeset
106
a61af66fc99e Initial load
duke
parents:
diff changeset
107 protected void fireFrameChanged() {
a61af66fc99e Initial load
duke
parents:
diff changeset
108 if (listeners != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
109 StackTraceEntry entry = (StackTraceEntry) trace.get(list.getSelectedIndex());
a61af66fc99e Initial load
duke
parents:
diff changeset
110 for (Iterator iter = listeners.iterator(); iter.hasNext(); ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
111 ((Listener) iter.next()).frameChanged(entry.getCFrame(), entry.getJavaFrame());
a61af66fc99e Initial load
duke
parents:
diff changeset
112 }
a61af66fc99e Initial load
duke
parents:
diff changeset
113 }
a61af66fc99e Initial load
duke
parents:
diff changeset
114 }
a61af66fc99e Initial load
duke
parents:
diff changeset
115 }