History

My first initial commit with all of mine experimental changes.

Dmitry Kabak (userdima committed 13 years ago

Commit d37b88d1 parent 3f5b46618352 files · +2598093 −-8690Browse files

Showing the changes to java/pkg/com/sun/tools/example/debug (126 of 18352 files). Show all

Unified · Split

126 files
  1. java/pkg/com/sun/tools/example/debug/bdi/AccessWatchpointSpec.java +58 −0
  2. java/pkg/com/sun/tools/example/debug/bdi/AmbiguousMethodException.java +42 −0
  3. java/pkg/com/sun/tools/example/debug/bdi/BreakpointSpec.java +58 −0
  4. java/pkg/com/sun/tools/example/debug/bdi/ChildSession.java +300 −0
  5. java/pkg/com/sun/tools/example/debug/bdi/EvaluationException.java +31 −0
  6. java/pkg/com/sun/tools/example/debug/bdi/EventRequestSpec.java +159 −0
  7. java/pkg/com/sun/tools/example/debug/bdi/EventRequestSpecList.java +178 −0
  8. java/pkg/com/sun/tools/example/debug/bdi/ExceptionSpec.java +100 −0
  9. java/pkg/com/sun/tools/example/debug/bdi/ExecutionManager.java +815 −0
  10. java/pkg/com/sun/tools/example/debug/bdi/FrameIndexOutOfBoundsException.java +31 −0
  11. java/pkg/com/sun/tools/example/debug/bdi/InputListener.java +30 −0
  12. java/pkg/com/sun/tools/example/debug/bdi/JDIEventSource.java +184 −0
  13. java/pkg/com/sun/tools/example/debug/bdi/LineBreakpointSpec.java +121 −0
  14. java/pkg/com/sun/tools/example/debug/bdi/LineNotFoundException.java +42 −0
  15. java/pkg/com/sun/tools/example/debug/bdi/MalformedMemberNameException.java +39 −0
  16. java/pkg/com/sun/tools/example/debug/bdi/MethodBreakpointSpec.java +337 −0
  17. java/pkg/com/sun/tools/example/debug/bdi/MethodNotFoundException.java +41 −0
  18. java/pkg/com/sun/tools/example/debug/bdi/ModificationWatchpointSpec.java +59 −0
  19. java/pkg/com/sun/tools/example/debug/bdi/NoSessionException.java +31 −0
  20. java/pkg/com/sun/tools/example/debug/bdi/NoThreadException.java +32 −0
  21. java/pkg/com/sun/tools/example/debug/bdi/OutputListener.java +31 −0
  22. java/pkg/com/sun/tools/example/debug/bdi/ParseException.java +30 −0
  23. java/pkg/com/sun/tools/example/debug/bdi/PatternReferenceTypeSpec.java +99 −0
  24. java/pkg/com/sun/tools/example/debug/bdi/ReferenceTypeSpec.java +41 −0
  25. java/pkg/com/sun/tools/example/debug/bdi/Session.java +96 −0
  26. java/pkg/com/sun/tools/example/debug/bdi/SessionListener.java +37 −0
  27. java/pkg/com/sun/tools/example/debug/bdi/SourceNameReferenceTypeSpec.java +81 −0
  28. java/pkg/com/sun/tools/example/debug/bdi/SpecErrorEvent.java +42 −0
  29. java/pkg/com/sun/tools/example/debug/bdi/SpecEvent.java +49 −0
  30. java/pkg/com/sun/tools/example/debug/bdi/SpecListener.java +49 −0
  31. java/pkg/com/sun/tools/example/debug/bdi/ThreadGroupIterator.java +108 −0
  32. java/pkg/com/sun/tools/example/debug/bdi/ThreadInfo.java +117 −0
  33. java/pkg/com/sun/tools/example/debug/bdi/ThreadIterator.java +70 −0
  34. java/pkg/com/sun/tools/example/debug/bdi/Utils.java +181 −0
  35. java/pkg/com/sun/tools/example/debug/bdi/VMLaunchFailureException.java +31 −0
  36. java/pkg/com/sun/tools/example/debug/bdi/VMNotInterruptedException.java +31 −0
  37. java/pkg/com/sun/tools/example/debug/bdi/WatchpointSpec.java +92 −0
  38. java/pkg/com/sun/tools/example/debug/bdi/mkfile +44 −0
  39. java/pkg/com/sun/tools/example/debug/event/AbstractEventSet.java +263 −0
  40. java/pkg/com/sun/tools/example/debug/event/AccessWatchpointEventSet.java +42 −0
  41. java/pkg/com/sun/tools/example/debug/event/ClassPrepareEventSet.java +64 −0
  42. java/pkg/com/sun/tools/example/debug/event/ClassUnloadEventSet.java +56 −0
  43. java/pkg/com/sun/tools/example/debug/event/ExceptionEventSet.java +84 −0
  44. java/pkg/com/sun/tools/example/debug/event/JDIAdapter.java +80 −0
  45. java/pkg/com/sun/tools/example/debug/event/JDIListener.java +42 −0
  46. java/pkg/com/sun/tools/example/debug/event/LocatableEventSet.java +62 −0
  47. java/pkg/com/sun/tools/example/debug/event/LocationTriggerEventSet.java +42 −0
  48. java/pkg/com/sun/tools/example/debug/event/ModificationWatchpointEventSet.java +51 −0
  49. java/pkg/com/sun/tools/example/debug/event/ThreadDeathEventSet.java +53 −0
  50. java/pkg/com/sun/tools/example/debug/event/ThreadStartEventSet.java +53 −0
  51. java/pkg/com/sun/tools/example/debug/event/VMDeathEventSet.java +42 −0
  52. java/pkg/com/sun/tools/example/debug/event/VMDisconnectEventSet.java +42 −0
  53. java/pkg/com/sun/tools/example/debug/event/VMStartEventSet.java +53 −0
  54. java/pkg/com/sun/tools/example/debug/event/WatchpointEventSet.java +66 −0
  55. java/pkg/com/sun/tools/example/debug/event/mkfile +23 −0
  56. java/pkg/com/sun/tools/example/debug/expr/ASCII_UCodeESC_CharStream.java +524 −0
  57. java/pkg/com/sun/tools/example/debug/expr/Expr.jj +724 −0
  58. java/pkg/com/sun/tools/example/debug/expr/ExpressionParser.java +3933 −0
  59. java/pkg/com/sun/tools/example/debug/expr/ExpressionParserConstants.java +264 −0
  60. java/pkg/com/sun/tools/example/debug/expr/ExpressionParserTokenManager.java +1757 −0
  61. java/pkg/com/sun/tools/example/debug/expr/LValue.java +1056 −0
  62. java/pkg/com/sun/tools/example/debug/expr/ParseException.java +221 −0
  63. java/pkg/com/sun/tools/example/debug/expr/Token.java +107 −0
  64. java/pkg/com/sun/tools/example/debug/expr/TokenMgrError.java +161 −0
  65. java/pkg/com/sun/tools/example/debug/expr/mkfile +15 −0
  66. java/pkg/com/sun/tools/example/debug/gui/ApplicationTool.java +74 −0
  67. java/pkg/com/sun/tools/example/debug/gui/ClassManager.java +64 −0
  68. java/pkg/com/sun/tools/example/debug/gui/ClassTreeTool.java +278 −0
  69. java/pkg/com/sun/tools/example/debug/gui/CommandInterpreter.java +1459 −0
  70. java/pkg/com/sun/tools/example/debug/gui/CommandTool.java +333 −0
  71. java/pkg/com/sun/tools/example/debug/gui/ContextListener.java +30 −0
  72. java/pkg/com/sun/tools/example/debug/gui/ContextManager.java +353 −0
  73. java/pkg/com/sun/tools/example/debug/gui/CurrentFrameChangedEvent.java +62 −0
  74. java/pkg/com/sun/tools/example/debug/gui/Environment.java +156 −0
  75. java/pkg/com/sun/tools/example/debug/gui/GUI.java +256 −0
  76. java/pkg/com/sun/tools/example/debug/gui/Icons.java +209 −0
  77. java/pkg/com/sun/tools/example/debug/gui/JDBFileFilter.java +269 −0
  78. java/pkg/com/sun/tools/example/debug/gui/JDBMenuBar.java +190 −0
  79. java/pkg/com/sun/tools/example/debug/gui/JDBToolBar.java +101 −0
  80. java/pkg/com/sun/tools/example/debug/gui/LaunchTool.java +263 −0
  81. java/pkg/com/sun/tools/example/debug/gui/MonitorListModel.java +90 −0
  82. java/pkg/com/sun/tools/example/debug/gui/MonitorTool.java +125 −0
  83. java/pkg/com/sun/tools/example/debug/gui/OutputSink.java +46 −0
  84. java/pkg/com/sun/tools/example/debug/gui/SearchPath.java +95 −0
  85. java/pkg/com/sun/tools/example/debug/gui/SingleLeafTreeSelectionModel.java +70 −0
  86. java/pkg/com/sun/tools/example/debug/gui/SourceListener.java +30 −0
  87. java/pkg/com/sun/tools/example/debug/gui/SourceManager.java +180 −0
  88. java/pkg/com/sun/tools/example/debug/gui/SourceModel.java +247 −0
  89. java/pkg/com/sun/tools/example/debug/gui/SourceTool.java +383 −0
  90. java/pkg/com/sun/tools/example/debug/gui/SourceTreeTool.java +283 −0
  91. java/pkg/com/sun/tools/example/debug/gui/SourcepathChangedEvent.java +37 −0
  92. java/pkg/com/sun/tools/example/debug/gui/StackTraceTool.java +198 −0
  93. java/pkg/com/sun/tools/example/debug/gui/ThreadTreeTool.java +346 −0
  94. java/pkg/com/sun/tools/example/debug/gui/TypeScript.java +123 −0
  95. java/pkg/com/sun/tools/example/debug/gui/TypeScriptOutputListener.java +52 −0
  96. java/pkg/com/sun/tools/example/debug/gui/TypeScriptWriter.java +52 −0
  97. java/pkg/com/sun/tools/example/debug/gui/mkfile +38 −0
  98. java/pkg/com/sun/tools/example/debug/mkfile +10 −0
  99. java/pkg/com/sun/tools/example/debug/tty/AccessWatchpointSpec.java +58 −0
  100. java/pkg/com/sun/tools/example/debug/tty/AmbiguousMethodException.java +41 −0
  101. java/pkg/com/sun/tools/example/debug/tty/BreakpointSpec.java +382 −0
  102. java/pkg/com/sun/tools/example/debug/tty/Commands.java +2098 −0
  103. java/pkg/com/sun/tools/example/debug/tty/Env.java +322 −0
  104. java/pkg/com/sun/tools/example/debug/tty/EventHandler.java +277 −0
  105. java/pkg/com/sun/tools/example/debug/tty/EventNotifier.java +50 −0
  106. java/pkg/com/sun/tools/example/debug/tty/EventRequestSpec.java +210 −0
  107. java/pkg/com/sun/tools/example/debug/tty/EventRequestSpecList.java +166 −0
  108. java/pkg/com/sun/tools/example/debug/tty/ExceptionSpec.java +107 −0
  109. java/pkg/com/sun/tools/example/debug/tty/LineNotFoundException.java +41 −0
  110. java/pkg/com/sun/tools/example/debug/tty/MalformedMemberNameException.java +38 −0
  111. java/pkg/com/sun/tools/example/debug/tty/MessageOutput.java +196 −0
  112. java/pkg/com/sun/tools/example/debug/tty/ModificationWatchpointSpec.java +58 −0
  113. java/pkg/com/sun/tools/example/debug/tty/PatternReferenceTypeSpec.java +136 −0
  114. java/pkg/com/sun/tools/example/debug/tty/ReferenceTypeSpec.java +43 −0
  115. java/pkg/com/sun/tools/example/debug/tty/SourceMapper.java +138 −0
  116. java/pkg/com/sun/tools/example/debug/tty/TTY.java +1063 −0
  117. java/pkg/com/sun/tools/example/debug/tty/TTYResources.java +456 −0
  118. java/pkg/com/sun/tools/example/debug/tty/TTYResources_ja.java +327 −0
  119. java/pkg/com/sun/tools/example/debug/tty/TTYResources_zh_CN.java +327 −0
  120. java/pkg/com/sun/tools/example/debug/tty/ThreadGroupIterator.java +104 −0
  121. java/pkg/com/sun/tools/example/debug/tty/ThreadInfo.java +287 −0
  122. java/pkg/com/sun/tools/example/debug/tty/ThreadIterator.java +73 −0
  123. java/pkg/com/sun/tools/example/debug/tty/VMConnection.java +376 −0
  124. java/pkg/com/sun/tools/example/debug/tty/VMNotConnectedException.java +39 −0
  125. java/pkg/com/sun/tools/example/debug/tty/WatchpointSpec.java +68 −0
  126. java/pkg/com/sun/tools/example/debug/tty/mkfile +34 −0
java/pkg/com/sun/tools/example/debug/bdi/AccessWatchpointSpec.java+58−0
@@ -0,0 +1,58 @@
1+/*
2+ * Copyright (c) 1999, Oracle and/or its affiliates. All rights reserved.
3+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+ *
5+ * This code is free software; you can redistribute it and/or modify it
6+ * under the terms of the GNU General Public License version 2 only, as
7+ * published by the Free Software Foundation. Oracle designates this
8+ * particular file as subject to the "Classpath" exception as provided
9+ * by Oracle in the LICENSE file that accompanied this code.
10+ *
11+ * This code is distributed in the hope that it will be useful, but WITHOUT
12+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+ * version 2 for more details (a copy is included in the LICENSE file that
15+ * accompanied this code).
16+ *
17+ * You should have received a copy of the GNU General Public License version
18+ * 2 along with this work; if not, write to the Free Software Foundation,
19+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+ *
21+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+ * or visit www.oracle.com if you need additional information or have any
23+ * questions.
24+ */
25+
26+package com.sun.tools.example.debug.bdi;
27+
28+import com.sun.jdi.*;
29+
30+public class AccessWatchpointSpec extends WatchpointSpec {
31+
32+ AccessWatchpointSpec(EventRequestSpecList specs,
33+ ReferenceTypeSpec refSpec, String fieldId) {
34+ super(specs, refSpec, fieldId);
35+ }
36+
37+ /**
38+ * The 'refType' is known to match.
39+ */
40+ @Override
41+ void resolve(ReferenceType refType) throws InvalidTypeException,
42+ NoSuchFieldException {
43+ if (!(refType instanceof ClassType)) {
44+ throw new InvalidTypeException();
45+ }
46+ Field field = refType.fieldByName(fieldId);
47+ if (field == null) {
48+ throw new NoSuchFieldException(fieldId);
49+ }
50+ setRequest(refType.virtualMachine().eventRequestManager()
51+ .createAccessWatchpointRequest(field));
52+ }
53+
54+ @Override
55+ public boolean equals(Object obj) {
56+ return (obj instanceof AccessWatchpointSpec) && super.equals(obj);
57+ }
58+}
java/pkg/com/sun/tools/example/debug/bdi/AmbiguousMethodException.java+42−0
@@ -0,0 +1,42 @@
1+/*
2+ * Copyright (c) 1998, 1999, Oracle and/or its affiliates. All rights reserved.
3+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+ *
5+ * This code is free software; you can redistribute it and/or modify it
6+ * under the terms of the GNU General Public License version 2 only, as
7+ * published by the Free Software Foundation. Oracle designates this
8+ * particular file as subject to the "Classpath" exception as provided
9+ * by Oracle in the LICENSE file that accompanied this code.
10+ *
11+ * This code is distributed in the hope that it will be useful, but WITHOUT
12+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+ * version 2 for more details (a copy is included in the LICENSE file that
15+ * accompanied this code).
16+ *
17+ * You should have received a copy of the GNU General Public License version
18+ * 2 along with this work; if not, write to the Free Software Foundation,
19+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+ *
21+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+ * or visit www.oracle.com if you need additional information or have any
23+ * questions.
24+ */
25+
26+package com.sun.tools.example.debug.bdi;
27+
28+public class AmbiguousMethodException extends Exception
29+{
30+
31+ private static final long serialVersionUID = 7793370943251707514L;
32+
33+ public AmbiguousMethodException()
34+ {
35+ super();
36+ }
37+
38+ public AmbiguousMethodException(String s)
39+ {
40+ super(s);
41+ }
42+}
java/pkg/com/sun/tools/example/debug/bdi/BreakpointSpec.java+58−0
@@ -0,0 +1,58 @@
1+/*
2+ * Copyright (c) 1999, Oracle and/or its affiliates. All rights reserved.
3+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+ *
5+ * This code is free software; you can redistribute it and/or modify it
6+ * under the terms of the GNU General Public License version 2 only, as
7+ * published by the Free Software Foundation. Oracle designates this
8+ * particular file as subject to the "Classpath" exception as provided
9+ * by Oracle in the LICENSE file that accompanied this code.
10+ *
11+ * This code is distributed in the hope that it will be useful, but WITHOUT
12+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+ * version 2 for more details (a copy is included in the LICENSE file that
15+ * accompanied this code).
16+ *
17+ * You should have received a copy of the GNU General Public License version
18+ * 2 along with this work; if not, write to the Free Software Foundation,
19+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+ *
21+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+ * or visit www.oracle.com if you need additional information or have any
23+ * questions.
24+ */
25+
26+package com.sun.tools.example.debug.bdi;
27+
28+public abstract class BreakpointSpec extends EventRequestSpec {
29+
30+ BreakpointSpec(EventRequestSpecList specs, ReferenceTypeSpec refSpec) {
31+ super(specs, refSpec);
32+ }
33+
34+ @Override
35+ void notifySet(SpecListener listener, SpecEvent evt) {
36+ listener.breakpointSet(evt);
37+ }
38+
39+ @Override
40+ void notifyDeferred(SpecListener listener, SpecEvent evt) {
41+ listener.breakpointDeferred(evt);
42+ }
43+
44+ @Override
45+ void notifyResolved(SpecListener listener, SpecEvent evt) {
46+ listener.breakpointResolved(evt);
47+ }
48+
49+ @Override
50+ void notifyDeleted(SpecListener listener, SpecEvent evt) {
51+ listener.breakpointDeleted(evt);
52+ }
53+
54+ @Override
55+ void notifyError(SpecListener listener, SpecErrorEvent evt) {
56+ listener.breakpointError(evt);
57+ }
58+}
java/pkg/com/sun/tools/example/debug/bdi/ChildSession.java+300−0
@@ -0,0 +1,300 @@
1+/*
2+ * Copyright (c) 1998, 1999, Oracle and/or its affiliates. All rights reserved.
3+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+ *
5+ * This code is free software; you can redistribute it and/or modify it
6+ * under the terms of the GNU General Public License version 2 only, as
7+ * published by the Free Software Foundation. Oracle designates this
8+ * particular file as subject to the "Classpath" exception as provided
9+ * by Oracle in the LICENSE file that accompanied this code.
10+ *
11+ * This code is distributed in the hope that it will be useful, but WITHOUT
12+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+ * version 2 for more details (a copy is included in the LICENSE file that
15+ * accompanied this code).
16+ *
17+ * You should have received a copy of the GNU General Public License version
18+ * 2 along with this work; if not, write to the Free Software Foundation,
19+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+ *
21+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+ * or visit www.oracle.com if you need additional information or have any
23+ * questions.
24+ */
25+
26+package com.sun.tools.example.debug.bdi;
27+
28+import com.sun.jdi.*;
29+import com.sun.jdi.connect.LaunchingConnector;
30+import com.sun.jdi.connect.Connector;
31+import com.sun.jdi.connect.VMStartException;
32+import com.sun.jdi.connect.IllegalConnectorArgumentsException;
33+import java.io.*;
34+import java.util.Map;
35+import javax.swing.SwingUtilities;
36+
37+
38+class ChildSession extends Session {
39+
40+ private Process process;
41+
42+ private PrintWriter in;
43+ private BufferedReader out;
44+ private BufferedReader err;
45+
46+ private InputListener input;
47+ private OutputListener output;
48+ private OutputListener error;
49+
50+ public ChildSession(ExecutionManager runtime,
51+ String userVMArgs, String cmdLine,
52+ InputListener input,
53+ OutputListener output,
54+ OutputListener error,
55+ OutputListener diagnostics) {
56+ this(runtime, getVM(diagnostics, userVMArgs, cmdLine),
57+ input, output, error, diagnostics);
58+ }
59+
60+ public ChildSession(ExecutionManager runtime,
61+ LaunchingConnector connector,
62+ Map<String, Connector.Argument> arguments,
63+ InputListener input,
64+ OutputListener output,
65+ OutputListener error,
66+ OutputListener diagnostics) {
67+ this(runtime, generalGetVM(diagnostics, connector, arguments),
68+ input, output, error, diagnostics);
69+ }
70+
71+ private ChildSession(ExecutionManager runtime,
72+ VirtualMachine vm,
73+ InputListener input,
74+ OutputListener output,
75+ OutputListener error,
76+ OutputListener diagnostics) {
77+ super(vm, runtime, diagnostics);
78+ this.input = input;
79+ this.output = output;
80+ this.error = error;
81+ }
82+
83+ @Override
84+ public boolean attach() {
85+
86+ if (!connectToVMProcess()) {
87+ diagnostics.putString("Could not launch VM");
88+ return false;
89+ }
90+
91+ /*
92+ * Create a Thread that will retrieve and display any output.
93+ * Needs to be high priority, else debugger may exit before
94+ * it can be displayed.
95+ */
96+
97+ //### Rename InputWriter and OutputReader classes
98+ //### Thread priorities cribbed from ttydebug. Think about them.
99+
100+ OutputReader outputReader =
101+ new OutputReader("output reader", "output",
102+ out, output, diagnostics);
103+ outputReader.setPriority(Thread.MAX_PRIORITY-1);
104+ outputReader.start();
105+
106+ OutputReader errorReader =
107+ new OutputReader("error reader", "error",
108+ err, error, diagnostics);
109+ errorReader.setPriority(Thread.MAX_PRIORITY-1);
110+ errorReader.start();
111+
112+ InputWriter inputWriter =
113+ new InputWriter("input writer", in, input);
114+ inputWriter.setPriority(Thread.MAX_PRIORITY-1);
115+ inputWriter.start();
116+
117+ if (!super.attach()) {
118+ if (process != null) {
119+ process.destroy();
120+ process = null;
121+ }
122+ return false;
123+ }
124+
125+ //### debug
126+ //System.out.println("IO after attach: "+ inputWriter + " " + outputReader + " "+ errorReader);
127+
128+ return true;
129+ }
130+
131+ @Override
132+ public void detach() {
133+
134+ //### debug
135+ //System.out.println("IO before detach: "+ inputWriter + " " + outputReader + " "+ errorReader);
136+
137+ super.detach();
138+
139+ /*
140+ inputWriter.quit();
141+ outputReader.quit();
142+ errorReader.quit();
143+ */
144+
145+ if (process != null) {
146+ process.destroy();
147+ process = null;
148+ }
149+
150+ }
151+
152+ /**
153+ * Launch child java interpreter, return host:port
154+ */
155+
156+ static private void dumpStream(OutputListener diagnostics,
157+ InputStream stream) throws IOException {
158+ BufferedReader in =
159+ new BufferedReader(new InputStreamReader(stream));
160+ String line;
161+ while ((line = in.readLine()) != null) {
162+ diagnostics.putString(line);
163+ }
164+ }
165+
166+ static private void dumpFailedLaunchInfo(OutputListener diagnostics,
167+ Process process) {
168+ try {
169+ dumpStream(diagnostics, process.getErrorStream());
170+ dumpStream(diagnostics, process.getInputStream());
171+ } catch (IOException e) {
172+ diagnostics.putString("Unable to display process output: " +
173+ e.getMessage());
174+ }
175+ }
176+
177+ static private VirtualMachine getVM(OutputListener diagnostics,
178+ String userVMArgs,
179+ String cmdLine) {
180+ VirtualMachineManager manager = Bootstrap.virtualMachineManager();
181+ LaunchingConnector connector = manager.defaultConnector();
182+ Map<String, Connector.Argument> arguments = connector.defaultArguments();
183+ arguments.get("options").setValue(userVMArgs);
184+ arguments.get("main").setValue(cmdLine);
185+ return generalGetVM(diagnostics, connector, arguments);
186+ }
187+
188+ static private VirtualMachine generalGetVM(OutputListener diagnostics,
189+ LaunchingConnector connector,
190+ Map<String, Connector.Argument> arguments) {
191+ VirtualMachine vm = null;
192+ try {
193+ diagnostics.putString("Starting child.");
194+ vm = connector.launch(arguments);
195+ } catch (IOException ioe) {
196+ diagnostics.putString("Unable to start child: " + ioe.getMessage());
197+ } catch (IllegalConnectorArgumentsException icae) {
198+ diagnostics.putString("Unable to start child: " + icae.getMessage());
199+ } catch (VMStartException vmse) {
200+ diagnostics.putString("Unable to start child: " + vmse.getMessage() + '\n');
201+ dumpFailedLaunchInfo(diagnostics, vmse.process());
202+ }
203+ return vm;
204+ }
205+
206+ private boolean connectToVMProcess() {
207+ if (vm == null) {
208+ return false;
209+ }
210+ process = vm.process();
211+ in = new PrintWriter(new OutputStreamWriter(process.getOutputStream()));
212+ //### Note small buffer sizes!
213+ out = new BufferedReader(new InputStreamReader(process.getInputStream()), 1);
214+ err = new BufferedReader(new InputStreamReader(process.getErrorStream()), 1);
215+ return true;
216+ }
217+
218+ /**
219+ * Threads to handle application input/output.
220+ */
221+
222+ private static class OutputReader extends Thread {
223+
224+ private String streamName;
225+ private BufferedReader stream;
226+ private OutputListener output;
227+ private OutputListener diagnostics;
228+ private boolean running = true;
229+ private char[] buffer = new char[512];
230+
231+ OutputReader(String threadName,
232+ String streamName,
233+ BufferedReader stream,
234+ OutputListener output,
235+ OutputListener diagnostics) {
236+ super(threadName);
237+ this.streamName = streamName;
238+ this.stream = stream;
239+ this.output = output;
240+ this.diagnostics = diagnostics;
241+ }
242+
243+ @Override
244+ public void run() {
245+ try {
246+ int count;
247+ while (running && (count = stream.read(buffer, 0, 512)) != -1) {
248+ if (count > 0) {
249+ // Run in Swing event dispatcher thread.
250+ final String chars = new String(buffer, 0, count);
251+ SwingUtilities.invokeLater(new Runnable() {
252+ @Override
253+ public void run() {
254+ output.putString(chars);
255+ }
256+ });
257+ }
258+ //### Should we sleep briefly here?
259+ }
260+ } catch (IOException e) {
261+ // Run in Swing event dispatcher thread.
262+ SwingUtilities.invokeLater(new Runnable() {
263+ @Override
264+ public void run() {
265+ diagnostics.putString("IO error reading " +
266+ streamName +
267+ " stream of child java interpreter");
268+ }
269+ });
270+ }
271+ }
272+ }
273+
274+ private static class InputWriter extends Thread {
275+
276+ private PrintWriter stream;
277+ private InputListener input;
278+ private boolean running = true;
279+
280+ InputWriter(String threadName,
281+ PrintWriter stream,
282+ InputListener input) {
283+ super(threadName);
284+ this.stream = stream;
285+ this.input = input;
286+ }
287+
288+ @Override
289+ public void run() {
290+ String line;
291+ while (running) {
292+ line = input.getLine();
293+ stream.println(line);
294+ // Should not be needed for println above!
295+ stream.flush();
296+ }
297+ }
298+ }
299+
300+}
java/pkg/com/sun/tools/example/debug/bdi/EvaluationException.java+31−0
@@ -0,0 +1,31 @@
1+/*
2+ * Copyright (c) 1998, 1999, Oracle and/or its affiliates. All rights reserved.
3+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+ *
5+ * This code is free software; you can redistribute it and/or modify it
6+ * under the terms of the GNU General Public License version 2 only, as
7+ * published by the Free Software Foundation. Oracle designates this
8+ * particular file as subject to the "Classpath" exception as provided
9+ * by Oracle in the LICENSE file that accompanied this code.
10+ *
11+ * This code is distributed in the hope that it will be useful, but WITHOUT
12+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+ * version 2 for more details (a copy is included in the LICENSE file that
15+ * accompanied this code).
16+ *
17+ * You should have received a copy of the GNU General Public License version
18+ * 2 along with this work; if not, write to the Free Software Foundation,
19+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+ *
21+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+ * or visit www.oracle.com if you need additional information or have any
23+ * questions.
24+ */
25+
26+package com.sun.tools.example.debug.bdi;
27+
28+public class EvaluationException extends Exception {
29+
30+ private static final long serialVersionUID = 4947109680354951694L;
31+}
java/pkg/com/sun/tools/example/debug/bdi/EventRequestSpec.java+159−0
@@ -0,0 +1,159 @@
1+/*
2+ * Copyright (c) 1999, 2008, Oracle and/or its affiliates. All rights reserved.
3+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+ *
5+ * This code is free software; you can redistribute it and/or modify it
6+ * under the terms of the GNU General Public License version 2 only, as
7+ * published by the Free Software Foundation. Oracle designates this
8+ * particular file as subject to the "Classpath" exception as provided
9+ * by Oracle in the LICENSE file that accompanied this code.
10+ *
11+ * This code is distributed in the hope that it will be useful, but WITHOUT
12+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+ * version 2 for more details (a copy is included in the LICENSE file that
15+ * accompanied this code).
16+ *
17+ * You should have received a copy of the GNU General Public License version
18+ * 2 along with this work; if not, write to the Free Software Foundation,
19+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+ *
21+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+ * or visit www.oracle.com if you need additional information or have any
23+ * questions.
24+ */
25+
26+package com.sun.tools.example.debug.bdi;
27+
28+import com.sun.jdi.*;
29+import com.sun.jdi.request.EventRequest;
30+
31+abstract public class EventRequestSpec {
32+
33+ static final int STATUS_UNRESOLVED = 1;
34+ static final int STATUS_RESOLVED = 2;
35+ static final int STATUS_ERROR = 3;
36+
37+ static final Object specPropertyKey = "spec";
38+
39+ final EventRequestSpecList specs;
40+ final ReferenceTypeSpec refSpec;
41+ EventRequest request = null;
42+
43+ int status = STATUS_UNRESOLVED;
44+
45+ EventRequestSpec(EventRequestSpecList specs, ReferenceTypeSpec refSpec) {
46+ this.specs = specs;
47+ this.refSpec = refSpec;
48+ }
49+
50+ void setRequest(EventRequest request) {
51+ this.request = request;
52+ request.putProperty(specPropertyKey, this);
53+ request.enable();
54+ }
55+
56+ /**
57+ * The 'refType' is known to match.
58+ */
59+ abstract void resolve(ReferenceType refType) throws Exception;
60+
61+ abstract void notifySet(SpecListener listener, SpecEvent evt);
62+ abstract void notifyDeferred(SpecListener listener, SpecEvent evt);
63+ abstract void notifyResolved(SpecListener listener, SpecEvent evt);
64+ abstract void notifyDeleted(SpecListener listener, SpecEvent evt);
65+ abstract void notifyError(SpecListener listener, SpecErrorEvent evt);
66+
67+ /**
68+ * The 'refType' is known to match.
69+ */
70+ void resolveNotify(ReferenceType refType) {
71+ try {
72+ resolve(refType);
73+ status = STATUS_RESOLVED;
74+ specs.notifyResolved(this);
75+ } catch(Exception exc) {
76+ status = STATUS_ERROR;
77+ specs.notifyError(this, exc);
78+ }
79+ }
80+
81+ /**
82+ * See if 'refType' matches and resolve.
83+ */
84+ void attemptResolve(ReferenceType refType) {
85+ if (!isResolved() && refSpec.matches(refType)) {
86+ resolveNotify(refType);
87+ }
88+ }
89+
90+ void attemptImmediateResolve(VirtualMachine vm) {
91+ // try to resolve immediately
92+ for (ReferenceType refType : vm.allClasses()) {
93+ if (refSpec.matches(refType)) {
94+ try {
95+ resolve(refType);
96+ status = STATUS_RESOLVED;
97+ specs.notifySet(this);
98+ } catch(Exception exc) {
99+ status = STATUS_ERROR;
100+ specs.notifyError(this, exc);
101+ }
102+ return;
103+ }
104+ }
105+ specs.notifyDeferred(this);
106+ }
107+
108+ public EventRequest getEventRequest() {
109+ return request;
110+ }
111+
112+ /**
113+ * @return true if this spec has been resolved.
114+ */
115+ public boolean isResolved() {
116+ return status == STATUS_RESOLVED;
117+ }
118+
119+ /**
120+ * @return true if this spec has not yet been resolved.
121+ */
122+ public boolean isUnresolved() {
123+ return status == STATUS_UNRESOLVED;
124+ }
125+
126+ /**
127+ * @return true if this spec is unresolvable due to error.
128+ */
129+ public boolean isErroneous() {
130+ return status == STATUS_ERROR;
131+ }
132+
133+ public String getStatusString() {
134+ switch (status) {
135+ case STATUS_RESOLVED:
136+ return "resolved";
137+ case STATUS_UNRESOLVED:
138+ return "deferred";
139+ case STATUS_ERROR:
140+ return "erroneous";
141+ }
142+ return "unknown";
143+ }
144+
145+ boolean isJavaIdentifier(String s) {
146+ return Utils.isJavaIdentifier(s);
147+ }
148+
149+ public String errorMessageFor(Exception e) {
150+ if (e instanceof IllegalArgumentException) {
151+ return ("Invalid command syntax");
152+ } else if (e instanceof RuntimeException) {
153+ // A runtime exception that we were not expecting
154+ throw (RuntimeException)e;
155+ } else {
156+ return ("Internal error; unable to set" + this);
157+ }
158+ }
159+}
java/pkg/com/sun/tools/example/debug/bdi/EventRequestSpecList.java+178−0
@@ -0,0 +1,178 @@
1+/*
2+ * Copyright (c) 1999, 2008, Oracle and/or its affiliates. All rights reserved.
3+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+ *
5+ * This code is free software; you can redistribute it and/or modify it
6+ * under the terms of the GNU General Public License version 2 only, as
7+ * published by the Free Software Foundation. Oracle designates this
8+ * particular file as subject to the "Classpath" exception as provided
9+ * by Oracle in the LICENSE file that accompanied this code.
10+ *
11+ * This code is distributed in the hope that it will be useful, but WITHOUT
12+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+ * version 2 for more details (a copy is included in the LICENSE file that
15+ * accompanied this code).
16+ *
17+ * You should have received a copy of the GNU General Public License version
18+ * 2 along with this work; if not, write to the Free Software Foundation,
19+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+ *
21+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+ * or visit www.oracle.com if you need additional information or have any
23+ * questions.
24+ */
25+
26+package com.sun.tools.example.debug.bdi;
27+
28+import com.sun.jdi.*;
29+import com.sun.jdi.request.*;
30+
31+import java.util.*;
32+
33+class EventRequestSpecList {
34+
35+ // all specs
36+ private List<EventRequestSpec> eventRequestSpecs = Collections.synchronizedList(
37+ new ArrayList<EventRequestSpec>());
38+
39+ final ExecutionManager runtime;
40+
41+ EventRequestSpecList(ExecutionManager runtime) {
42+ this.runtime = runtime;
43+ }
44+
45+ /**
46+ * Resolve all deferred eventRequests waiting for 'refType'.
47+ */
48+ void resolve(ReferenceType refType) {
49+ synchronized(eventRequestSpecs) {
50+ for (EventRequestSpec spec : eventRequestSpecs) {
51+ spec.attemptResolve(refType);
52+ }
53+ }
54+ }
55+
56+ void install(EventRequestSpec ers, VirtualMachine vm) {
57+ synchronized (eventRequestSpecs) {
58+ eventRequestSpecs.add(ers);
59+ }
60+ if (vm != null) {
61+ ers.attemptImmediateResolve(vm);
62+ }
63+ }
64+
65+ BreakpointSpec
66+ createClassLineBreakpoint(String classPattern, int line) {
67+ ReferenceTypeSpec refSpec =
68+ new PatternReferenceTypeSpec(classPattern);
69+ return new LineBreakpointSpec(this, refSpec, line);
70+ }
71+
72+ BreakpointSpec
73+ createSourceLineBreakpoint(String sourceName, int line) {
74+ ReferenceTypeSpec refSpec =
75+ new SourceNameReferenceTypeSpec(sourceName, line);
76+ return new LineBreakpointSpec(this, refSpec, line);
77+ }
78+
79+ BreakpointSpec
80+ createMethodBreakpoint(String classPattern,
81+ String methodId, List<String> methodArgs) {
82+ ReferenceTypeSpec refSpec =
83+ new PatternReferenceTypeSpec(classPattern);
84+ return new MethodBreakpointSpec(this, refSpec,
85+ methodId, methodArgs);
86+ }
87+
88+ ExceptionSpec
89+ createExceptionIntercept(String classPattern,
90+ boolean notifyCaught,
91+ boolean notifyUncaught) {
92+ ReferenceTypeSpec refSpec =
93+ new PatternReferenceTypeSpec(classPattern);
94+ return new ExceptionSpec(this, refSpec,
95+ notifyCaught, notifyUncaught);
96+ }
97+
98+ AccessWatchpointSpec
99+ createAccessWatchpoint(String classPattern, String fieldId) {
100+ ReferenceTypeSpec refSpec =
101+ new PatternReferenceTypeSpec(classPattern);
102+ return new AccessWatchpointSpec(this, refSpec, fieldId);
103+ }
104+
105+ ModificationWatchpointSpec
106+ createModificationWatchpoint(String classPattern, String fieldId) {
107+ ReferenceTypeSpec refSpec =
108+ new PatternReferenceTypeSpec(classPattern);
109+ return new ModificationWatchpointSpec(this, refSpec, fieldId);
110+ }
111+
112+ void delete(EventRequestSpec ers) {
113+ EventRequest request = ers.getEventRequest();
114+ synchronized (eventRequestSpecs) {
115+ eventRequestSpecs.remove(ers);
116+ }
117+ if (request != null) {
118+ request.virtualMachine().eventRequestManager()
119+ .deleteEventRequest(request);
120+ }
121+ notifyDeleted(ers);
122+ //### notify delete - here?
123+ }
124+
125+ List<EventRequestSpec> eventRequestSpecs() {
126+ // We need to make a copy to avoid synchronization problems
127+ synchronized (eventRequestSpecs) {
128+ return new ArrayList<EventRequestSpec>(eventRequestSpecs);
129+ }
130+ }
131+
132+ // -------- notify routines --------------------
133+
134+ @SuppressWarnings("unchecked")
135+ private Vector<SpecListener> specListeners() {
136+ return (Vector<SpecListener>)runtime.specListeners.clone();
137+ }
138+
139+ void notifySet(EventRequestSpec spec) {
140+ Vector<SpecListener> l = specListeners();
141+ SpecEvent evt = new SpecEvent(spec);
142+ for (int i = 0; i < l.size(); i++) {
143+ spec.notifySet(l.elementAt(i), evt);
144+ }
145+ }
146+
147+ void notifyDeferred(EventRequestSpec spec) {
148+ Vector<SpecListener> l = specListeners();
149+ SpecEvent evt = new SpecEvent(spec);
150+ for (int i = 0; i < l.size(); i++) {
151+ spec.notifyDeferred(l.elementAt(i), evt);
152+ }
153+ }
154+
155+ void notifyDeleted(EventRequestSpec spec) {
156+ Vector<SpecListener> l = specListeners();
157+ SpecEvent evt = new SpecEvent(spec);
158+ for (int i = 0; i < l.size(); i++) {
159+ spec.notifyDeleted(l.elementAt(i), evt);
160+ }
161+ }
162+
163+ void notifyResolved(EventRequestSpec spec) {
164+ Vector<SpecListener> l = specListeners();
165+ SpecEvent evt = new SpecEvent(spec);
166+ for (int i = 0; i < l.size(); i++) {
167+ spec.notifyResolved(l.elementAt(i), evt);
168+ }
169+ }
170+
171+ void notifyError(EventRequestSpec spec, Exception exc) {
172+ Vector<SpecListener> l = specListeners();
173+ SpecErrorEvent evt = new SpecErrorEvent(spec, exc);
174+ for (int i = 0; i < l.size(); i++) {
175+ spec.notifyError(l.elementAt(i), evt);
176+ }
177+ }
178+}
java/pkg/com/sun/tools/example/debug/bdi/ExceptionSpec.java+100−0
@@ -0,0 +1,100 @@
1+/*
2+ * Copyright (c) 1999, Oracle and/or its affiliates. All rights reserved.
3+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+ *
5+ * This code is free software; you can redistribute it and/or modify it
6+ * under the terms of the GNU General Public License version 2 only, as
7+ * published by the Free Software Foundation. Oracle designates this
8+ * particular file as subject to the "Classpath" exception as provided
9+ * by Oracle in the LICENSE file that accompanied this code.
10+ *
11+ * This code is distributed in the hope that it will be useful, but WITHOUT
12+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+ * version 2 for more details (a copy is included in the LICENSE file that
15+ * accompanied this code).
16+ *
17+ * You should have received a copy of the GNU General Public License version
18+ * 2 along with this work; if not, write to the Free Software Foundation,
19+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+ *
21+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+ * or visit www.oracle.com if you need additional information or have any
23+ * questions.
24+ */
25+
26+package com.sun.tools.example.debug.bdi;
27+
28+import com.sun.jdi.ReferenceType;
29+
30+public class ExceptionSpec extends EventRequestSpec {
31+
32+ boolean notifyCaught;
33+ boolean notifyUncaught;
34+
35+ ExceptionSpec(EventRequestSpecList specs, ReferenceTypeSpec refSpec,
36+ boolean notifyCaught, boolean notifyUncaught)
37+ {
38+ super(specs, refSpec);
39+ this.notifyCaught = notifyCaught;
40+ this.notifyUncaught = notifyUncaught;
41+ }
42+
43+ @Override
44+ void notifySet(SpecListener listener, SpecEvent evt) {
45+ listener.exceptionInterceptSet(evt);
46+ }
47+
48+ @Override
49+ void notifyDeferred(SpecListener listener, SpecEvent evt) {
50+ listener.exceptionInterceptDeferred(evt);
51+ }
52+
53+ @Override
54+ void notifyResolved(SpecListener listener, SpecEvent evt) {
55+ listener.exceptionInterceptResolved(evt);
56+ }
57+
58+ @Override
59+ void notifyDeleted(SpecListener listener, SpecEvent evt) {
60+ listener.exceptionInterceptDeleted(evt);
61+ }
62+
63+ @Override
64+ void notifyError(SpecListener listener, SpecErrorEvent evt) {
65+ listener.exceptionInterceptError(evt);
66+ }
67+
68+ /**
69+ * The 'refType' is known to match.
70+ */
71+ @Override
72+ void resolve(ReferenceType refType) {
73+ setRequest(refType.virtualMachine().eventRequestManager()
74+ .createExceptionRequest(refType,
75+ notifyCaught, notifyUncaught));
76+ }
77+
78+ @Override
79+ public int hashCode() {
80+ return refSpec.hashCode();
81+ }
82+
83+ @Override
84+ public boolean equals(Object obj) {
85+ if (obj instanceof ExceptionSpec) {
86+ ExceptionSpec es = (ExceptionSpec)obj;
87+
88+ return refSpec.equals(es.refSpec);
89+ } else {
90+ return false;
91+ }
92+ }
93+
94+ @Override
95+ public String toString() {
96+ StringBuffer buffer = new StringBuffer("exception catch ");
97+ buffer.append(refSpec.toString());
98+ return buffer.toString();
99+ }
100+}
java/pkg/com/sun/tools/example/debug/bdi/ExecutionManager.java+815−0
@@ -0,0 +1,815 @@
1+/*
2+ * Copyright (c) 1998, 2008, Oracle and/or its affiliates. All rights reserved.
3+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+ *
5+ * This code is free software; you can redistribute it and/or modify it
6+ * under the terms of the GNU General Public License version 2 only, as
7+ * published by the Free Software Foundation. Oracle designates this
8+ * particular file as subject to the "Classpath" exception as provided
9+ * by Oracle in the LICENSE file that accompanied this code.
10+ *
11+ * This code is distributed in the hope that it will be useful, but WITHOUT
12+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+ * version 2 for more details (a copy is included in the LICENSE file that
15+ * accompanied this code).
16+ *
17+ * You should have received a copy of the GNU General Public License version
18+ * 2 along with this work; if not, write to the Free Software Foundation,
19+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+ *
21+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+ * or visit www.oracle.com if you need additional information or have any
23+ * questions.
24+ */
25+
26+package com.sun.tools.example.debug.bdi;
27+
28+import com.sun.jdi.*;
29+import com.sun.jdi.request.*;
30+import com.sun.jdi.connect.*;
31+import com.sun.tools.example.debug.expr.ExpressionParser;
32+import com.sun.tools.example.debug.expr.ParseException;
33+
34+import java.io.*;
35+import java.util.*;
36+
37+import com.sun.tools.example.debug.event.*;
38+
39+import javax.swing.SwingUtilities;
40+
41+/**
42+ * Move this towards being only state and functionality
43+ * that spans across Sessions (and thus VMs).
44+ */
45+public class ExecutionManager {
46+
47+ private Session session;
48+
49+ /**
50+ * Get/set JDI trace mode.
51+ */
52+ int traceMode = VirtualMachine.TRACE_NONE;
53+
54+ ////////////////// Listener registration //////////////////
55+
56+ // Session Listeners
57+
58+ ArrayList<SessionListener> sessionListeners = new ArrayList<SessionListener>();
59+
60+ public void addSessionListener(SessionListener listener) {
61+ sessionListeners.add(listener);
62+ }
63+
64+ public void removeSessionListener(SessionListener listener) {
65+ sessionListeners.remove(listener);
66+ }
67+
68+ // Spec Listeners
69+
70+ ArrayList<SpecListener> specListeners = new ArrayList<SpecListener>();
71+
72+ public void addSpecListener(SpecListener cl) {
73+ specListeners.add(cl);
74+ }
75+
76+ public void removeSpecListener(SpecListener cl) {
77+ specListeners.remove(cl);
78+ }
79+
80+ // JDI Listeners
81+
82+ ArrayList<JDIListener> jdiListeners = new ArrayList<JDIListener>();
83+
84+ /**
85+ * Adds a JDIListener
86+ */
87+ public void addJDIListener(JDIListener jl) {
88+ jdiListeners.add(jl);
89+ }
90+
91+ /**
92+ * Adds a JDIListener - at the specified position
93+ */
94+ public void addJDIListener(int index, JDIListener jl) {
95+ jdiListeners.add(index, jl);
96+ }
97+
98+ /**
99+ * Removes a JDIListener
100+ */
101+ public void removeJDIListener(JDIListener jl) {
102+ jdiListeners.remove(jl);
103+ }
104+
105+ // App Echo Listeners
106+
107+ private ArrayList<OutputListener> appEchoListeners = new ArrayList<OutputListener>();
108+
109+ public void addApplicationEchoListener(OutputListener l) {
110+ appEchoListeners.add(l);
111+ }
112+
113+ public void removeApplicationEchoListener(OutputListener l) {
114+ appEchoListeners.remove(l);
115+ }
116+
117+ // App Output Listeners
118+
119+ private ArrayList<OutputListener> appOutputListeners = new ArrayList<OutputListener>();
120+
121+ public void addApplicationOutputListener(OutputListener l) {
122+ appOutputListeners.add(l);
123+ }
124+
125+ public void removeApplicationOutputListener(OutputListener l) {
126+ appOutputListeners.remove(l);
127+ }
128+
129+ // App Error Listeners
130+
131+ private ArrayList<OutputListener> appErrorListeners = new ArrayList<OutputListener>();
132+
133+ public void addApplicationErrorListener(OutputListener l) {
134+ appErrorListeners.add(l);
135+ }
136+
137+ public void removeApplicationErrorListener(OutputListener l) {
138+ appErrorListeners.remove(l);
139+ }
140+
141+ // Diagnostic Listeners
142+
143+ private ArrayList<OutputListener> diagnosticsListeners = new ArrayList<OutputListener>();
144+
145+ public void addDiagnosticsListener(OutputListener l) {
146+ diagnosticsListeners.add(l);
147+ }
148+
149+ public void removeDiagnosticsListener(OutputListener l) {
150+ diagnosticsListeners.remove(l);
151+ }
152+
153+ /////////// End Listener Registration //////////////
154+
155+ //### We probably don't want this public
156+ public VirtualMachine vm() {
157+ return session == null ? null : session.vm;
158+ }
159+
160+ void ensureActiveSession() throws NoSessionException {
161+ if (session == null) {
162+ throw new NoSessionException();
163+ }
164+ }
165+
166+ public EventRequestManager eventRequestManager() {
167+ return vm() == null ? null : vm().eventRequestManager();
168+ }
169+
170+ /**
171+ * Get JDI trace mode.
172+ */
173+ public int getTraceMode(int mode) {
174+ return traceMode;
175+ }
176+
177+ /**
178+ * Set JDI trace mode.
179+ */
180+ public void setTraceMode(int mode) {
181+ traceMode = mode;
182+ if (session != null) {
183+ session.setTraceMode(mode);
184+ }
185+ }
186+
187+ /**
188+ * Determine if VM is interrupted, i.e, present and not running.
189+ */
190+ public boolean isInterrupted() /* should: throws NoSessionException */ {
191+// ensureActiveSession();
192+ return session.interrupted;
193+ }
194+
195+ /**
196+ * Return a list of ReferenceType objects for all
197+ * currently loaded classes and interfaces.
198+ * Array types are not returned.
199+ */
200+ public List<ReferenceType> allClasses() throws NoSessionException {
201+ ensureActiveSession();
202+ return vm().allClasses();
203+ }
204+
205+ /**
206+ * Return a ReferenceType object for the currently
207+ * loaded class or interface whose fully-qualified
208+ * class name is specified, else return null if there
209+ * is none.
210+ *
211+ * In general, we must return a list of types, because
212+ * multiple class loaders could have loaded a class
213+ * with the same fully-qualified name.
214+ */
215+ public List<ReferenceType> findClassesByName(String name) throws NoSessionException {
216+ ensureActiveSession();
217+ return vm().classesByName(name);
218+ }
219+
220+ /**
221+ * Return a list of ReferenceType objects for all
222+ * currently loaded classes and interfaces whose name
223+ * matches the given pattern. The pattern syntax is
224+ * open to some future revision, but currently consists
225+ * of a fully-qualified class name in which the first
226+ * component may optionally be a "*" character, designating
227+ * an arbitrary prefix.
228+ */
229+ public List<ReferenceType> findClassesMatchingPattern(String pattern)
230+ throws NoSessionException {
231+ ensureActiveSession();
232+ List<ReferenceType> result = new ArrayList<ReferenceType>(); //### Is default size OK?
233+ if (pattern.startsWith("*.")) {
234+ // Wildcard matches any leading package name.
235+ pattern = pattern.substring(1);
236+ for (ReferenceType type : vm().allClasses()) {
237+ if (type.name().endsWith(pattern)) {
238+ result.add(type);
239+ }
240+ }
241+ return result;
242+ } else {
243+ // It's a class name.
244+ return vm().classesByName(pattern);
245+ }
246+ }
247+
248+ /*
249+ * Return a list of ThreadReference objects corresponding
250+ * to the threads that are currently active in the VM.
251+ * A thread is removed from the list just before the
252+ * thread terminates.
253+ */
254+
255+ public List<ThreadReference> allThreads() throws NoSessionException {
256+ ensureActiveSession();
257+ return vm().allThreads();
258+ }
259+
260+ /*
261+ * Return a list of ThreadGroupReference objects corresponding
262+ * to the top-level threadgroups that are currently active in the VM.
263+ * Note that a thread group may be empty, or contain no threads as
264+ * descendents.
265+ */
266+
267+ public List<ThreadGroupReference> topLevelThreadGroups() throws NoSessionException {
268+ ensureActiveSession();
269+ return vm().topLevelThreadGroups();
270+ }
271+
272+ /*
273+ * Return the system threadgroup.
274+ */
275+
276+ public ThreadGroupReference systemThreadGroup()
277+ throws NoSessionException {
278+ ensureActiveSession();
279+ return vm().topLevelThreadGroups().get(0);
280+ }
281+
282+ /*
283+ * Evaluate an expression.
284+ */
285+
286+ public Value evaluate(final StackFrame f, String expr)
287+ throws ParseException,
288+ InvocationException,
289+ InvalidTypeException,
290+ ClassNotLoadedException,
291+ NoSessionException,
292+ IncompatibleThreadStateException {
293+ ExpressionParser.GetFrame frameGetter = null;
294+ ensureActiveSession();
295+ if (f != null) {
296+ frameGetter = new ExpressionParser.GetFrame() {
297+ @Override
298+ public StackFrame get() /* throws IncompatibleThreadStateException */ {
299+ return f;
300+ }
301+ };
302+ }
303+ return ExpressionParser.evaluate(expr, vm(), frameGetter);
304+ }
305+
306+
307+ /*
308+ * Start a new VM.
309+ */
310+
311+ public void run(boolean suspended,
312+ String vmArgs,
313+ String className,
314+ String args) throws VMLaunchFailureException {
315+
316+ endSession();
317+
318+ //### Set a breakpoint on 'main' method.
319+ //### Would be cleaner if we could just bring up VM already suspended.
320+ if (suspended) {
321+ //### Set breakpoint at 'main(java.lang.String[])'.
322+ List<String> argList = new ArrayList<String>(1);
323+ argList.add("java.lang.String[]");
324+ createMethodBreakpoint(className, "main", argList);
325+ }
326+
327+ String cmdLine = className + " " + args;
328+
329+ startSession(new ChildSession(this, vmArgs, cmdLine,
330+ appInput, appOutput, appError,
331+ diagnostics));
332+ }
333+
334+ /*
335+ * Attach to an existing VM.
336+ */
337+ public void attach(String portName) throws VMLaunchFailureException {
338+ endSession();
339+
340+ //### Changes made here for connectors have broken the
341+ //### the 'Session' abstraction. The 'Session.attach()'
342+ //### method is intended to encapsulate all of the various
343+ //### ways in which session start-up can fail. (maddox 12/18/98)
344+
345+ /*
346+ * Now that attaches and launches both go through Connectors,
347+ * it may be worth creating a new subclass of Session for
348+ * attach sessions.
349+ */
350+ VirtualMachineManager mgr = Bootstrap.virtualMachineManager();
351+ AttachingConnector connector = mgr.attachingConnectors().get(0);
352+ Map<String, Connector.Argument> arguments = connector.defaultArguments();
353+ arguments.get("port").setValue(portName);
354+
355+ Session newSession = internalAttach(connector, arguments);
356+ if (newSession != null) {
357+ startSession(newSession);
358+ }
359+ }
360+
361+ private Session internalAttach(AttachingConnector connector,
362+ Map<String, Connector.Argument> arguments) {
363+ try {
364+ VirtualMachine vm = connector.attach(arguments);
365+ return new Session(vm, this, diagnostics);
366+ } catch (IOException ioe) {
367+ diagnostics.putString("\n Unable to attach to target VM: " +
368+ ioe.getMessage());
369+ } catch (IllegalConnectorArgumentsException icae) {
370+ diagnostics.putString("\n Invalid connector arguments: " +
371+ icae.getMessage());
372+ }
373+ return null;
374+ }
375+
376+ private Session internalListen(ListeningConnector connector,
377+ Map<String, Connector.Argument> arguments) {
378+ try {
379+ VirtualMachine vm = connector.accept(arguments);
380+ return new Session(vm, this, diagnostics);
381+ } catch (IOException ioe) {
382+ diagnostics.putString(
383+ "\n Unable to accept connection to target VM: " +
384+ ioe.getMessage());
385+ } catch (IllegalConnectorArgumentsException icae) {
386+ diagnostics.putString("\n Invalid connector arguments: " +
387+ icae.getMessage());
388+ }
389+ return null;
390+ }
391+
392+ /*
393+ * Connect via user specified arguments
394+ * @return true on success
395+ */
396+ public boolean explictStart(Connector connector, Map<String, Connector.Argument> arguments)
397+ throws VMLaunchFailureException {
398+ Session newSession = null;
399+
400+ endSession();
401+
402+ if (connector instanceof LaunchingConnector) {
403+ // we were launched, use ChildSession
404+ newSession = new ChildSession(this, (LaunchingConnector)connector,
405+ arguments,
406+ appInput, appOutput, appError,
407+ diagnostics);
408+ } else if (connector instanceof AttachingConnector) {
409+ newSession = internalAttach((AttachingConnector)connector,
410+ arguments);
411+ } else if (connector instanceof ListeningConnector) {
412+ newSession = internalListen((ListeningConnector)connector,
413+ arguments);
414+ } else {
415+ diagnostics.putString("\n Unknown connector: " + connector);
416+ }
417+ if (newSession != null) {
418+ startSession(newSession);
419+ }
420+ return newSession != null;
421+ }
422+
423+ /*
424+ * Detach from VM. If VM was started by debugger, terminate it.
425+ */
426+ public void detach() throws NoSessionException {
427+ ensureActiveSession();
428+ endSession();
429+ }
430+
431+ private void startSession(Session s) throws VMLaunchFailureException {
432+ if (!s.attach()) {
433+ throw new VMLaunchFailureException();
434+ }
435+ session = s;
436+ EventRequestManager em = vm().eventRequestManager();
437+ ClassPrepareRequest classPrepareRequest = em.createClassPrepareRequest();
438+ //### We must allow the deferred breakpoints to be resolved before
439+ //### we continue executing the class. We could optimize if there
440+ //### were no deferred breakpoints outstanding for a particular class.
441+ //### Can we do this with JDI?
442+ classPrepareRequest.setSuspendPolicy(EventRequest.SUSPEND_ALL);
443+ classPrepareRequest.enable();
444+ ClassUnloadRequest classUnloadRequest = em.createClassUnloadRequest();
445+ classUnloadRequest.setSuspendPolicy(EventRequest.SUSPEND_NONE);
446+ classUnloadRequest.enable();
447+ ThreadStartRequest threadStartRequest = em.createThreadStartRequest();
448+ threadStartRequest.setSuspendPolicy(EventRequest.SUSPEND_NONE);
449+ threadStartRequest.enable();
450+ ThreadDeathRequest threadDeathRequest = em.createThreadDeathRequest();
451+ threadDeathRequest.setSuspendPolicy(EventRequest.SUSPEND_NONE);
452+ threadDeathRequest.enable();
453+ ExceptionRequest exceptionRequest =
454+ em.createExceptionRequest(null, false, true);
455+ exceptionRequest.setSuspendPolicy(EventRequest.SUSPEND_ALL);
456+ exceptionRequest.enable();
457+ validateThreadInfo();
458+ session.interrupted = true;
459+ notifySessionStart();
460+ }
461+
462+ void endSession() {
463+ if (session != null) {
464+ session.detach();
465+ session = null;
466+ invalidateThreadInfo();
467+ notifySessionDeath();
468+ }
469+ }
470+
471+ /*
472+ * Suspend all VM activity.
473+ */
474+
475+ public void interrupt() throws NoSessionException {
476+ ensureActiveSession();
477+ vm().suspend();
478+ //### Is it guaranteed that the interrupt has happened?
479+ validateThreadInfo();
480+ session.interrupted = true;
481+ notifyInterrupted();
482+ }
483+
484+ /*
485+ * Resume interrupted VM.
486+ */
487+
488+ public void go() throws NoSessionException, VMNotInterruptedException {
489+ ensureActiveSession();
490+ invalidateThreadInfo();
491+ session.interrupted = false;
492+ notifyContinued();
493+ vm().resume();
494+ }
495+
496+ /*
497+ * Stepping.
498+ */
499+ void clearPreviousStep(ThreadReference thread) {
500+ /*
501+ * A previous step may not have completed on this thread;
502+ * if so, it gets removed here.
503+ */
504+ EventRequestManager mgr = vm().eventRequestManager();
505+ for (StepRequest request : mgr.stepRequests()) {
506+ if (request.thread().equals(thread)) {
507+ mgr.deleteEventRequest(request);
508+ break;
509+ }
510+ }
511+ }
512+
513+ private void generalStep(ThreadReference thread, int size, int depth)
514+ throws NoSessionException {
515+ ensureActiveSession();
516+ invalidateThreadInfo();
517+ session.interrupted = false;
518+ notifyContinued();
519+
520+ clearPreviousStep(thread);
521+ EventRequestManager reqMgr = vm().eventRequestManager();
522+ StepRequest request = reqMgr.createStepRequest(thread,
523+ size, depth);
524+ // We want just the next step event and no others
525+ request.addCountFilter(1);
526+ request.enable();
527+ vm().resume();
528+ }
529+
530+ public void stepIntoInstruction(ThreadReference thread)
531+ throws NoSessionException {
532+ generalStep(thread, StepRequest.STEP_MIN, StepRequest.STEP_INTO);
533+ }
534+
535+ public void stepOverInstruction(ThreadReference thread)
536+ throws NoSessionException {
537+ generalStep(thread, StepRequest.STEP_MIN, StepRequest.STEP_OVER);
538+ }
539+
540+ public void stepIntoLine(ThreadReference thread)
541+ throws NoSessionException,
542+ AbsentInformationException {
543+ generalStep(thread, StepRequest.STEP_LINE, StepRequest.STEP_INTO);
544+ }
545+
546+ public void stepOverLine(ThreadReference thread)
547+ throws NoSessionException,
548+ AbsentInformationException {
549+ generalStep(thread, StepRequest.STEP_LINE, StepRequest.STEP_OVER);
550+ }
551+
552+ public void stepOut(ThreadReference thread)
553+ throws NoSessionException {
554+ generalStep(thread, StepRequest.STEP_MIN, StepRequest.STEP_OUT);
555+ }
556+
557+ /*
558+ * Thread control.
559+ */
560+
561+ public void suspendThread(ThreadReference thread) throws NoSessionException {
562+ ensureActiveSession();
563+ thread.suspend();
564+ }
565+
566+ public void resumeThread(ThreadReference thread) throws NoSessionException {
567+ ensureActiveSession();
568+ thread.resume();
569+ }
570+
571+ public void stopThread(ThreadReference thread) throws NoSessionException {
572+ ensureActiveSession();
573+ //### Need an exception now. Which one to use?
574+ //thread.stop();
575+ }
576+
577+ /*
578+ * ThreadInfo objects -- Allow query of thread status and stack.
579+ */
580+
581+ private List<ThreadInfo> threadInfoList = new LinkedList<ThreadInfo>();
582+ //### Should be weak! (in the value, not the key)
583+ private HashMap<ThreadReference, ThreadInfo> threadInfoMap = new HashMap<ThreadReference, ThreadInfo>();
584+
585+ public ThreadInfo threadInfo(ThreadReference thread) {
586+ if (session == null || thread == null) {
587+ return null;
588+ }
589+ ThreadInfo info = threadInfoMap.get(thread);
590+ if (info == null) {
591+ //### Should not hardcode initial frame count and prefetch here!
592+ //info = new ThreadInfo(thread, 10, 10);
593+ info = new ThreadInfo(thread);
594+ if (session.interrupted) {
595+ info.validate();
596+ }
597+ threadInfoList.add(info);
598+ threadInfoMap.put(thread, info);
599+ }
600+ return info;
601+ }
602+
603+ void validateThreadInfo() {
604+ session.interrupted = true;
605+ for (ThreadInfo threadInfo : threadInfoList) {
606+ threadInfo.validate();
607+ }
608+ }
609+
610+ private void invalidateThreadInfo() {
611+ if (session != null) {
612+ session.interrupted = false;
613+ for (ThreadInfo threadInfo : threadInfoList) {
614+ threadInfo.invalidate();
615+ }
616+ }
617+ }
618+
619+ void removeThreadInfo(ThreadReference thread) {
620+ ThreadInfo info = threadInfoMap.get(thread);
621+ if (info != null) {
622+ info.invalidate();
623+ threadInfoMap.remove(thread);
624+ threadInfoList.remove(info);
625+ }
626+ }
627+
628+ /*
629+ * Listen for Session control events.
630+ */
631+
632+ private void notifyInterrupted() {
633+ ArrayList<SessionListener> l = new ArrayList<SessionListener>(sessionListeners);
634+ EventObject evt = new EventObject(this);
635+ for (int i = 0; i < l.size(); i++) {
636+ l.get(i).sessionInterrupt(evt);
637+ }
638+ }
639+
640+ private void notifyContinued() {
641+ ArrayList<SessionListener> l = new ArrayList<SessionListener>(sessionListeners);
642+ EventObject evt = new EventObject(this);
643+ for (int i = 0; i < l.size(); i++) {
644+ l.get(i).sessionContinue(evt);
645+ }
646+ }
647+
648+ private void notifySessionStart() {
649+ ArrayList<SessionListener> l = new ArrayList<SessionListener>(sessionListeners);
650+ EventObject evt = new EventObject(this);
651+ for (int i = 0; i < l.size(); i++) {
652+ l.get(i).sessionStart(evt);
653+ }
654+ }
655+
656+ private void notifySessionDeath() {
657+/*** noop for now
658+ ArrayList<SessionListener> l = new ArrayList<SessionListener>(sessionListeners);
659+ EventObject evt = new EventObject(this);
660+ for (int i = 0; i < l.size(); i++) {
661+ ((SessionListener)l.get(i)).sessionDeath(evt);
662+ }
663+****/
664+ }
665+
666+ /*
667+ * Listen for input and output requests from the application
668+ * being debugged. These are generated only when the debuggee
669+ * is spawned as a child of the debugger.
670+ */
671+
672+ private Object inputLock = new Object();
673+ private LinkedList<String> inputBuffer = new LinkedList<String>();
674+
675+ private void resetInputBuffer() {
676+ synchronized (inputLock) {
677+ inputBuffer = new LinkedList<String>();
678+ }
679+ }
680+
681+ public void sendLineToApplication(String line) {
682+ synchronized (inputLock) {
683+ inputBuffer.addFirst(line);
684+ inputLock.notifyAll();
685+ }
686+ }
687+
688+ private InputListener appInput = new InputListener() {
689+ @Override
690+ public String getLine() {
691+ // Don't allow reader to be interrupted -- catch and retry.
692+ String line = null;
693+ while (line == null) {
694+ synchronized (inputLock) {
695+ try {
696+ while (inputBuffer.size() < 1) {
697+ inputLock.wait();
698+ }
699+ line = inputBuffer.removeLast();
700+ } catch (InterruptedException e) {}
701+ }
702+ }
703+ // We must not be holding inputLock here, as the listener
704+ // that we call to echo a line might call us re-entrantly
705+ // to provide another line of input.
706+ // Run in Swing event dispatcher thread.
707+ final String input = line;
708+ SwingUtilities.invokeLater(new Runnable() {
709+ @Override
710+ public void run() {
711+ echoInputLine(input);
712+ }
713+ });
714+ return line;
715+ }
716+ };
717+
718+ private static String newline = System.getProperty("line.separator");
719+
720+ private void echoInputLine(String line) {
721+ ArrayList<OutputListener> l = new ArrayList<OutputListener>(appEchoListeners);
722+ for (int i = 0; i < l.size(); i++) {
723+ OutputListener ol = l.get(i);
724+ ol.putString(line);
725+ ol.putString(newline);
726+ }
727+ }
728+
729+ private OutputListener appOutput = new OutputListener() {
730+ @Override
731+ public void putString(String string) {
732+ ArrayList<OutputListener> l = new ArrayList<OutputListener>(appEchoListeners);
733+ for (int i = 0; i < l.size(); i++) {
734+ l.get(i).putString(string);
735+ }
736+ }
737+ };
738+
739+ private OutputListener appError = new OutputListener() {
740+ @Override
741+ public void putString(String string) {
742+ ArrayList<OutputListener> l = new ArrayList<OutputListener>(appEchoListeners);
743+ for (int i = 0; i < l.size(); i++) {
744+ l.get(i).putString(string);
745+ }
746+ }
747+ };
748+
749+ private OutputListener diagnostics = new OutputListener() {
750+ @Override
751+ public void putString(String string) {
752+ ArrayList<OutputListener> l = new ArrayList<OutputListener>(diagnosticsListeners);
753+ for (int i = 0; i < l.size(); i++) {
754+ l.get(i).putString(string);
755+ }
756+ }
757+ };
758+
759+ ///////////// Spec Request Creation/Deletion/Query ///////////
760+
761+ private EventRequestSpecList specList = new EventRequestSpecList(this);
762+
763+ public BreakpointSpec
764+ createSourceLineBreakpoint(String sourceName, int line) {
765+ return specList.createSourceLineBreakpoint(sourceName, line);
766+ }
767+
768+ public BreakpointSpec
769+ createClassLineBreakpoint(String classPattern, int line) {
770+ return specList.createClassLineBreakpoint(classPattern, line);
771+ }
772+
773+ public BreakpointSpec
774+ createMethodBreakpoint(String classPattern,
775+ String methodId, List<String> methodArgs) {
776+ return specList.createMethodBreakpoint(classPattern,
777+ methodId, methodArgs);
778+ }
779+
780+ public ExceptionSpec
781+ createExceptionIntercept(String classPattern,
782+ boolean notifyCaught,
783+ boolean notifyUncaught) {
784+ return specList.createExceptionIntercept(classPattern,
785+ notifyCaught,
786+ notifyUncaught);
787+ }
788+
789+ public AccessWatchpointSpec
790+ createAccessWatchpoint(String classPattern, String fieldId) {
791+ return specList.createAccessWatchpoint(classPattern, fieldId);
792+ }
793+
794+ public ModificationWatchpointSpec
795+ createModificationWatchpoint(String classPattern, String fieldId) {
796+ return specList.createModificationWatchpoint(classPattern,
797+ fieldId);
798+ }
799+
800+ public void delete(EventRequestSpec spec) {
801+ specList.delete(spec);
802+ }
803+
804+ void resolve(ReferenceType refType) {
805+ specList.resolve(refType);
806+ }
807+
808+ public void install(EventRequestSpec spec) {
809+ specList.install(spec, vm());
810+ }
811+
812+ public List<EventRequestSpec> eventRequestSpecs() {
813+ return specList.eventRequestSpecs();
814+ }
815+}
java/pkg/com/sun/tools/example/debug/bdi/FrameIndexOutOfBoundsException.java+31−0
@@ -0,0 +1,31 @@
1+/*
2+ * Copyright (c) 1998, 1999, Oracle and/or its affiliates. All rights reserved.
3+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+ *
5+ * This code is free software; you can redistribute it and/or modify it
6+ * under the terms of the GNU General Public License version 2 only, as
7+ * published by the Free Software Foundation. Oracle designates this
8+ * particular file as subject to the "Classpath" exception as provided
9+ * by Oracle in the LICENSE file that accompanied this code.
10+ *
11+ * This code is distributed in the hope that it will be useful, but WITHOUT
12+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+ * version 2 for more details (a copy is included in the LICENSE file that
15+ * accompanied this code).
16+ *
17+ * You should have received a copy of the GNU General Public License version
18+ * 2 along with this work; if not, write to the Free Software Foundation,
19+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+ *
21+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+ * or visit www.oracle.com if you need additional information or have any
23+ * questions.
24+ */
25+
26+package com.sun.tools.example.debug.bdi;
27+
28+public class FrameIndexOutOfBoundsException extends IndexOutOfBoundsException {
29+
30+ private static final long serialVersionUID = -4870148107027371437L;
31+}
java/pkg/com/sun/tools/example/debug/bdi/InputListener.java+30−0
@@ -0,0 +1,30 @@
1+/*
2+ * Copyright (c) 1998, 1999, Oracle and/or its affiliates. All rights reserved.
3+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+ *
5+ * This code is free software; you can redistribute it and/or modify it
6+ * under the terms of the GNU General Public License version 2 only, as
7+ * published by the Free Software Foundation. Oracle designates this
8+ * particular file as subject to the "Classpath" exception as provided
9+ * by Oracle in the LICENSE file that accompanied this code.
10+ *
11+ * This code is distributed in the hope that it will be useful, but WITHOUT
12+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+ * version 2 for more details (a copy is included in the LICENSE file that
15+ * accompanied this code).
16+ *
17+ * You should have received a copy of the GNU General Public License version
18+ * 2 along with this work; if not, write to the Free Software Foundation,
19+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+ *
21+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+ * or visit www.oracle.com if you need additional information or have any
23+ * questions.
24+ */
25+
26+package com.sun.tools.example.debug.bdi;
27+
28+public interface InputListener {
29+ String getLine();
30+}
java/pkg/com/sun/tools/example/debug/bdi/JDIEventSource.java+184−0
@@ -0,0 +1,184 @@
1+/*
2+ * Copyright (c) 1999, 2008, Oracle and/or its affiliates. All rights reserved.
3+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+ *
5+ * This code is free software; you can redistribute it and/or modify it
6+ * under the terms of the GNU General Public License version 2 only, as
7+ * published by the Free Software Foundation. Oracle designates this
8+ * particular file as subject to the "Classpath" exception as provided
9+ * by Oracle in the LICENSE file that accompanied this code.
10+ *
11+ * This code is distributed in the hope that it will be useful, but WITHOUT
12+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+ * version 2 for more details (a copy is included in the LICENSE file that
15+ * accompanied this code).
16+ *
17+ * You should have received a copy of the GNU General Public License version
18+ * 2 along with this work; if not, write to the Free Software Foundation,
19+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+ *
21+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+ * or visit www.oracle.com if you need additional information or have any
23+ * questions.
24+ */
25+
26+package com.sun.tools.example.debug.bdi;
27+
28+import com.sun.jdi.*;
29+import com.sun.jdi.event.*;
30+
31+import com.sun.tools.example.debug.event.*;
32+
33+import javax.swing.SwingUtilities;
34+
35+/**
36+ */
37+class JDIEventSource extends Thread {
38+
39+ private /*final*/ EventQueue queue;
40+ private /*final*/ Session session;
41+ private /*final*/ ExecutionManager runtime;
42+ private final JDIListener firstListener = new FirstListener();
43+
44+ private boolean wantInterrupt; //### Hack
45+
46+ /**
47+ * Create event source.
48+ */
49+ JDIEventSource(Session session) {
50+ super("JDI Event Set Dispatcher");
51+ this.session = session;
52+ this.runtime = session.runtime;
53+ this.queue = session.vm.eventQueue();
54+ }
55+
56+ @Override
57+ public void run() {
58+ try {
59+ runLoop();
60+ } catch (Exception exc) {
61+ //### Do something different for InterruptedException???
62+ // just exit
63+ }
64+ session.running = false;
65+ }
66+
67+ private void runLoop() throws InterruptedException {
68+ AbstractEventSet es;
69+ do {
70+ EventSet jdiEventSet = queue.remove();
71+ es = AbstractEventSet.toSpecificEventSet(jdiEventSet);
72+ session.interrupted = es.suspendedAll();
73+ dispatchEventSet(es);
74+ } while(!(es instanceof VMDisconnectEventSet));
75+ }
76+
77+ //### Gross foul hackery!
78+ private void dispatchEventSet(final AbstractEventSet es) {
79+ SwingUtilities.invokeLater(new Runnable() {
80+ @Override
81+ public void run() {
82+ boolean interrupted = es.suspendedAll();
83+ es.notify(firstListener);
84+ boolean wantInterrupt = JDIEventSource.this.wantInterrupt;
85+ for (JDIListener jl : session.runtime.jdiListeners) {
86+ es.notify(jl);
87+ }
88+ if (interrupted && !wantInterrupt) {
89+ session.interrupted = false;
90+ //### Catch here is a hack
91+ try {
92+ session.vm.resume();
93+ } catch (VMDisconnectedException ee) {}
94+ }
95+ if (es instanceof ThreadDeathEventSet) {
96+ ThreadReference t = ((ThreadDeathEventSet)es).getThread();
97+ session.runtime.removeThreadInfo(t);
98+ }
99+ }
100+ });
101+ }
102+
103+ private void finalizeEventSet(AbstractEventSet es) {
104+ if (session.interrupted && !wantInterrupt) {
105+ session.interrupted = false;
106+ //### Catch here is a hack
107+ try {
108+ session.vm.resume();
109+ } catch (VMDisconnectedException ee) {}
110+ }
111+ if (es instanceof ThreadDeathEventSet) {
112+ ThreadReference t = ((ThreadDeathEventSet)es).getThread();
113+ session.runtime.removeThreadInfo(t);
114+ }
115+ }
116+
117+ //### This is a Hack, deal with it
118+ private class FirstListener implements JDIListener {
119+
120+ @Override
121+ public void accessWatchpoint(AccessWatchpointEventSet e) {
122+ session.runtime.validateThreadInfo();
123+ wantInterrupt = true;
124+ }
125+
126+ @Override
127+ public void classPrepare(ClassPrepareEventSet e) {
128+ wantInterrupt = false;
129+ runtime.resolve(e.getReferenceType());
130+ }
131+
132+ @Override
133+ public void classUnload(ClassUnloadEventSet e) {
134+ wantInterrupt = false;
135+ }
136+
137+ @Override
138+ public void exception(ExceptionEventSet e) {
139+ wantInterrupt = true;
140+ }
141+
142+ @Override
143+ public void locationTrigger(LocationTriggerEventSet e) {
144+ session.runtime.validateThreadInfo();
145+ wantInterrupt = true;
146+ }
147+
148+ @Override
149+ public void modificationWatchpoint(ModificationWatchpointEventSet e) {
150+ session.runtime.validateThreadInfo();
151+ wantInterrupt = true;
152+ }
153+
154+ @Override
155+ public void threadDeath(ThreadDeathEventSet e) {
156+ wantInterrupt = false;
157+ }
158+
159+ @Override
160+ public void threadStart(ThreadStartEventSet e) {
161+ wantInterrupt = false;
162+ }
163+
164+ @Override
165+ public void vmDeath(VMDeathEventSet e) {
166+ //### Should have some way to notify user
167+ //### that VM died before the session ended.
168+ wantInterrupt = false;
169+ }
170+
171+ @Override
172+ public void vmDisconnect(VMDisconnectEventSet e) {
173+ //### Notify user?
174+ wantInterrupt = false;
175+ session.runtime.endSession();
176+ }
177+
178+ @Override
179+ public void vmStart(VMStartEventSet e) {
180+ //### Do we need to do anything with it?
181+ wantInterrupt = false;
182+ }
183+ }
184+}
java/pkg/com/sun/tools/example/debug/bdi/LineBreakpointSpec.java+121−0
@@ -0,0 +1,121 @@
1+/*
2+ * Copyright (c) 1999, 2008, Oracle and/or its affiliates. All rights reserved.
3+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+ *
5+ * This code is free software; you can redistribute it and/or modify it
6+ * under the terms of the GNU General Public License version 2 only, as
7+ * published by the Free Software Foundation. Oracle designates this
8+ * particular file as subject to the "Classpath" exception as provided
9+ * by Oracle in the LICENSE file that accompanied this code.
10+ *
11+ * This code is distributed in the hope that it will be useful, but WITHOUT
12+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+ * version 2 for more details (a copy is included in the LICENSE file that
15+ * accompanied this code).
16+ *
17+ * You should have received a copy of the GNU General Public License version
18+ * 2 along with this work; if not, write to the Free Software Foundation,
19+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+ *
21+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+ * or visit www.oracle.com if you need additional information or have any
23+ * questions.
24+ */
25+
26+package com.sun.tools.example.debug.bdi;
27+
28+import com.sun.jdi.*;
29+import java.util.List;
30+
31+public class LineBreakpointSpec extends BreakpointSpec {
32+ int lineNumber;
33+
34+ LineBreakpointSpec(EventRequestSpecList specs,
35+ ReferenceTypeSpec refSpec, int lineNumber) {
36+ super(specs, refSpec);
37+ this.lineNumber = lineNumber;
38+ }
39+
40+ /**
41+ * The 'refType' is known to match.
42+ */
43+ @Override
44+ void resolve(ReferenceType refType) throws InvalidTypeException,
45+ LineNotFoundException {
46+ if (!(refType instanceof ClassType)) {
47+ throw new InvalidTypeException();
48+ }
49+ Location location = location((ClassType)refType);
50+ setRequest(refType.virtualMachine().eventRequestManager()
51+ .createBreakpointRequest(location));
52+ }
53+
54+ private Location location(ClassType clazz) throws
55+ LineNotFoundException {
56+ Location location = null;
57+ try {
58+ List<Location> locs = clazz.locationsOfLine(lineNumber());
59+ if (locs.size() == 0) {
60+ throw new LineNotFoundException();
61+ }
62+ // TODO handle multiple locations
63+ location = locs.get(0);
64+ if (location.method() == null) {
65+ throw new LineNotFoundException();
66+ }
67+ } catch (AbsentInformationException e) {
68+ /*
69+ * TO DO: throw something more specific, or allow
70+ * AbsentInfo exception to pass through.
71+ */
72+ throw new LineNotFoundException();
73+ }
74+ return location;
75+ }
76+
77+ public int lineNumber() {
78+ return lineNumber;
79+ }
80+
81+ @Override
82+ public int hashCode() {
83+ return refSpec.hashCode() + lineNumber;
84+ }
85+
86+ @Override
87+ public boolean equals(Object obj) {
88+ if (obj instanceof LineBreakpointSpec) {
89+ LineBreakpointSpec breakpoint = (LineBreakpointSpec)obj;
90+
91+ return refSpec.equals(breakpoint.refSpec) &&
92+ (lineNumber == breakpoint.lineNumber);
93+ } else {
94+ return false;
95+ }
96+ }
97+
98+ @Override
99+ public String errorMessageFor(Exception e) {
100+ if (e instanceof LineNotFoundException) {
101+ return ("No code at line " + lineNumber() + " in " + refSpec);
102+ } else if (e instanceof InvalidTypeException) {
103+ return ("Breakpoints can be located only in classes. " +
104+ refSpec + " is an interface or array");
105+ } else {
106+ return super.errorMessageFor( e);
107+ }
108+ }
109+
110+ @Override
111+ public String toString() {
112+ StringBuffer buffer = new StringBuffer("breakpoint ");
113+ buffer.append(refSpec.toString());
114+ buffer.append(':');
115+ buffer.append(lineNumber);
116+ buffer.append(" (");
117+ buffer.append(getStatusString());
118+ buffer.append(')');
119+ return buffer.toString();
120+ }
121+}
java/pkg/com/sun/tools/example/debug/bdi/LineNotFoundException.java+42−0
@@ -0,0 +1,42 @@
1+/*
2+ * Copyright (c) 1998, 1999, Oracle and/or its affiliates. All rights reserved.
3+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+ *
5+ * This code is free software; you can redistribute it and/or modify it
6+ * under the terms of the GNU General Public License version 2 only, as
7+ * published by the Free Software Foundation. Oracle designates this
8+ * particular file as subject to the "Classpath" exception as provided
9+ * by Oracle in the LICENSE file that accompanied this code.
10+ *
11+ * This code is distributed in the hope that it will be useful, but WITHOUT
12+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+ * version 2 for more details (a copy is included in the LICENSE file that
15+ * accompanied this code).
16+ *
17+ * You should have received a copy of the GNU General Public License version
18+ * 2 along with this work; if not, write to the Free Software Foundation,
19+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+ *
21+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+ * or visit www.oracle.com if you need additional information or have any
23+ * questions.
24+ */
25+
26+package com.sun.tools.example.debug.bdi;
27+
28+public class LineNotFoundException extends Exception
29+{
30+
31+ private static final long serialVersionUID = -5630418117861587582L;
32+
33+ public LineNotFoundException()
34+ {
35+ super();
36+ }
37+
38+ public LineNotFoundException(String s)
39+ {
40+ super(s);
41+ }
42+}
java/pkg/com/sun/tools/example/debug/bdi/MalformedMemberNameException.java+39−0
@@ -0,0 +1,39 @@
1+/*
2+ * Copyright (c) 1999, Oracle and/or its affiliates. All rights reserved.
3+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+ *
5+ * This code is free software; you can redistribute it and/or modify it
6+ * under the terms of the GNU General Public License version 2 only, as
7+ * published by the Free Software Foundation. Oracle designates this
8+ * particular file as subject to the "Classpath" exception as provided
9+ * by Oracle in the LICENSE file that accompanied this code.
10+ *
11+ * This code is distributed in the hope that it will be useful, but WITHOUT
12+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+ * version 2 for more details (a copy is included in the LICENSE file that
15+ * accompanied this code).
16+ *
17+ * You should have received a copy of the GNU General Public License version
18+ * 2 along with this work; if not, write to the Free Software Foundation,
19+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+ *
21+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+ * or visit www.oracle.com if you need additional information or have any
23+ * questions.
24+ */
25+
26+package com.sun.tools.example.debug.bdi;
27+
28+class MalformedMemberNameException extends Exception {
29+
30+ private static final long serialVersionUID = -7726664097374844485L;
31+
32+ public MalformedMemberNameException() {
33+ super();
34+ }
35+
36+ public MalformedMemberNameException(String s) {
37+ super(s);
38+ }
39+}
java/pkg/com/sun/tools/example/debug/bdi/MethodBreakpointSpec.java+337−0
@@ -0,0 +1,337 @@
1+/*
2+ * Copyright (c) 1999, 2008, Oracle and/or its affiliates. All rights reserved.
3+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+ *
5+ * This code is free software; you can redistribute it and/or modify it
6+ * under the terms of the GNU General Public License version 2 only, as
7+ * published by the Free Software Foundation. Oracle designates this
8+ * particular file as subject to the "Classpath" exception as provided
9+ * by Oracle in the LICENSE file that accompanied this code.
10+ *
11+ * This code is distributed in the hope that it will be useful, but WITHOUT
12+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+ * version 2 for more details (a copy is included in the LICENSE file that
15+ * accompanied this code).
16+ *
17+ * You should have received a copy of the GNU General Public License version
18+ * 2 along with this work; if not, write to the Free Software Foundation,
19+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+ *
21+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+ * or visit www.oracle.com if you need additional information or have any
23+ * questions.
24+ */
25+
26+package com.sun.tools.example.debug.bdi;
27+
28+import com.sun.jdi.*;
29+import java.util.ArrayList;
30+import java.util.List;
31+
32+public class MethodBreakpointSpec extends BreakpointSpec {
33+ String methodId;
34+ List<String> methodArgs;
35+
36+ MethodBreakpointSpec(EventRequestSpecList specs,
37+ ReferenceTypeSpec refSpec,
38+ String methodId, List<String> methodArgs) {
39+ super(specs, refSpec);
40+ this.methodId = methodId;
41+ this.methodArgs = methodArgs;
42+ }
43+
44+ /**
45+ * The 'refType' is known to match.
46+ */
47+ @Override
48+ void resolve(ReferenceType refType) throws MalformedMemberNameException,
49+ AmbiguousMethodException,
50+ InvalidTypeException,
51+ NoSuchMethodException,
52+ NoSessionException {
53+ if (!isValidMethodName(methodId)) {
54+ throw new MalformedMemberNameException(methodId);
55+ }
56+ if (!(refType instanceof ClassType)) {
57+ throw new InvalidTypeException();
58+ }
59+ Location location = location((ClassType)refType);
60+ setRequest(refType.virtualMachine().eventRequestManager()
61+ .createBreakpointRequest(location));
62+ }
63+
64+ private Location location(ClassType clazz) throws
65+ AmbiguousMethodException,
66+ NoSuchMethodException,
67+ NoSessionException {
68+ Method method = findMatchingMethod(clazz);
69+ Location location = method.location();
70+ return location;
71+ }
72+
73+ public String methodName() {
74+ return methodId;
75+ }
76+
77+ public List<String> methodArgs() {
78+ return methodArgs;
79+ }
80+
81+ @Override
82+ public int hashCode() {
83+ return refSpec.hashCode() +
84+ ((methodId != null) ? methodId.hashCode() : 0) +
85+ ((methodArgs != null) ? methodArgs.hashCode() : 0);
86+ }
87+
88+ @Override
89+ public boolean equals(Object obj) {
90+ if (obj instanceof MethodBreakpointSpec) {
91+ MethodBreakpointSpec breakpoint = (MethodBreakpointSpec)obj;
92+
93+ return methodId.equals(breakpoint.methodId) &&
94+ methodArgs.equals(breakpoint.methodArgs) &&
95+ refSpec.equals(breakpoint.refSpec);
96+ } else {
97+ return false;
98+ }
99+ }
100+
101+ @Override
102+ public String errorMessageFor(Exception e) {
103+ if (e instanceof AmbiguousMethodException) {
104+ return ("Method " + methodName() + " is overloaded; specify arguments");
105+ /*
106+ * TO DO: list the methods here
107+ */
108+ } else if (e instanceof NoSuchMethodException) {
109+ return ("No method " + methodName() + " in " + refSpec);
110+ } else if (e instanceof InvalidTypeException) {
111+ return ("Breakpoints can be located only in classes. " +
112+ refSpec + " is an interface or array");
113+ } else {
114+ return super.errorMessageFor( e);
115+ }
116+ }
117+
118+ @Override
119+ public String toString() {
120+ StringBuffer buffer = new StringBuffer("breakpoint ");
121+ buffer.append(refSpec.toString());
122+ buffer.append('.');
123+ buffer.append(methodId);
124+ if (methodArgs != null) {
125+ boolean first = true;
126+ buffer.append('(');
127+ for (String name : methodArgs) {
128+ if (!first) {
129+ buffer.append(',');
130+ }
131+ buffer.append(name);
132+ first = false;
133+ }
134+ buffer.append(")");
135+ }
136+ buffer.append(" (");
137+ buffer.append(getStatusString());
138+ buffer.append(')');
139+ return buffer.toString();
140+ }
141+
142+ private boolean isValidMethodName(String s) {
143+ return isJavaIdentifier(s) ||
144+ s.equals("<init>") ||
145+ s.equals("<clinit>");
146+ }
147+
148+ /*
149+ * Compare a method's argument types with a Vector of type names.
150+ * Return true if each argument type has a name identical to the
151+ * corresponding string in the vector (allowing for varargs)
152+ * and if the number of arguments in the method matches the
153+ * number of names passed
154+ */
155+ private boolean compareArgTypes(Method method, List<String> nameList) {
156+ List<String> argTypeNames = method.argumentTypeNames();
157+
158+ // If argument counts differ, we can stop here
159+ if (argTypeNames.size() != nameList.size()) {
160+ return false;
161+ }
162+
163+ // Compare each argument type's name
164+ int nTypes = argTypeNames.size();
165+ for (int i = 0; i < nTypes; ++i) {
166+ String comp1 = argTypeNames.get(i);
167+ String comp2 = nameList.get(i);
168+ if (! comp1.equals(comp2)) {
169+ /*
170+ * We have to handle varargs. EG, the
171+ * method's last arg type is xxx[]
172+ * while the nameList contains xxx...
173+ * Note that the nameList can also contain
174+ * xxx[] in which case we don't get here.
175+ */
176+ if (i != nTypes - 1 ||
177+ !method.isVarArgs() ||
178+ !comp2.endsWith("...")) {
179+ return false;
180+ }
181+ /*
182+ * The last types differ, it is a varargs
183+ * method and the nameList item is varargs.
184+ * We just have to compare the type names, eg,
185+ * make sure we don't have xxx[] for the method
186+ * arg type and yyy... for the nameList item.
187+ */
188+ int comp1Length = comp1.length();
189+ if (comp1Length + 1 != comp2.length()) {
190+ // The type names are different lengths
191+ return false;
192+ }
193+ // We know the two type names are the same length
194+ if (!comp1.regionMatches(0, comp2, 0, comp1Length - 2)) {
195+ return false;
196+ }
197+ // We do have xxx[] and xxx... as the last param type
198+ return true;
199+ }
200+ }
201+
202+ return true;
203+ }
204+
205+ private VirtualMachine vm() {
206+ return request.virtualMachine();
207+ }
208+
209+ /**
210+ * Remove unneeded spaces and expand class names to fully
211+ * qualified names, if necessary and possible.
212+ */
213+ private String normalizeArgTypeName(String name) throws NoSessionException {
214+ /*
215+ * Separate the type name from any array modifiers,
216+ * stripping whitespace after the name ends.
217+ */
218+ int i = 0;
219+ StringBuffer typePart = new StringBuffer();
220+ StringBuffer arrayPart = new StringBuffer();
221+ name = name.trim();
222+ int nameLength = name.length();
223+ /*
224+ * For varargs, there can be spaces before the ... but not
225+ * within the ... So, we will just ignore the ...
226+ * while stripping blanks.
227+ */
228+ boolean isVarArgs = name.endsWith("...");
229+ if (isVarArgs) {
230+ nameLength -= 3;
231+ }
232+
233+ while (i < nameLength) {
234+ char c = name.charAt(i);
235+ if (Character.isWhitespace(c) || c == '[') {
236+ break; // name is complete
237+ }
238+ typePart.append(c);
239+ i++;
240+ }
241+ while (i < nameLength) {
242+ char c = name.charAt(i);
243+ if ( (c == '[') || (c == ']')) {
244+ arrayPart.append(c);
245+ } else if (!Character.isWhitespace(c)) {
246+ throw new IllegalArgumentException(
247+ "Invalid argument type name");
248+
249+ }
250+ i++;
251+ }
252+
253+ name = typePart.toString();
254+
255+ /*
256+ * When there's no sign of a package name already,
257+ * try to expand the
258+ * the name to a fully qualified class name
259+ */
260+ if ((name.indexOf('.') == -1) || name.startsWith("*.")) {
261+ try {
262+ List<?> refs = specs.runtime.findClassesMatchingPattern(name);
263+ if (refs.size() > 0) { //### ambiguity???
264+ name = ((ReferenceType)(refs.get(0))).name();
265+ }
266+ } catch (IllegalArgumentException e) {
267+ // We'll try the name as is
268+ }
269+ }
270+ name += arrayPart.toString();
271+ if (isVarArgs) {
272+ name += "...";
273+ }
274+ return name;
275+ }
276+
277+ /*
278+ * Attempt an unambiguous match of the method name and
279+ * argument specification to a method. If no arguments
280+ * are specified, the method must not be overloaded.
281+ * Otherwise, the argument types much match exactly
282+ */
283+ private Method findMatchingMethod(ClassType clazz)
284+ throws AmbiguousMethodException,
285+ NoSuchMethodException,
286+ NoSessionException {
287+
288+ // Normalize the argument string once before looping below.
289+ List<String> argTypeNames = null;
290+ if (methodArgs() != null) {
291+ argTypeNames = new ArrayList<String>(methodArgs().size());
292+ for (String name : methodArgs()) {
293+ name = normalizeArgTypeName(name);
294+ argTypeNames.add(name);
295+ }
296+ }
297+
298+ // Check each method in the class for matches
299+ Method firstMatch = null; // first method with matching name
300+ Method exactMatch = null; // (only) method with same name & sig
301+ int matchCount = 0; // > 1 implies overload
302+ for (Method candidate : clazz.methods()) {
303+ if (candidate.name().equals(methodName())) {
304+ matchCount++;
305+
306+ // Remember the first match in case it is the only one
307+ if (matchCount == 1) {
308+ firstMatch = candidate;
309+ }
310+
311+ // If argument types were specified, check against candidate
312+ if ((argTypeNames != null)
313+ && compareArgTypes(candidate, argTypeNames) == true) {
314+ exactMatch = candidate;
315+ break;
316+ }
317+ }
318+ }
319+
320+ // Determine method for breakpoint
321+ Method method = null;
322+ if (exactMatch != null) {
323+ // Name and signature match
324+ method = exactMatch;
325+ } else if ((argTypeNames == null) && (matchCount > 0)) {
326+ // At least one name matched and no arg types were specified
327+ if (matchCount == 1) {
328+ method = firstMatch; // Only one match; safe to use it
329+ } else {
330+ throw new AmbiguousMethodException();
331+ }
332+ } else {
333+ throw new NoSuchMethodException(methodName());
334+ }
335+ return method;
336+ }
337+}
java/pkg/com/sun/tools/example/debug/bdi/MethodNotFoundException.java+41−0
@@ -0,0 +1,41 @@
1+/*
2+ * Copyright (c) 1998, 1999, Oracle and/or its affiliates. All rights reserved.
3+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+ *
5+ * This code is free software; you can redistribute it and/or modify it
6+ * under the terms of the GNU General Public License version 2 only, as
7+ * published by the Free Software Foundation. Oracle designates this
8+ * particular file as subject to the "Classpath" exception as provided
9+ * by Oracle in the LICENSE file that accompanied this code.
10+ *
11+ * This code is distributed in the hope that it will be useful, but WITHOUT
12+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+ * version 2 for more details (a copy is included in the LICENSE file that
15+ * accompanied this code).
16+ *
17+ * You should have received a copy of the GNU General Public License version
18+ * 2 along with this work; if not, write to the Free Software Foundation,
19+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+ *
21+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+ * or visit www.oracle.com if you need additional information or have any
23+ * questions.
24+ */
25+
26+package com.sun.tools.example.debug.bdi;
27+
28+public class MethodNotFoundException extends Exception
29+{
30+ private static final long serialVersionUID = -2064968107599632609L;
31+
32+ public MethodNotFoundException()
33+ {
34+ super();
35+ }
36+
37+ public MethodNotFoundException(String s)
38+ {
39+ super(s);
40+ }
41+}
java/pkg/com/sun/tools/example/debug/bdi/ModificationWatchpointSpec.java+59−0
@@ -0,0 +1,59 @@
1+/*
2+ * Copyright (c) 1999, Oracle and/or its affiliates. All rights reserved.
3+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+ *
5+ * This code is free software; you can redistribute it and/or modify it
6+ * under the terms of the GNU General Public License version 2 only, as
7+ * published by the Free Software Foundation. Oracle designates this
8+ * particular file as subject to the "Classpath" exception as provided
9+ * by Oracle in the LICENSE file that accompanied this code.
10+ *
11+ * This code is distributed in the hope that it will be useful, but WITHOUT
12+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+ * version 2 for more details (a copy is included in the LICENSE file that
15+ * accompanied this code).
16+ *
17+ * You should have received a copy of the GNU General Public License version
18+ * 2 along with this work; if not, write to the Free Software Foundation,
19+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+ *
21+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+ * or visit www.oracle.com if you need additional information or have any
23+ * questions.
24+ */
25+
26+package com.sun.tools.example.debug.bdi;
27+
28+import com.sun.jdi.*;
29+
30+public class ModificationWatchpointSpec extends WatchpointSpec {
31+
32+ ModificationWatchpointSpec(EventRequestSpecList specs,
33+ ReferenceTypeSpec refSpec, String fieldId) {
34+ super(specs, refSpec, fieldId);
35+ }
36+
37+ /**
38+ * The 'refType' is known to match.
39+ */
40+ @Override
41+ void resolve(ReferenceType refType) throws InvalidTypeException,
42+ NoSuchFieldException {
43+ if (!(refType instanceof ClassType)) {
44+ throw new InvalidTypeException();
45+ }
46+ Field field = refType.fieldByName(fieldId);
47+ if (field == null) {
48+ throw new NoSuchFieldException(fieldId);
49+ }
50+ setRequest(refType.virtualMachine().eventRequestManager()
51+ .createModificationWatchpointRequest(field));
52+ }
53+
54+ @Override
55+ public boolean equals(Object obj) {
56+ return (obj instanceof ModificationWatchpointSpec) &&
57+ super.equals(obj);
58+ }
59+}
java/pkg/com/sun/tools/example/debug/bdi/NoSessionException.java+31−0
@@ -0,0 +1,31 @@
1+/*
2+ * Copyright (c) 1998, 1999, Oracle and/or its affiliates. All rights reserved.
3+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+ *
5+ * This code is free software; you can redistribute it and/or modify it
6+ * under the terms of the GNU General Public License version 2 only, as
7+ * published by the Free Software Foundation. Oracle designates this
8+ * particular file as subject to the "Classpath" exception as provided
9+ * by Oracle in the LICENSE file that accompanied this code.
10+ *
11+ * This code is distributed in the hope that it will be useful, but WITHOUT
12+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+ * version 2 for more details (a copy is included in the LICENSE file that
15+ * accompanied this code).
16+ *
17+ * You should have received a copy of the GNU General Public License version
18+ * 2 along with this work; if not, write to the Free Software Foundation,
19+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+ *
21+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+ * or visit www.oracle.com if you need additional information or have any
23+ * questions.
24+ */
25+
26+package com.sun.tools.example.debug.bdi;
27+
28+public class NoSessionException extends Exception {
29+
30+ private static final long serialVersionUID = -7324357828115128603L;
31+}
java/pkg/com/sun/tools/example/debug/bdi/NoThreadException.java+32−0
@@ -0,0 +1,32 @@
1+/*
2+ * Copyright (c) 1998, 1999, Oracle and/or its affiliates. All rights reserved.
3+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+ *
5+ * This code is free software; you can redistribute it and/or modify it
6+ * under the terms of the GNU General Public License version 2 only, as
7+ * published by the Free Software Foundation. Oracle designates this
8+ * particular file as subject to the "Classpath" exception as provided
9+ * by Oracle in the LICENSE file that accompanied this code.
10+ *
11+ * This code is distributed in the hope that it will be useful, but WITHOUT
12+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+ * version 2 for more details (a copy is included in the LICENSE file that
15+ * accompanied this code).
16+ *
17+ * You should have received a copy of the GNU General Public License version
18+ * 2 along with this work; if not, write to the Free Software Foundation,
19+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+ *
21+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+ * or visit www.oracle.com if you need additional information or have any
23+ * questions.
24+ */
25+
26+package com.sun.tools.example.debug.bdi;
27+
28+public class NoThreadException extends Exception {
29+
30+ private static final long serialVersionUID = 1846613539928921998L;
31+
32+}
java/pkg/com/sun/tools/example/debug/bdi/OutputListener.java+31−0
@@ -0,0 +1,31 @@
1+/*
2+ * Copyright (c) 1998, 1999, Oracle and/or its affiliates. All rights reserved.
3+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+ *
5+ * This code is free software; you can redistribute it and/or modify it
6+ * under the terms of the GNU General Public License version 2 only, as
7+ * published by the Free Software Foundation. Oracle designates this
8+ * particular file as subject to the "Classpath" exception as provided
9+ * by Oracle in the LICENSE file that accompanied this code.
10+ *
11+ * This code is distributed in the hope that it will be useful, but WITHOUT
12+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+ * version 2 for more details (a copy is included in the LICENSE file that
15+ * accompanied this code).
16+ *
17+ * You should have received a copy of the GNU General Public License version
18+ * 2 along with this work; if not, write to the Free Software Foundation,
19+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+ *
21+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+ * or visit www.oracle.com if you need additional information or have any
23+ * questions.
24+ */
25+
26+package com.sun.tools.example.debug.bdi;
27+
28+public interface OutputListener {
29+ void putString(String str);
30+ //void putLine(String line);
31+}
java/pkg/com/sun/tools/example/debug/bdi/ParseException.java+30−0
@@ -0,0 +1,30 @@
1+/*
2+ * Copyright (c) 1998, 1999, Oracle and/or its affiliates. All rights reserved.
3+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+ *
5+ * This code is free software; you can redistribute it and/or modify it
6+ * under the terms of the GNU General Public License version 2 only, as
7+ * published by the Free Software Foundation. Oracle designates this
8+ * particular file as subject to the "Classpath" exception as provided
9+ * by Oracle in the LICENSE file that accompanied this code.
10+ *
11+ * This code is distributed in the hope that it will be useful, but WITHOUT
12+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+ * version 2 for more details (a copy is included in the LICENSE file that
15+ * accompanied this code).
16+ *
17+ * You should have received a copy of the GNU General Public License version
18+ * 2 along with this work; if not, write to the Free Software Foundation,
19+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+ *
21+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+ * or visit www.oracle.com if you need additional information or have any
23+ * questions.
24+ */
25+
26+package com.sun.tools.example.debug.bdi;
27+
28+// dummy placeholder for javaCC-generated code.
29+
30+public class ParseException extends Exception {}
java/pkg/com/sun/tools/example/debug/bdi/PatternReferenceTypeSpec.java+99−0
@@ -0,0 +1,99 @@
1+/*
2+ * Copyright (c) 1999, 2003, Oracle and/or its affiliates. All rights reserved.
3+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+ *
5+ * This code is free software; you can redistribute it and/or modify it
6+ * under the terms of the GNU General Public License version 2 only, as
7+ * published by the Free Software Foundation. Oracle designates this
8+ * particular file as subject to the "Classpath" exception as provided
9+ * by Oracle in the LICENSE file that accompanied this code.
10+ *
11+ * This code is distributed in the hope that it will be useful, but WITHOUT
12+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+ * version 2 for more details (a copy is included in the LICENSE file that
15+ * accompanied this code).
16+ *
17+ * You should have received a copy of the GNU General Public License version
18+ * 2 along with this work; if not, write to the Free Software Foundation,
19+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+ *
21+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+ * or visit www.oracle.com if you need additional information or have any
23+ * questions.
24+ */
25+
26+package com.sun.tools.example.debug.bdi;
27+
28+import com.sun.jdi.*;
29+import java.util.StringTokenizer;
30+
31+class PatternReferenceTypeSpec implements ReferenceTypeSpec {
32+ final boolean isWild;
33+ final String classId;
34+
35+ PatternReferenceTypeSpec(String classId)
36+// throws ClassNotFoundException
37+ {
38+// checkClassName(classId);
39+ isWild = classId.startsWith("*.");
40+ if (isWild) {
41+ this.classId = classId.substring(1);
42+ } else {
43+ this.classId = classId;
44+ }
45+ }
46+
47+ /**
48+ * Does the specified ReferenceType match this spec.
49+ */
50+ @Override
51+ public boolean matches(ReferenceType refType) {
52+ if (isWild) {
53+ return refType.name().endsWith(classId);
54+ } else {
55+ return refType.name().equals(classId);
56+ }
57+ }
58+
59+ @Override
60+ public int hashCode() {
61+ return classId.hashCode();
62+ }
63+
64+ @Override
65+ public boolean equals(Object obj) {
66+ if (obj instanceof PatternReferenceTypeSpec) {
67+ PatternReferenceTypeSpec spec = (PatternReferenceTypeSpec)obj;
68+
69+ return classId.equals(spec.classId) && (isWild == spec.isWild);
70+ } else {
71+ return false;
72+ }
73+ }
74+
75+ private void checkClassName(String className) throws ClassNotFoundException {
76+ // Do stricter checking of class name validity on deferred
77+ // because if the name is invalid, it will
78+ // never match a future loaded class, and we'll be silent
79+ // about it.
80+ StringTokenizer tokenizer = new StringTokenizer(className, ".");
81+ boolean first = true;
82+ while (tokenizer.hasMoreTokens()) {
83+ String token = tokenizer.nextToken();
84+ // Each dot-separated piece must be a valid identifier
85+ // and the first token can also be "*". (Note that
86+ // numeric class ids are not permitted. They must
87+ // match a loaded class.)
88+ if (!Utils.isJavaIdentifier(token) && !(first && token.equals("*"))) {
89+ throw new ClassNotFoundException();
90+ }
91+ first = false;
92+ }
93+ }
94+
95+ @Override
96+ public String toString() {
97+ return isWild? "*" + classId : classId;
98+ }
99+}
java/pkg/com/sun/tools/example/debug/bdi/ReferenceTypeSpec.java+41−0
@@ -0,0 +1,41 @@
1+/*
2+ * Copyright (c) 1999, Oracle and/or its affiliates. All rights reserved.
3+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+ *
5+ * This code is free software; you can redistribute it and/or modify it
6+ * under the terms of the GNU General Public License version 2 only, as
7+ * published by the Free Software Foundation. Oracle designates this
8+ * particular file as subject to the "Classpath" exception as provided
9+ * by Oracle in the LICENSE file that accompanied this code.
10+ *
11+ * This code is distributed in the hope that it will be useful, but WITHOUT
12+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+ * version 2 for more details (a copy is included in the LICENSE file that
15+ * accompanied this code).
16+ *
17+ * You should have received a copy of the GNU General Public License version
18+ * 2 along with this work; if not, write to the Free Software Foundation,
19+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+ *
21+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+ * or visit www.oracle.com if you need additional information or have any
23+ * questions.
24+ */
25+
26+package com.sun.tools.example.debug.bdi;
27+
28+import com.sun.jdi.*;
29+
30+interface ReferenceTypeSpec {
31+ /**
32+ * Does the specified ReferenceType match this spec.
33+ */
34+ boolean matches(ReferenceType refType);
35+
36+ @Override
37+ int hashCode();
38+
39+ @Override
40+ boolean equals(Object obj);
41+}
java/pkg/com/sun/tools/example/debug/bdi/Session.java+96−0
@@ -0,0 +1,96 @@
1+/*
2+ * Copyright (c) 1998, 1999, Oracle and/or its affiliates. All rights reserved.
3+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+ *
5+ * This code is free software; you can redistribute it and/or modify it
6+ * under the terms of the GNU General Public License version 2 only, as
7+ * published by the Free Software Foundation. Oracle designates this
8+ * particular file as subject to the "Classpath" exception as provided
9+ * by Oracle in the LICENSE file that accompanied this code.
10+ *
11+ * This code is distributed in the hope that it will be useful, but WITHOUT
12+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+ * version 2 for more details (a copy is included in the LICENSE file that
15+ * accompanied this code).
16+ *
17+ * You should have received a copy of the GNU General Public License version
18+ * 2 along with this work; if not, write to the Free Software Foundation,
19+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+ *
21+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+ * or visit www.oracle.com if you need additional information or have any
23+ * questions.
24+ */
25+
26+package com.sun.tools.example.debug.bdi;
27+
28+import com.sun.jdi.VirtualMachine;
29+import com.sun.jdi.VMDisconnectedException;
30+
31+/**
32+ * Our repository of what we know about the state of one
33+ * running VM.
34+ */
35+class Session {
36+
37+ final VirtualMachine vm;
38+ final ExecutionManager runtime;
39+ final OutputListener diagnostics;
40+
41+ boolean running = true; // Set false by JDIEventSource
42+ boolean interrupted = false; // Set false by JDIEventSource
43+
44+ private JDIEventSource eventSourceThread = null;
45+ private int traceFlags;
46+ private boolean dead = false;
47+
48+ public Session(VirtualMachine vm, ExecutionManager runtime,
49+ OutputListener diagnostics) {
50+ this.vm = vm;
51+ this.runtime = runtime;
52+ this.diagnostics = diagnostics;
53+ this.traceFlags = VirtualMachine.TRACE_NONE;
54+ }
55+
56+ /**
57+ * Determine if VM is interrupted, i.e, present and not running.
58+ */
59+ public boolean isInterrupted() {
60+ return interrupted;
61+ }
62+
63+ public void setTraceMode(int traceFlags) {
64+ this.traceFlags = traceFlags;
65+ if (!dead) {
66+ vm.setDebugTraceMode(traceFlags);
67+ }
68+ }
69+
70+ public boolean attach() {
71+ vm.setDebugTraceMode(traceFlags);
72+ diagnostics.putString("Connected to VM");
73+ eventSourceThread = new JDIEventSource(this);
74+ eventSourceThread.start();
75+ return true;
76+ }
77+
78+ public void detach() {
79+ if (!dead) {
80+ eventSourceThread.interrupt();
81+ eventSourceThread = null;
82+ //### The VM may already be disconnected
83+ //### if the debuggee did a System.exit().
84+ //### Exception handler here is a kludge,
85+ //### Rather, there are many other places
86+ //### where we need to handle this exception,
87+ //### and initiate a detach due to an error
88+ //### condition, e.g., connection failure.
89+ try {
90+ vm.dispose();
91+ } catch (VMDisconnectedException ee) {}
92+ dead = true;
93+ diagnostics.putString("Disconnected from VM");
94+ }
95+ }
96+}
java/pkg/com/sun/tools/example/debug/bdi/SessionListener.java+37−0
@@ -0,0 +1,37 @@
1+/*
2+ * Copyright (c) 1999, Oracle and/or its affiliates. All rights reserved.
3+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+ *
5+ * This code is free software; you can redistribute it and/or modify it
6+ * under the terms of the GNU General Public License version 2 only, as
7+ * published by the Free Software Foundation. Oracle designates this
8+ * particular file as subject to the "Classpath" exception as provided
9+ * by Oracle in the LICENSE file that accompanied this code.
10+ *
11+ * This code is distributed in the hope that it will be useful, but WITHOUT
12+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+ * version 2 for more details (a copy is included in the LICENSE file that
15+ * accompanied this code).
16+ *
17+ * You should have received a copy of the GNU General Public License version
18+ * 2 along with this work; if not, write to the Free Software Foundation,
19+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+ *
21+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+ * or visit www.oracle.com if you need additional information or have any
23+ * questions.
24+ */
25+
26+package com.sun.tools.example.debug.bdi;
27+
28+import java.util.EventObject;
29+import java.util.EventListener;
30+
31+public interface SessionListener extends EventListener {
32+
33+ void sessionStart(EventObject e);
34+
35+ void sessionInterrupt(EventObject e);
36+ void sessionContinue(EventObject e);
37+}
java/pkg/com/sun/tools/example/debug/bdi/SourceNameReferenceTypeSpec.java+81−0
@@ -0,0 +1,81 @@
1+/*
2+ * Copyright (c) 1999, Oracle and/or its affiliates. All rights reserved.
3+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+ *
5+ * This code is free software; you can redistribute it and/or modify it
6+ * under the terms of the GNU General Public License version 2 only, as
7+ * published by the Free Software Foundation. Oracle designates this
8+ * particular file as subject to the "Classpath" exception as provided
9+ * by Oracle in the LICENSE file that accompanied this code.
10+ *
11+ * This code is distributed in the hope that it will be useful, but WITHOUT
12+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+ * version 2 for more details (a copy is included in the LICENSE file that
15+ * accompanied this code).
16+ *
17+ * You should have received a copy of the GNU General Public License version
18+ * 2 along with this work; if not, write to the Free Software Foundation,
19+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+ *
21+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+ * or visit www.oracle.com if you need additional information or have any
23+ * questions.
24+ */
25+
26+package com.sun.tools.example.debug.bdi;
27+
28+import com.sun.jdi.*;
29+
30+class SourceNameReferenceTypeSpec implements ReferenceTypeSpec {
31+ final String sourceName;
32+ final int linenumber;
33+
34+ SourceNameReferenceTypeSpec(String sourceName, int linenumber) {
35+ this.sourceName = sourceName;
36+ this.linenumber = linenumber;
37+ }
38+
39+ /**
40+ * Does the specified ReferenceType match this spec.
41+ */
42+ @Override
43+ public boolean matches(ReferenceType refType) {
44+ try {
45+ if (refType.sourceName().equals(sourceName)) {
46+ try {
47+ refType.locationsOfLine(linenumber);
48+ // if we don't throw an exception then it was found
49+ return true;
50+ } catch(AbsentInformationException exc) {
51+ } catch(ObjectCollectedException exc) {
52+ }
53+ }
54+ } catch(AbsentInformationException exc) {
55+ // for sourceName(), fall through
56+ }
57+ return false;
58+ }
59+
60+ @Override
61+ public int hashCode() {
62+ return sourceName.hashCode() + linenumber;
63+ }
64+
65+ @Override
66+ public boolean equals(Object obj) {
67+ if (obj instanceof SourceNameReferenceTypeSpec) {
68+ SourceNameReferenceTypeSpec spec = (SourceNameReferenceTypeSpec)obj;
69+
70+ return sourceName.equals(spec.sourceName) &&
71+ (linenumber == spec.linenumber);
72+ } else {
73+ return false;
74+ }
75+ }
76+
77+ @Override
78+ public String toString() {
79+ return sourceName + "@" + linenumber;
80+ }
81+}
java/pkg/com/sun/tools/example/debug/bdi/SpecErrorEvent.java+42−0
@@ -0,0 +1,42 @@
1+/*
2+ * Copyright (c) 1999, Oracle and/or its affiliates. All rights reserved.
3+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+ *
5+ * This code is free software; you can redistribute it and/or modify it
6+ * under the terms of the GNU General Public License version 2 only, as
7+ * published by the Free Software Foundation. Oracle designates this
8+ * particular file as subject to the "Classpath" exception as provided
9+ * by Oracle in the LICENSE file that accompanied this code.
10+ *
11+ * This code is distributed in the hope that it will be useful, but WITHOUT
12+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+ * version 2 for more details (a copy is included in the LICENSE file that
15+ * accompanied this code).
16+ *
17+ * You should have received a copy of the GNU General Public License version
18+ * 2 along with this work; if not, write to the Free Software Foundation,
19+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+ *
21+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+ * or visit www.oracle.com if you need additional information or have any
23+ * questions.
24+ */
25+
26+package com.sun.tools.example.debug.bdi;
27+
28+public class SpecErrorEvent extends SpecEvent {
29+
30+ private static final long serialVersionUID = 8162634387866409578L;
31+ private Exception reason;
32+
33+ public SpecErrorEvent(EventRequestSpec eventRequestSpec,
34+ Exception reason) {
35+ super(eventRequestSpec);
36+ this.reason = reason;
37+ }
38+
39+ public Exception getReason() {
40+ return reason;
41+ }
42+}
java/pkg/com/sun/tools/example/debug/bdi/SpecEvent.java+49−0
@@ -0,0 +1,49 @@
1+/*
2+ * Copyright (c) 1999, Oracle and/or its affiliates. All rights reserved.
3+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+ *
5+ * This code is free software; you can redistribute it and/or modify it
6+ * under the terms of the GNU General Public License version 2 only, as
7+ * published by the Free Software Foundation. Oracle designates this
8+ * particular file as subject to the "Classpath" exception as provided
9+ * by Oracle in the LICENSE file that accompanied this code.
10+ *
11+ * This code is distributed in the hope that it will be useful, but WITHOUT
12+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+ * version 2 for more details (a copy is included in the LICENSE file that
15+ * accompanied this code).
16+ *
17+ * You should have received a copy of the GNU General Public License version
18+ * 2 along with this work; if not, write to the Free Software Foundation,
19+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+ *
21+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+ * or visit www.oracle.com if you need additional information or have any
23+ * questions.
24+ */
25+
26+package com.sun.tools.example.debug.bdi;
27+
28+import java.util.EventObject;
29+
30+import com.sun.jdi.request.EventRequest;
31+
32+public class SpecEvent extends EventObject {
33+
34+ private static final long serialVersionUID = 4820735456787276230L;
35+ private EventRequestSpec eventRequestSpec;
36+
37+ public SpecEvent(EventRequestSpec eventRequestSpec) {
38+ super(eventRequestSpec.specs);
39+ this.eventRequestSpec = eventRequestSpec;
40+ }
41+
42+ public EventRequestSpec getEventRequestSpec() {
43+ return eventRequestSpec;
44+ }
45+
46+ public EventRequest getEventRequest() {
47+ return eventRequestSpec.getEventRequest();
48+ }
49+}
java/pkg/com/sun/tools/example/debug/bdi/SpecListener.java+49−0
@@ -0,0 +1,49 @@
1+/*
2+ * Copyright (c) 1999, Oracle and/or its affiliates. All rights reserved.
3+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+ *
5+ * This code is free software; you can redistribute it and/or modify it
6+ * under the terms of the GNU General Public License version 2 only, as
7+ * published by the Free Software Foundation. Oracle designates this
8+ * particular file as subject to the "Classpath" exception as provided
9+ * by Oracle in the LICENSE file that accompanied this code.
10+ *
11+ * This code is distributed in the hope that it will be useful, but WITHOUT
12+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+ * version 2 for more details (a copy is included in the LICENSE file that
15+ * accompanied this code).
16+ *
17+ * You should have received a copy of the GNU General Public License version
18+ * 2 along with this work; if not, write to the Free Software Foundation,
19+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+ *
21+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+ * or visit www.oracle.com if you need additional information or have any
23+ * questions.
24+ */
25+
26+package com.sun.tools.example.debug.bdi;
27+
28+import java.util.EventListener;
29+
30+public interface SpecListener extends EventListener {
31+
32+ void breakpointSet(SpecEvent e);
33+ void breakpointDeferred(SpecEvent e);
34+ void breakpointDeleted(SpecEvent e);
35+ void breakpointResolved(SpecEvent e);
36+ void breakpointError(SpecErrorEvent e);
37+
38+ void watchpointSet(SpecEvent e);
39+ void watchpointDeferred(SpecEvent e);
40+ void watchpointDeleted(SpecEvent e);
41+ void watchpointResolved(SpecEvent e);
42+ void watchpointError(SpecErrorEvent e);
43+
44+ void exceptionInterceptSet(SpecEvent e);
45+ void exceptionInterceptDeferred(SpecEvent e);
46+ void exceptionInterceptDeleted(SpecEvent e);
47+ void exceptionInterceptResolved(SpecEvent e);
48+ void exceptionInterceptError(SpecErrorEvent e);
49+}
java/pkg/com/sun/tools/example/debug/bdi/ThreadGroupIterator.java+108−0
@@ -0,0 +1,108 @@
1+/*
2+ * Copyright (c) 1998, 2008, Oracle and/or its affiliates. All rights reserved.
3+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+ *
5+ * This code is free software; you can redistribute it and/or modify it
6+ * under the terms of the GNU General Public License version 2 only, as
7+ * published by the Free Software Foundation. Oracle designates this
8+ * particular file as subject to the "Classpath" exception as provided
9+ * by Oracle in the LICENSE file that accompanied this code.
10+ *
11+ * This code is distributed in the hope that it will be useful, but WITHOUT
12+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+ * version 2 for more details (a copy is included in the LICENSE file that
15+ * accompanied this code).
16+ *
17+ * You should have received a copy of the GNU General Public License version
18+ * 2 along with this work; if not, write to the Free Software Foundation,
19+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+ *
21+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+ * or visit www.oracle.com if you need additional information or have any
23+ * questions.
24+ */
25+
26+package com.sun.tools.example.debug.bdi;
27+
28+import com.sun.jdi.ThreadGroupReference;
29+import java.util.List;
30+import java.util.Stack;
31+import java.util.ArrayList;
32+import java.util.Iterator;
33+
34+/**
35+ * Descend the tree of thread groups.
36+ * @author Robert G. Field
37+ */
38+public class ThreadGroupIterator implements Iterator<ThreadGroupReference> {
39+ private final Stack<Iterator<ThreadGroupReference>> stack
40+ = new Stack<Iterator<ThreadGroupReference>>();
41+
42+ public ThreadGroupIterator(List<ThreadGroupReference> tgl) {
43+ push(tgl);
44+ }
45+
46+ public ThreadGroupIterator(ThreadGroupReference tg) {
47+ List<ThreadGroupReference> tgl = new ArrayList<ThreadGroupReference>();
48+ tgl.add(tg);
49+ push(tgl);
50+ }
51+
52+/*
53+ ThreadGroupIterator() {
54+ this(Env.vm().topLevelThreadGroups());
55+ }
56+*/
57+
58+ private Iterator<ThreadGroupReference> top() {
59+ return stack.peek();
60+ }
61+
62+ /**
63+ * The invariant in this class is that the top iterator
64+ * on the stack has more elements. If the stack is
65+ * empty, there is no top. This method assures
66+ * this invariant.
67+ */
68+ private void push(List<ThreadGroupReference> tgl) {
69+ stack.push(tgl.iterator());
70+ while (!stack.isEmpty() && !top().hasNext()) {
71+ stack.pop();
72+ }
73+ }
74+
75+ @Override
76+ public boolean hasNext() {
77+ return !stack.isEmpty();
78+ }
79+
80+ @Override
81+ public ThreadGroupReference next() {
82+ return nextThreadGroup();
83+ }
84+
85+ public ThreadGroupReference nextThreadGroup() {
86+ ThreadGroupReference tg = top().next();
87+ push(tg.threadGroups());
88+ return tg;
89+ }
90+
91+ @Override
92+ public void remove() {
93+ throw new UnsupportedOperationException();
94+ }
95+
96+/*
97+ static ThreadGroupReference find(String name) {
98+ ThreadGroupIterator tgi = new ThreadGroupIterator();
99+ while (tgi.hasNext()) {
100+ ThreadGroupReference tg = tgi.nextThreadGroup();
101+ if (tg.name().equals(name)) {
102+ return tg;
103+ }
104+ }
105+ return null;
106+ }
107+*/
108+}
java/pkg/com/sun/tools/example/debug/bdi/ThreadInfo.java+117−0
@@ -0,0 +1,117 @@
1+/*
2+ * Copyright (c) 1998, 2002, Oracle and/or its affiliates. All rights reserved.
3+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+ *
5+ * This code is free software; you can redistribute it and/or modify it
6+ * under the terms of the GNU General Public License version 2 only, as
7+ * published by the Free Software Foundation. Oracle designates this
8+ * particular file as subject to the "Classpath" exception as provided
9+ * by Oracle in the LICENSE file that accompanied this code.
10+ *
11+ * This code is distributed in the hope that it will be useful, but WITHOUT
12+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+ * version 2 for more details (a copy is included in the LICENSE file that
15+ * accompanied this code).
16+ *
17+ * You should have received a copy of the GNU General Public License version
18+ * 2 along with this work; if not, write to the Free Software Foundation,
19+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+ *
21+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+ * or visit www.oracle.com if you need additional information or have any
23+ * questions.
24+ */
25+
26+package com.sun.tools.example.debug.bdi;
27+
28+import com.sun.jdi.*;
29+
30+//### Should handle target VM death or connection failure cleanly.
31+
32+public class ThreadInfo {
33+
34+ private ThreadReference thread;
35+ private int status;
36+
37+ private int frameCount;
38+
39+ Object userObject; // User-supplied annotation.
40+
41+ private boolean interrupted = false;
42+
43+ private void assureInterrupted() throws VMNotInterruptedException {
44+ if (!interrupted) {
45+ throw new VMNotInterruptedException();
46+ }
47+ }
48+
49+ ThreadInfo (ThreadReference thread) {
50+ this.thread = thread;
51+ this.frameCount = -1;
52+ }
53+
54+ public ThreadReference thread() {
55+ return thread;
56+ }
57+
58+ public int getStatus() throws VMNotInterruptedException {
59+ assureInterrupted();
60+ update();
61+ return status;
62+ }
63+
64+ public int getFrameCount() throws VMNotInterruptedException {
65+ assureInterrupted();
66+ update();
67+ return frameCount;
68+ }
69+
70+ public StackFrame getFrame(int index) throws VMNotInterruptedException {
71+ assureInterrupted();
72+ update();
73+ try {
74+ return thread.frame(index);
75+ } catch (IncompatibleThreadStateException e) {
76+ // Should not happen
77+ interrupted = false;
78+ throw new VMNotInterruptedException();
79+ }
80+ }
81+
82+ public Object getUserObject() {
83+ return userObject;
84+ }
85+
86+ public void setUserObject(Object obj) {
87+ userObject = obj;
88+ }
89+
90+ // Refresh upon first access after cache is cleared.
91+
92+ void update() throws VMNotInterruptedException {
93+ if (frameCount == -1) {
94+ try {
95+ status = thread.status();
96+ frameCount = thread.frameCount();
97+ } catch (IncompatibleThreadStateException e) {
98+ // Should not happen
99+ interrupted = false;
100+ throw new VMNotInterruptedException();
101+ }
102+ }
103+ }
104+
105+ // Called from 'ExecutionManager'.
106+
107+ void validate() {
108+ interrupted = true;
109+ }
110+
111+ void invalidate() {
112+ interrupted = false;
113+ frameCount = -1;
114+ status = ThreadReference.THREAD_STATUS_UNKNOWN;
115+ }
116+
117+}
java/pkg/com/sun/tools/example/debug/bdi/ThreadIterator.java+70−0
@@ -0,0 +1,70 @@
1+/*
2+ * Copyright (c) 1998, 2008, Oracle and/or its affiliates. All rights reserved.
3+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+ *
5+ * This code is free software; you can redistribute it and/or modify it
6+ * under the terms of the GNU General Public License version 2 only, as
7+ * published by the Free Software Foundation. Oracle designates this
8+ * particular file as subject to the "Classpath" exception as provided
9+ * by Oracle in the LICENSE file that accompanied this code.
10+ *
11+ * This code is distributed in the hope that it will be useful, but WITHOUT
12+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+ * version 2 for more details (a copy is included in the LICENSE file that
15+ * accompanied this code).
16+ *
17+ * You should have received a copy of the GNU General Public License version
18+ * 2 along with this work; if not, write to the Free Software Foundation,
19+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+ *
21+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+ * or visit www.oracle.com if you need additional information or have any
23+ * questions.
24+ */
25+
26+package com.sun.tools.example.debug.bdi;
27+
28+import com.sun.jdi.ThreadGroupReference;
29+import com.sun.jdi.ThreadReference;
30+import java.util.List;
31+import java.util.Iterator;
32+
33+public class ThreadIterator implements Iterator<ThreadReference> {
34+ Iterator<ThreadReference> it = null;
35+ ThreadGroupIterator tgi;
36+
37+ public ThreadIterator(ThreadGroupReference tg) {
38+ tgi = new ThreadGroupIterator(tg);
39+ }
40+
41+ //### make this package access only?
42+ public ThreadIterator(List<ThreadGroupReference> tgl) {
43+ tgi = new ThreadGroupIterator(tgl);
44+ }
45+
46+ @Override
47+ public boolean hasNext() {
48+ while (it == null || !it.hasNext()) {
49+ if (!tgi.hasNext()) {
50+ return false; // no more
51+ }
52+ it = tgi.nextThreadGroup().threads().iterator();
53+ }
54+ return true;
55+ }
56+
57+ @Override
58+ public ThreadReference next() {
59+ return it.next();
60+ }
61+
62+ public ThreadReference nextThread() {
63+ return next();
64+ }
65+
66+ @Override
67+ public void remove() {
68+ throw new UnsupportedOperationException();
69+ }
70+}
java/pkg/com/sun/tools/example/debug/bdi/Utils.java+181−0
@@ -0,0 +1,181 @@
1+/*
2+ * Copyright (c) 1998, 2003, Oracle and/or its affiliates. All rights reserved.
3+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+ *
5+ * This code is free software; you can redistribute it and/or modify it
6+ * under the terms of the GNU General Public License version 2 only, as
7+ * published by the Free Software Foundation. Oracle designates this
8+ * particular file as subject to the "Classpath" exception as provided
9+ * by Oracle in the LICENSE file that accompanied this code.
10+ *
11+ * This code is distributed in the hope that it will be useful, but WITHOUT
12+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+ * version 2 for more details (a copy is included in the LICENSE file that
15+ * accompanied this code).
16+ *
17+ * You should have received a copy of the GNU General Public License version
18+ * 2 along with this work; if not, write to the Free Software Foundation,
19+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+ *
21+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+ * or visit www.oracle.com if you need additional information or have any
23+ * questions.
24+ */
25+
26+package com.sun.tools.example.debug.bdi; //### does it belong here?
27+
28+import com.sun.jdi.*;
29+
30+public class Utils {
31+
32+ /**
33+ * Return the thread status description.
34+ */
35+ public static String getStatus(ThreadReference thr) {
36+ int status = thr.status();
37+ String result;
38+ switch (status) {
39+ case ThreadReference.THREAD_STATUS_UNKNOWN:
40+ result = "unknown status";
41+ break;
42+ case ThreadReference.THREAD_STATUS_ZOMBIE:
43+ result = "zombie";
44+ break;
45+ case ThreadReference.THREAD_STATUS_RUNNING:
46+ result = "running";
47+ break;
48+ case ThreadReference.THREAD_STATUS_SLEEPING:
49+ result = "sleeping";
50+ break;
51+ case ThreadReference.THREAD_STATUS_MONITOR:
52+ result = "waiting to acquire a monitor lock";
53+ break;
54+ case ThreadReference.THREAD_STATUS_WAIT:
55+ result = "waiting on a condition";
56+ break;
57+ default:
58+ result = "<invalid thread status>";
59+ }
60+ if (thr.isSuspended()) {
61+ result += " (suspended)";
62+ }
63+ return result;
64+ }
65+
66+ /**
67+ * Return a description of an object.
68+ */
69+ public static String description(ObjectReference ref) {
70+ ReferenceType clazz = ref.referenceType();
71+ long id = ref.uniqueID(); //### TODO use real id
72+ if (clazz == null) {
73+ return toHex(id);
74+ } else {
75+ return "(" + clazz.name() + ")" + toHex(id);
76+ }
77+ }
78+
79+ /**
80+ * Convert a long to a hexadecimal string.
81+ */
82+ public static String toHex(long n) {
83+ char s1[] = new char[16];
84+ char s2[] = new char[18];
85+
86+ // Store digits in reverse order.
87+ int i = 0;
88+ do {
89+ long d = n & 0xf;
90+ s1[i++] = (char)((d < 10) ? ('0' + d) : ('a' + d - 10));
91+ } while ((n >>>= 4) > 0);
92+
93+ // Now reverse the array.
94+ s2[0] = '0';
95+ s2[1] = 'x';
96+ int j = 2;
97+ while (--i >= 0) {
98+ s2[j++] = s1[i];
99+ }
100+ return new String(s2, 0, j);
101+ }
102+
103+ /**
104+ * Convert hexadecimal strings to longs.
105+ */
106+ public static long fromHex(String hexStr) {
107+ String str = hexStr.startsWith("0x") ?
108+ hexStr.substring(2).toLowerCase() : hexStr.toLowerCase();
109+ if (hexStr.length() == 0) {
110+ throw new NumberFormatException();
111+ }
112+
113+ long ret = 0;
114+ for (int i = 0; i < str.length(); i++) {
115+ int c = str.charAt(i);
116+ if (c >= '0' && c <= '9') {
117+ ret = (ret * 16) + (c - '0');
118+ } else if (c >= 'a' && c <= 'f') {
119+ ret = (ret * 16) + (c - 'a' + 10);
120+ } else {
121+ throw new NumberFormatException();
122+ }
123+ }
124+ return ret;
125+ }
126+
127+
128+ /*
129+ * The next two methods are used by this class and by EventHandler
130+ * to print consistent locations and error messages.
131+ */
132+ public static String locationString(Location loc) {
133+ return loc.declaringType().name() +
134+ "." + loc.method().name() + "(), line=" +
135+ loc.lineNumber();
136+ }
137+
138+//### UNUSED.
139+/************************
140+ private String typedName(Method method) {
141+ // TO DO: Use method.signature() instead of method.arguments() so that
142+ // we get sensible results for classes without debugging info
143+ StringBuffer buf = new StringBuffer();
144+ buf.append(method.name());
145+ buf.append("(");
146+ Iterator it = method.arguments().iterator();
147+ while (it.hasNext()) {
148+ buf.append(((LocalVariable)it.next()).typeName());
149+ if (it.hasNext()) {
150+ buf.append(",");
151+ }
152+ }
153+ buf.append(")");
154+ return buf.toString();
155+ }
156+************************/
157+
158+ public static boolean isValidMethodName(String s) {
159+ return isJavaIdentifier(s) ||
160+ s.equals("<init>") ||
161+ s.equals("<clinit>");
162+ }
163+
164+ public static boolean isJavaIdentifier(String s) {
165+ if (s.length() == 0) {
166+ return false;
167+ }
168+ int cp = s.codePointAt(0);
169+ if (! Character.isJavaIdentifierStart(cp)) {
170+ return false;
171+ }
172+ for (int i = Character.charCount(cp); i < s.length(); i += Character.charCount(cp)) {
173+ cp = s.codePointAt(i);
174+ if (! Character.isJavaIdentifierPart(cp)) {
175+ return false;
176+ }
177+ }
178+ return true;
179+ }
180+
181+}
java/pkg/com/sun/tools/example/debug/bdi/VMLaunchFailureException.java+31−0
@@ -0,0 +1,31 @@
1+/*
2+ * Copyright (c) 1998, 1999, Oracle and/or its affiliates. All rights reserved.
3+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+ *
5+ * This code is free software; you can redistribute it and/or modify it
6+ * under the terms of the GNU General Public License version 2 only, as
7+ * published by the Free Software Foundation. Oracle designates this
8+ * particular file as subject to the "Classpath" exception as provided
9+ * by Oracle in the LICENSE file that accompanied this code.
10+ *
11+ * This code is distributed in the hope that it will be useful, but WITHOUT
12+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+ * version 2 for more details (a copy is included in the LICENSE file that
15+ * accompanied this code).
16+ *
17+ * You should have received a copy of the GNU General Public License version
18+ * 2 along with this work; if not, write to the Free Software Foundation,
19+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+ *
21+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+ * or visit www.oracle.com if you need additional information or have any
23+ * questions.
24+ */
25+
26+package com.sun.tools.example.debug.bdi;
27+
28+public class VMLaunchFailureException extends Exception {
29+
30+ private static final long serialVersionUID = -2439646729274310108L;
31+}
java/pkg/com/sun/tools/example/debug/bdi/VMNotInterruptedException.java+31−0
@@ -0,0 +1,31 @@
1+/*
2+ * Copyright (c) 1998, 1999, Oracle and/or its affiliates. All rights reserved.
3+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+ *
5+ * This code is free software; you can redistribute it and/or modify it
6+ * under the terms of the GNU General Public License version 2 only, as
7+ * published by the Free Software Foundation. Oracle designates this
8+ * particular file as subject to the "Classpath" exception as provided
9+ * by Oracle in the LICENSE file that accompanied this code.
10+ *
11+ * This code is distributed in the hope that it will be useful, but WITHOUT
12+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+ * version 2 for more details (a copy is included in the LICENSE file that
15+ * accompanied this code).
16+ *
17+ * You should have received a copy of the GNU General Public License version
18+ * 2 along with this work; if not, write to the Free Software Foundation,
19+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+ *
21+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+ * or visit www.oracle.com if you need additional information or have any
23+ * questions.
24+ */
25+
26+package com.sun.tools.example.debug.bdi;
27+
28+public class VMNotInterruptedException extends Exception {
29+
30+ private static final long serialVersionUID = 8111074582188765600L;
31+}
java/pkg/com/sun/tools/example/debug/bdi/WatchpointSpec.java+92−0
@@ -0,0 +1,92 @@
1+/*
2+ * Copyright (c) 1999, Oracle and/or its affiliates. All rights reserved.
3+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+ *
5+ * This code is free software; you can redistribute it and/or modify it
6+ * under the terms of the GNU General Public License version 2 only, as
7+ * published by the Free Software Foundation. Oracle designates this
8+ * particular file as subject to the "Classpath" exception as provided
9+ * by Oracle in the LICENSE file that accompanied this code.
10+ *
11+ * This code is distributed in the hope that it will be useful, but WITHOUT
12+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+ * version 2 for more details (a copy is included in the LICENSE file that
15+ * accompanied this code).
16+ *
17+ * You should have received a copy of the GNU General Public License version
18+ * 2 along with this work; if not, write to the Free Software Foundation,
19+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+ *
21+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+ * or visit www.oracle.com if you need additional information or have any
23+ * questions.
24+ */
25+
26+package com.sun.tools.example.debug.bdi;
27+
28+public abstract class WatchpointSpec extends EventRequestSpec {
29+ final String fieldId;
30+
31+ WatchpointSpec(EventRequestSpecList specs,
32+ ReferenceTypeSpec refSpec, String fieldId) {
33+ super(specs, refSpec);
34+ this.fieldId = fieldId;
35+// if (!isJavaIdentifier(fieldId)) {
36+// throw new MalformedMemberNameException(fieldId);
37+// }
38+ }
39+
40+ @Override
41+ void notifySet(SpecListener listener, SpecEvent evt) {
42+ listener.watchpointSet(evt);
43+ }
44+
45+ @Override
46+ void notifyDeferred(SpecListener listener, SpecEvent evt) {
47+ listener.watchpointDeferred(evt);
48+ }
49+
50+ @Override
51+ void notifyResolved(SpecListener listener, SpecEvent evt) {
52+ listener.watchpointResolved(evt);
53+ }
54+
55+ @Override
56+ void notifyDeleted(SpecListener listener, SpecEvent evt) {
57+ listener.watchpointDeleted(evt);
58+ }
59+
60+ @Override
61+ void notifyError(SpecListener listener, SpecErrorEvent evt) {
62+ listener.watchpointError(evt);
63+ }
64+
65+ @Override
66+ public int hashCode() {
67+ return refSpec.hashCode() + fieldId.hashCode() +
68+ getClass().hashCode();
69+ }
70+
71+ @Override
72+ public boolean equals(Object obj) {
73+ if (obj instanceof WatchpointSpec) {
74+ WatchpointSpec watchpoint = (WatchpointSpec)obj;
75+
76+ return fieldId.equals(watchpoint.fieldId) &&
77+ refSpec.equals(watchpoint.refSpec) &&
78+ getClass().equals(watchpoint.getClass());
79+ } else {
80+ return false;
81+ }
82+ }
83+
84+ @Override
85+ public String errorMessageFor(Exception e) {
86+ if (e instanceof NoSuchFieldException) {
87+ return ("No field " + fieldId + " in " + refSpec);
88+ } else {
89+ return super.errorMessageFor(e);
90+ }
91+ }
92+}
java/pkg/com/sun/tools/example/debug/bdi/mkfile+44−0
@@ -0,0 +1,44 @@
1+<../../../../../../../../mkconfig
2+
3+TARG=\
4+ AccessWatchpointSpec.dis\
5+ AmbiguousMethodException.dis\
6+ BreakpointSpec.dis\
7+ ChildSession.dis\
8+ EvaluationException.dis\
9+ EventRequestSpec.dis\
10+ EventRequestSpecList.dis\
11+ ExceptionSpec.dis\
12+ ExecutionManager.dis\
13+ FrameIndexOutOfBoundsException.dis\
14+ InputListener.dis\
15+ JDIEventSource.dis\
16+ LineBreakpointSpec.dis\
17+ LineNotFoundException.dis\
18+ MalformedMemberNameException.dis\
19+ MethodBreakpointSpec.dis\
20+ MethodNotFoundException.dis\
21+ ModificationWatchpointSpec.dis\
22+ NoSessionException.dis\
23+ NoThreadException.dis\
24+ OutputListener.dis\
25+ ParseException.dis\
26+ PatternReferenceTypeSpec.dis\
27+ ReferenceTypeSpec.dis\
28+ Session.dis\
29+ SessionListener.dis\
30+ SourceNameReferenceTypeSpec.dis\
31+ SpecErrorEvent.dis\
32+ SpecEvent.dis\
33+ SpecListener.dis\
34+ ThreadGroupIterator.dis\
35+ ThreadInfo.dis\
36+ ThreadIterator.dis\
37+ Utils.dis\
38+ VMLaunchFailureException.dis\
39+ VMNotInterruptedException.dis\
40+ WatchpointSpec.dis\
41+
42+DISBIN=$ROOT/java/dis/java/java/com/sun/tools/example/debug/bdi
43+
44+<$ROOT/mkfiles/mkjava
java/pkg/com/sun/tools/example/debug/event/AbstractEventSet.java+263−0
@@ -0,0 +1,263 @@
1+/*
2+ * Copyright (c) 1999, 2004, Oracle and/or its affiliates. All rights reserved.
3+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+ *
5+ * This code is free software; you can redistribute it and/or modify it
6+ * under the terms of the GNU General Public License version 2 only, as
7+ * published by the Free Software Foundation. Oracle designates this
8+ * particular file as subject to the "Classpath" exception as provided
9+ * by Oracle in the LICENSE file that accompanied this code.
10+ *
11+ * This code is distributed in the hope that it will be useful, but WITHOUT
12+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+ * version 2 for more details (a copy is included in the LICENSE file that
15+ * accompanied this code).
16+ *
17+ * You should have received a copy of the GNU General Public License version
18+ * 2 along with this work; if not, write to the Free Software Foundation,
19+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+ *
21+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+ * or visit www.oracle.com if you need additional information or have any
23+ * questions.
24+ */
25+
26+package com.sun.tools.example.debug.event;
27+
28+import com.sun.jdi.*;
29+import com.sun.jdi.event.*;
30+import com.sun.jdi.request.*;
31+
32+import java.util.*;
33+
34+public abstract class AbstractEventSet extends EventObject implements EventSet {
35+
36+ private static final long serialVersionUID = 2772717574222076977L;
37+ private final EventSet jdiEventSet;
38+ final Event oneEvent;
39+
40+ /**
41+ */
42+ AbstractEventSet(EventSet jdiEventSet) {
43+ super(jdiEventSet.virtualMachine());
44+ this.jdiEventSet = jdiEventSet;
45+ this.oneEvent = eventIterator().nextEvent();
46+ }
47+
48+ public static AbstractEventSet toSpecificEventSet(EventSet jdiEventSet) {
49+ Event evt = jdiEventSet.eventIterator().nextEvent();
50+ if (evt instanceof LocatableEvent) {
51+ if (evt instanceof ExceptionEvent) {
52+ return new ExceptionEventSet(jdiEventSet);
53+ } else if (evt instanceof WatchpointEvent) {
54+ if (evt instanceof AccessWatchpointEvent) {
55+ return new AccessWatchpointEventSet(jdiEventSet);
56+ } else {
57+ return new ModificationWatchpointEventSet(jdiEventSet);
58+ }
59+ } else {
60+ return new LocationTriggerEventSet(jdiEventSet);
61+ }
62+ } else if (evt instanceof ClassPrepareEvent) {
63+ return new ClassPrepareEventSet(jdiEventSet);
64+ } else if (evt instanceof ClassUnloadEvent) {
65+ return new ClassUnloadEventSet(jdiEventSet);
66+ } else if (evt instanceof ThreadDeathEvent) {
67+ return new ThreadDeathEventSet(jdiEventSet);
68+ } else if (evt instanceof ThreadStartEvent) {
69+ return new ThreadStartEventSet(jdiEventSet);
70+ } else if (evt instanceof VMDeathEvent) {
71+ return new VMDeathEventSet(jdiEventSet);
72+ } else if (evt instanceof VMDisconnectEvent) {
73+ return new VMDisconnectEventSet(jdiEventSet);
74+ } else if (evt instanceof VMStartEvent) {
75+ return new VMStartEventSet(jdiEventSet);
76+ } else {
77+ throw new IllegalArgumentException("Unknown event " + evt);
78+ }
79+ }
80+
81+ public abstract void notify(JDIListener listener);
82+
83+ // Implement Mirror
84+
85+ @Override
86+ public VirtualMachine virtualMachine() {
87+ return jdiEventSet.virtualMachine();
88+ }
89+
90+ public VirtualMachine getVirtualMachine() {
91+ return jdiEventSet.virtualMachine();
92+ }
93+
94+ // Implement EventSet
95+
96+ /**
97+ * Returns the policy used to suspend threads in the target VM
98+ * for this event set. This policy is selected from the suspend
99+ * policies for each event's request. The one that suspends the
100+ * most threads is chosen when the event occurs in the target VM
101+ * and that policy is returned here. See
102+ * com.sun.jdi.request.EventRequest for the possible policy values.
103+ *
104+ * @return the integer suspendPolicy
105+ */
106+ public int getSuspendPolicy() {
107+ return jdiEventSet.suspendPolicy();
108+ }
109+
110+ @Override
111+ public void resume() {
112+ jdiEventSet.resume();
113+ }
114+
115+ @Override
116+ public int suspendPolicy() {
117+ return jdiEventSet.suspendPolicy();
118+ }
119+
120+ public boolean suspendedAll() {
121+ return jdiEventSet.suspendPolicy() == EventRequest.SUSPEND_ALL;
122+ }
123+
124+ public boolean suspendedEventThread() {
125+ return jdiEventSet.suspendPolicy() == EventRequest.SUSPEND_EVENT_THREAD;
126+ }
127+
128+ public boolean suspendedNone() {
129+ return jdiEventSet.suspendPolicy() == EventRequest.SUSPEND_NONE;
130+ }
131+
132+ /**
133+ * Return an iterator specific to {@link Event} objects.
134+ */
135+ @Override
136+ public EventIterator eventIterator() {
137+ return jdiEventSet.eventIterator();
138+ }
139+
140+
141+ // Implement java.util.Set (by pass through)
142+
143+ /**
144+ * Returns the number of elements in this set (its cardinality). If this
145+ * set contains more than <tt>Integer.MAX_VALUE</tt> elements, returns
146+ * <tt>Integer.MAX_VALUE</tt>.
147+ *
148+ * @return the number of elements in this set (its cardinality).
149+ */
150+ @Override
151+ public int size() {
152+ return jdiEventSet.size();
153+ }
154+
155+ /**
156+ * Returns <tt>true</tt> if this set contains no elements.
157+ *
158+ * @return <tt>true</tt> if this set contains no elements.
159+ */
160+ @Override
161+ public boolean isEmpty() {
162+ return jdiEventSet.isEmpty();
163+ }
164+
165+ /**
166+ * Returns <tt>true</tt> if this set contains the specified element. More
167+ * formally, returns <tt>true</tt> if and only if this set contains an
168+ * element <code>e</code> such that <code>(o==null ? e==null :
169+ * o.equals(e))</code>.
170+ *
171+ * @return <tt>true</tt> if this set contains the specified element.
172+ */
173+ @Override
174+ public boolean contains(Object o) {
175+ return jdiEventSet.contains(o);
176+ }
177+
178+ /**
179+ * Returns an iterator over the elements in this set. The elements are
180+ * returned in no particular order (unless this set is an instance of some
181+ * class that provides a guarantee).
182+ *
183+ * @return an iterator over the elements in this set.
184+ */
185+ @Override
186+ public Iterator<Event> iterator() {
187+ return jdiEventSet.iterator();
188+ }
189+
190+ /**
191+ * Returns an array containing all of the elements in this set.
192+ * Obeys the general contract of the <tt>Collection.toArray</tt> method.
193+ *
194+ * @return an array containing all of the elements in this set.
195+ */
196+ @Override
197+ public Object[] toArray() {
198+ return jdiEventSet.toArray();
199+ }
200+
201+ /**
202+ * Returns an array containing all of the elements in this set whose
203+ * runtime type is that of the specified array. Obeys the general
204+ * contract of the <tt>Collection.toArray(Object[])</tt> method.
205+ *
206+ * @param a the array into which the elements of this set are to
207+ * be stored, if it is big enough {
208+ return jdiEventSet.XXX();
209+ } otherwise, a new array of the
210+ * same runtime type is allocated for this purpose.
211+ * @return an array containing the elements of this set.
212+ * @throws ArrayStoreException the runtime type of a is not a supertype
213+ * of the runtime type of every element in this set.
214+ */
215+ @Override
216+ public <T> T[] toArray(T a[]) {
217+ return jdiEventSet.toArray(a);
218+ }
219+
220+ // Bulk Operations
221+
222+ /**
223+ * Returns <tt>true</tt> if this set contains all of the elements of the
224+ * specified collection. If the specified collection is also a set, this
225+ * method returns <tt>true</tt> if it is a <i>subset</i> of this set.
226+ *
227+ * @param c collection to be checked for containment in this set.
228+ * @return <tt>true</tt> if this set contains all of the elements of the
229+ * specified collection.
230+ */
231+ @Override
232+ public boolean containsAll(Collection<?> c) {
233+ return jdiEventSet.containsAll(c);
234+ }
235+
236+
237+ // Make the rest of Set unmodifiable
238+
239+ @Override
240+ public boolean add(Event e){
241+ throw new UnsupportedOperationException();
242+ }
243+ @Override
244+ public boolean remove(Object o) {
245+ throw new UnsupportedOperationException();
246+ }
247+ @Override
248+ public boolean addAll(Collection<? extends Event> coll) {
249+ throw new UnsupportedOperationException();
250+ }
251+ @Override
252+ public boolean removeAll(Collection<?> coll) {
253+ throw new UnsupportedOperationException();
254+ }
255+ @Override
256+ public boolean retainAll(Collection<?> coll) {
257+ throw new UnsupportedOperationException();
258+ }
259+ @Override
260+ public void clear() {
261+ throw new UnsupportedOperationException();
262+ }
263+}
java/pkg/com/sun/tools/example/debug/event/AccessWatchpointEventSet.java+42−0
@@ -0,0 +1,42 @@
1+/*
2+ * Copyright (c) 1999, Oracle and/or its affiliates. All rights reserved.
3+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+ *
5+ * This code is free software; you can redistribute it and/or modify it
6+ * under the terms of the GNU General Public License version 2 only, as
7+ * published by the Free Software Foundation. Oracle designates this
8+ * particular file as subject to the "Classpath" exception as provided
9+ * by Oracle in the LICENSE file that accompanied this code.
10+ *
11+ * This code is distributed in the hope that it will be useful, but WITHOUT
12+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+ * version 2 for more details (a copy is included in the LICENSE file that
15+ * accompanied this code).
16+ *
17+ * You should have received a copy of the GNU General Public License version
18+ * 2 along with this work; if not, write to the Free Software Foundation,
19+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+ *
21+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+ * or visit www.oracle.com if you need additional information or have any
23+ * questions.
24+ */
25+
26+package com.sun.tools.example.debug.event;
27+
28+import com.sun.jdi.event.*;
29+
30+public class AccessWatchpointEventSet extends WatchpointEventSet {
31+
32+ private static final long serialVersionUID = -2620394219156607673L;
33+
34+ AccessWatchpointEventSet(EventSet jdiEventSet) {
35+ super(jdiEventSet);
36+ }
37+
38+ @Override
39+ public void notify(JDIListener listener) {
40+ listener.accessWatchpoint(this);
41+ }
42+}
java/pkg/com/sun/tools/example/debug/event/ClassPrepareEventSet.java+64−0
@@ -0,0 +1,64 @@
1+/*
2+ * Copyright (c) 1999, Oracle and/or its affiliates. All rights reserved.
3+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+ *
5+ * This code is free software; you can redistribute it and/or modify it
6+ * under the terms of the GNU General Public License version 2 only, as
7+ * published by the Free Software Foundation. Oracle designates this
8+ * particular file as subject to the "Classpath" exception as provided
9+ * by Oracle in the LICENSE file that accompanied this code.
10+ *
11+ * This code is distributed in the hope that it will be useful, but WITHOUT
12+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+ * version 2 for more details (a copy is included in the LICENSE file that
15+ * accompanied this code).
16+ *
17+ * You should have received a copy of the GNU General Public License version
18+ * 2 along with this work; if not, write to the Free Software Foundation,
19+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+ *
21+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+ * or visit www.oracle.com if you need additional information or have any
23+ * questions.
24+ */
25+
26+package com.sun.tools.example.debug.event;
27+
28+import com.sun.jdi.*;
29+import com.sun.jdi.event.*;
30+
31+public class ClassPrepareEventSet extends AbstractEventSet {
32+
33+ private static final long serialVersionUID = 5958493423581010491L;
34+
35+ ClassPrepareEventSet(EventSet jdiEventSet) {
36+ super(jdiEventSet);
37+ }
38+
39+ /**
40+ * Returns the thread in which this event has occurred.
41+ *
42+ * @return a {@link ThreadReference} which mirrors the event's thread in
43+ * the target VM.
44+ */
45+ public ThreadReference getThread() {
46+ return ((ClassPrepareEvent)oneEvent).thread();
47+ }
48+
49+
50+ /**
51+ * Returns the reference type for which this event was generated.
52+ *
53+ * @return a {@link ReferenceType} which mirrors the class, interface, or
54+ * array which has been linked.
55+ */
56+ public ReferenceType getReferenceType() {
57+ return ((ClassPrepareEvent)oneEvent).referenceType();
58+ }
59+
60+ @Override
61+ public void notify(JDIListener listener) {
62+ listener.classPrepare(this);
63+ }
64+}
java/pkg/com/sun/tools/example/debug/event/ClassUnloadEventSet.java+56−0
@@ -0,0 +1,56 @@
1+/*
2+ * Copyright (c) 1999, Oracle and/or its affiliates. All rights reserved.
3+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+ *
5+ * This code is free software; you can redistribute it and/or modify it
6+ * under the terms of the GNU General Public License version 2 only, as
7+ * published by the Free Software Foundation. Oracle designates this
8+ * particular file as subject to the "Classpath" exception as provided
9+ * by Oracle in the LICENSE file that accompanied this code.
10+ *
11+ * This code is distributed in the hope that it will be useful, but WITHOUT
12+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+ * version 2 for more details (a copy is included in the LICENSE file that
15+ * accompanied this code).
16+ *
17+ * You should have received a copy of the GNU General Public License version
18+ * 2 along with this work; if not, write to the Free Software Foundation,
19+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+ *
21+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+ * or visit www.oracle.com if you need additional information or have any
23+ * questions.
24+ */
25+
26+package com.sun.tools.example.debug.event;
27+
28+import com.sun.jdi.event.*;
29+
30+public class ClassUnloadEventSet extends AbstractEventSet {
31+
32+ private static final long serialVersionUID = 8370341450345835866L;
33+
34+ ClassUnloadEventSet(EventSet jdiEventSet) {
35+ super(jdiEventSet);
36+ }
37+
38+ /**
39+ * Returns the name of the class that has been unloaded.
40+ */
41+ public String getClassName() {
42+ return ((ClassUnloadEvent)oneEvent).className();
43+ }
44+
45+ /**
46+ * Returns the JNI-style signature of the class that has been unloaded.
47+ */
48+ public String getClassSignature() {
49+ return ((ClassUnloadEvent)oneEvent).classSignature();
50+ }
51+
52+ @Override
53+ public void notify(JDIListener listener) {
54+ listener.classUnload(this);
55+ }
56+}
java/pkg/com/sun/tools/example/debug/event/ExceptionEventSet.java+84−0
@@ -0,0 +1,84 @@
1+/*
2+ * Copyright (c) 1999, Oracle and/or its affiliates. All rights reserved.
3+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+ *
5+ * This code is free software; you can redistribute it and/or modify it
6+ * under the terms of the GNU General Public License version 2 only, as
7+ * published by the Free Software Foundation. Oracle designates this
8+ * particular file as subject to the "Classpath" exception as provided
9+ * by Oracle in the LICENSE file that accompanied this code.
10+ *
11+ * This code is distributed in the hope that it will be useful, but WITHOUT
12+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+ * version 2 for more details (a copy is included in the LICENSE file that
15+ * accompanied this code).
16+ *
17+ * You should have received a copy of the GNU General Public License version
18+ * 2 along with this work; if not, write to the Free Software Foundation,
19+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+ *
21+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+ * or visit www.oracle.com if you need additional information or have any
23+ * questions.
24+ */
25+
26+package com.sun.tools.example.debug.event;
27+
28+import com.sun.jdi.*;
29+import com.sun.jdi.event.*;
30+
31+public class ExceptionEventSet extends LocatableEventSet {
32+
33+ private static final long serialVersionUID = 5328140167954640711L;
34+
35+ ExceptionEventSet(EventSet jdiEventSet) {
36+ super(jdiEventSet);
37+ }
38+
39+ /**
40+ * Gets the thrown exception object. The exception object is
41+ * an instance of java.lang.Throwable or a subclass in the
42+ * target VM.
43+ *
44+ * @return an {@link ObjectReference} which mirrors the thrown object in
45+ * the target VM.
46+ */
47+ public ObjectReference getException() {
48+ return ((ExceptionEvent)oneEvent).exception();
49+ }
50+
51+ /**
52+ * Gets the location where the exception will be caught. An exception
53+ * is considered to be caught if, at the point of the throw, the
54+ * current location is dynamically enclosed in a try statement that
55+ * handles the exception. (See the JVM specification for details).
56+ * If there is such a try statement, the catch location is the
57+ * first code index of the appropriate catch clause.
58+ * <p>
59+ * If there are native methods in the call stack at the time of the
60+ * exception, there are important restrictions to note about the
61+ * returned catch location. In such cases,
62+ * it is not possible to predict whether an exception will be handled
63+ * by some native method on the call stack.
64+ * Thus, it is possible that exceptions considered uncaught
65+ * here will, in fact, be handled by a native method and not cause
66+ * termination of the target VM. Also, it cannot be assumed that the
67+ * catch location returned here will ever be reached by the throwing
68+ * thread. If there is
69+ * a native frame between the current location and the catch location,
70+ * the exception might be handled and cleared in that native method
71+ * instead.
72+ *
73+ * @return the {@link Location} where the exception will be caught or null if
74+ * the exception is uncaught.
75+ */
76+ public Location getCatchLocation() {
77+ return ((ExceptionEvent)oneEvent).catchLocation();
78+ }
79+
80+ @Override
81+ public void notify(JDIListener listener) {
82+ listener.exception(this);
83+ }
84+}
java/pkg/com/sun/tools/example/debug/event/JDIAdapter.java+80−0
@@ -0,0 +1,80 @@
1+/*
2+ * Copyright (c) 1999, Oracle and/or its affiliates. All rights reserved.
3+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+ *
5+ * This code is free software; you can redistribute it and/or modify it
6+ * under the terms of the GNU General Public License version 2 only, as
7+ * published by the Free Software Foundation. Oracle designates this
8+ * particular file as subject to the "Classpath" exception as provided
9+ * by Oracle in the LICENSE file that accompanied this code.
10+ *
11+ * This code is distributed in the hope that it will be useful, but WITHOUT
12+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+ * version 2 for more details (a copy is included in the LICENSE file that
15+ * accompanied this code).
16+ *
17+ * You should have received a copy of the GNU General Public License version
18+ * 2 along with this work; if not, write to the Free Software Foundation,
19+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+ *
21+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+ * or visit www.oracle.com if you need additional information or have any
23+ * questions.
24+ */
25+
26+package com.sun.tools.example.debug.event;
27+
28+/**
29+ * The adapter which receives JDI event sets. The methods in this
30+ * class are empty; this class is provided as a convenience for
31+ * easily creating listeners by extending this class and overriding
32+ * only the methods of interest.
33+ */
34+public class JDIAdapter implements JDIListener {
35+
36+ @Override
37+ public void accessWatchpoint(AccessWatchpointEventSet e) {
38+ }
39+
40+ @Override
41+ public void classPrepare(ClassPrepareEventSet e) {
42+ }
43+
44+ @Override
45+ public void classUnload(ClassUnloadEventSet e) {
46+ }
47+
48+ @Override
49+ public void exception(ExceptionEventSet e) {
50+ }
51+
52+ @Override
53+ public void locationTrigger(LocationTriggerEventSet e) {
54+ }
55+
56+ @Override
57+ public void modificationWatchpoint(ModificationWatchpointEventSet e) {
58+ }
59+
60+ @Override
61+ public void threadDeath(ThreadDeathEventSet e) {
62+ }
63+
64+ @Override
65+ public void threadStart(ThreadStartEventSet e) {
66+ }
67+
68+ @Override
69+ public void vmDeath(VMDeathEventSet e) {
70+ }
71+
72+ @Override
73+ public void vmDisconnect(VMDisconnectEventSet e) {
74+ }
75+
76+ @Override
77+ public void vmStart(VMStartEventSet e) {
78+ }
79+
80+}
java/pkg/com/sun/tools/example/debug/event/JDIListener.java+42−0
@@ -0,0 +1,42 @@
1+/*
2+ * Copyright (c) 1999, Oracle and/or its affiliates. All rights reserved.
3+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+ *
5+ * This code is free software; you can redistribute it and/or modify it
6+ * under the terms of the GNU General Public License version 2 only, as
7+ * published by the Free Software Foundation. Oracle designates this
8+ * particular file as subject to the "Classpath" exception as provided
9+ * by Oracle in the LICENSE file that accompanied this code.
10+ *
11+ * This code is distributed in the hope that it will be useful, but WITHOUT
12+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+ * version 2 for more details (a copy is included in the LICENSE file that
15+ * accompanied this code).
16+ *
17+ * You should have received a copy of the GNU General Public License version
18+ * 2 along with this work; if not, write to the Free Software Foundation,
19+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+ *
21+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+ * or visit www.oracle.com if you need additional information or have any
23+ * questions.
24+ */
25+
26+package com.sun.tools.example.debug.event;
27+
28+import java.util.EventListener;
29+
30+public interface JDIListener extends EventListener {
31+ void accessWatchpoint(AccessWatchpointEventSet e);
32+ void classPrepare(ClassPrepareEventSet e);
33+ void classUnload(ClassUnloadEventSet e);
34+ void exception(ExceptionEventSet e);
35+ void locationTrigger(LocationTriggerEventSet e);
36+ void modificationWatchpoint(ModificationWatchpointEventSet e);
37+ void threadDeath(ThreadDeathEventSet e);
38+ void threadStart(ThreadStartEventSet e);
39+ void vmDeath(VMDeathEventSet e);
40+ void vmDisconnect(VMDisconnectEventSet e);
41+ void vmStart(VMStartEventSet e);
42+}
java/pkg/com/sun/tools/example/debug/event/LocatableEventSet.java+62−0
@@ -0,0 +1,62 @@
1+/*
2+ * Copyright (c) 1999, Oracle and/or its affiliates. All rights reserved.
3+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+ *
5+ * This code is free software; you can redistribute it and/or modify it
6+ * under the terms of the GNU General Public License version 2 only, as
7+ * published by the Free Software Foundation. Oracle designates this
8+ * particular file as subject to the "Classpath" exception as provided
9+ * by Oracle in the LICENSE file that accompanied this code.
10+ *
11+ * This code is distributed in the hope that it will be useful, but WITHOUT
12+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+ * version 2 for more details (a copy is included in the LICENSE file that
15+ * accompanied this code).
16+ *
17+ * You should have received a copy of the GNU General Public License version
18+ * 2 along with this work; if not, write to the Free Software Foundation,
19+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+ *
21+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+ * or visit www.oracle.com if you need additional information or have any
23+ * questions.
24+ */
25+
26+package com.sun.tools.example.debug.event;
27+
28+import com.sun.jdi.*;
29+import com.sun.jdi.event.*;
30+
31+/**
32+ * Abstract event set for events with location and thread.
33+ */
34+public abstract class LocatableEventSet extends AbstractEventSet {
35+
36+ private static final long serialVersionUID = 1027131209997915620L;
37+
38+ LocatableEventSet(EventSet jdiEventSet) {
39+ super(jdiEventSet);
40+ }
41+
42+ /**
43+ * Returns the {@link Location} of this mirror. Depending on context
44+ * and on available debug information, this location will have
45+ * varying precision.
46+ *
47+ * @return the {@link Location} of this mirror.
48+ */
49+ public Location getLocation() {
50+ return ((LocatableEvent)oneEvent).location();
51+ }
52+
53+ /**
54+ * Returns the thread in which this event has occurred.
55+ *
56+ * @return a {@link ThreadReference} which mirrors the event's thread in
57+ * the target VM.
58+ */
59+ public ThreadReference getThread() {
60+ return ((LocatableEvent)oneEvent).thread();
61+ }
62+}
java/pkg/com/sun/tools/example/debug/event/LocationTriggerEventSet.java+42−0
@@ -0,0 +1,42 @@
1+/*
2+ * Copyright (c) 1999, Oracle and/or its affiliates. All rights reserved.
3+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+ *
5+ * This code is free software; you can redistribute it and/or modify it
6+ * under the terms of the GNU General Public License version 2 only, as
7+ * published by the Free Software Foundation. Oracle designates this
8+ * particular file as subject to the "Classpath" exception as provided
9+ * by Oracle in the LICENSE file that accompanied this code.
10+ *
11+ * This code is distributed in the hope that it will be useful, but WITHOUT
12+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+ * version 2 for more details (a copy is included in the LICENSE file that
15+ * accompanied this code).
16+ *
17+ * You should have received a copy of the GNU General Public License version
18+ * 2 along with this work; if not, write to the Free Software Foundation,
19+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+ *
21+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+ * or visit www.oracle.com if you need additional information or have any
23+ * questions.
24+ */
25+
26+package com.sun.tools.example.debug.event;
27+
28+import com.sun.jdi.event.*;
29+
30+public class LocationTriggerEventSet extends LocatableEventSet {
31+
32+ private static final long serialVersionUID = -3674631710485872487L;
33+
34+ LocationTriggerEventSet(EventSet jdiEventSet) {
35+ super(jdiEventSet);
36+ }
37+
38+ @Override
39+ public void notify(JDIListener listener) {
40+ listener.locationTrigger(this);
41+ }
42+}
java/pkg/com/sun/tools/example/debug/event/ModificationWatchpointEventSet.java+51−0
@@ -0,0 +1,51 @@
1+/*
2+ * Copyright (c) 1999, Oracle and/or its affiliates. All rights reserved.
3+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+ *
5+ * This code is free software; you can redistribute it and/or modify it
6+ * under the terms of the GNU General Public License version 2 only, as
7+ * published by the Free Software Foundation. Oracle designates this
8+ * particular file as subject to the "Classpath" exception as provided
9+ * by Oracle in the LICENSE file that accompanied this code.
10+ *
11+ * This code is distributed in the hope that it will be useful, but WITHOUT
12+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+ * version 2 for more details (a copy is included in the LICENSE file that
15+ * accompanied this code).
16+ *
17+ * You should have received a copy of the GNU General Public License version
18+ * 2 along with this work; if not, write to the Free Software Foundation,
19+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+ *
21+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+ * or visit www.oracle.com if you need additional information or have any
23+ * questions.
24+ */
25+
26+package com.sun.tools.example.debug.event;
27+
28+import com.sun.jdi.*;
29+import com.sun.jdi.event.*;
30+
31+public class ModificationWatchpointEventSet extends WatchpointEventSet {
32+
33+ private static final long serialVersionUID = -680889300856154719L;
34+
35+ ModificationWatchpointEventSet(EventSet jdiEventSet) {
36+ super(jdiEventSet);
37+ }
38+
39+ /**
40+ * Value that will be assigned to the field when the instruction
41+ * completes.
42+ */
43+ public Value getValueToBe() {
44+ return ((ModificationWatchpointEvent)oneEvent).valueToBe();
45+ }
46+
47+ @Override
48+ public void notify(JDIListener listener) {
49+ listener.modificationWatchpoint(this);
50+ }
51+}
java/pkg/com/sun/tools/example/debug/event/ThreadDeathEventSet.java+53−0
@@ -0,0 +1,53 @@
1+/*
2+ * Copyright (c) 1999, Oracle and/or its affiliates. All rights reserved.
3+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+ *
5+ * This code is free software; you can redistribute it and/or modify it
6+ * under the terms of the GNU General Public License version 2 only, as
7+ * published by the Free Software Foundation. Oracle designates this
8+ * particular file as subject to the "Classpath" exception as provided
9+ * by Oracle in the LICENSE file that accompanied this code.
10+ *
11+ * This code is distributed in the hope that it will be useful, but WITHOUT
12+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+ * version 2 for more details (a copy is included in the LICENSE file that
15+ * accompanied this code).
16+ *
17+ * You should have received a copy of the GNU General Public License version
18+ * 2 along with this work; if not, write to the Free Software Foundation,
19+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+ *
21+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+ * or visit www.oracle.com if you need additional information or have any
23+ * questions.
24+ */
25+
26+package com.sun.tools.example.debug.event;
27+
28+import com.sun.jdi.*;
29+import com.sun.jdi.event.*;
30+
31+public class ThreadDeathEventSet extends AbstractEventSet {
32+
33+ private static final long serialVersionUID = -8801604712308151331L;
34+
35+ ThreadDeathEventSet(EventSet jdiEventSet) {
36+ super(jdiEventSet);
37+ }
38+
39+ /**
40+ * Returns the thread which is terminating.
41+ *
42+ * @return a {@link ThreadReference} which mirrors the event's thread in
43+ * the target VM.
44+ */
45+ public ThreadReference getThread() {
46+ return ((ThreadDeathEvent)oneEvent).thread();
47+ }
48+
49+ @Override
50+ public void notify(JDIListener listener) {
51+ listener.threadDeath(this);
52+ }
53+}
java/pkg/com/sun/tools/example/debug/event/ThreadStartEventSet.java+53−0
@@ -0,0 +1,53 @@
1+/*
2+ * Copyright (c) 1999, Oracle and/or its affiliates. All rights reserved.
3+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+ *
5+ * This code is free software; you can redistribute it and/or modify it
6+ * under the terms of the GNU General Public License version 2 only, as
7+ * published by the Free Software Foundation. Oracle designates this
8+ * particular file as subject to the "Classpath" exception as provided
9+ * by Oracle in the LICENSE file that accompanied this code.
10+ *
11+ * This code is distributed in the hope that it will be useful, but WITHOUT
12+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+ * version 2 for more details (a copy is included in the LICENSE file that
15+ * accompanied this code).
16+ *
17+ * You should have received a copy of the GNU General Public License version
18+ * 2 along with this work; if not, write to the Free Software Foundation,
19+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+ *
21+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+ * or visit www.oracle.com if you need additional information or have any
23+ * questions.
24+ */
25+
26+package com.sun.tools.example.debug.event;
27+
28+import com.sun.jdi.*;
29+import com.sun.jdi.event.*;
30+
31+public class ThreadStartEventSet extends AbstractEventSet {
32+
33+ private static final long serialVersionUID = -3802096132294933502L;
34+
35+ ThreadStartEventSet(EventSet jdiEventSet) {
36+ super(jdiEventSet);
37+ }
38+
39+ /**
40+ * Returns the thread which has started.
41+ *
42+ * @return a {@link ThreadReference} which mirrors the event's thread in
43+ * the target VM.
44+ */
45+ public ThreadReference getThread() {
46+ return ((ThreadStartEvent)oneEvent).thread();
47+ }
48+
49+ @Override
50+ public void notify(JDIListener listener) {
51+ listener.threadStart(this);
52+ }
53+}
java/pkg/com/sun/tools/example/debug/event/VMDeathEventSet.java+42−0
@@ -0,0 +1,42 @@
1+/*
2+ * Copyright (c) 1999, Oracle and/or its affiliates. All rights reserved.
3+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+ *
5+ * This code is free software; you can redistribute it and/or modify it
6+ * under the terms of the GNU General Public License version 2 only, as
7+ * published by the Free Software Foundation. Oracle designates this
8+ * particular file as subject to the "Classpath" exception as provided
9+ * by Oracle in the LICENSE file that accompanied this code.
10+ *
11+ * This code is distributed in the hope that it will be useful, but WITHOUT
12+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+ * version 2 for more details (a copy is included in the LICENSE file that
15+ * accompanied this code).
16+ *
17+ * You should have received a copy of the GNU General Public License version
18+ * 2 along with this work; if not, write to the Free Software Foundation,
19+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+ *
21+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+ * or visit www.oracle.com if you need additional information or have any
23+ * questions.
24+ */
25+
26+package com.sun.tools.example.debug.event;
27+
28+import com.sun.jdi.event.*;
29+
30+public class VMDeathEventSet extends AbstractEventSet {
31+
32+ private static final long serialVersionUID = 1163097303940092229L;
33+
34+ VMDeathEventSet(EventSet jdiEventSet) {
35+ super(jdiEventSet);
36+ }
37+
38+ @Override
39+ public void notify(JDIListener listener) {
40+ listener.vmDeath(this);
41+ }
42+}
java/pkg/com/sun/tools/example/debug/event/VMDisconnectEventSet.java+42−0
@@ -0,0 +1,42 @@
1+/*
2+ * Copyright (c) 1999, Oracle and/or its affiliates. All rights reserved.
3+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+ *
5+ * This code is free software; you can redistribute it and/or modify it
6+ * under the terms of the GNU General Public License version 2 only, as
7+ * published by the Free Software Foundation. Oracle designates this
8+ * particular file as subject to the "Classpath" exception as provided
9+ * by Oracle in the LICENSE file that accompanied this code.
10+ *
11+ * This code is distributed in the hope that it will be useful, but WITHOUT
12+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+ * version 2 for more details (a copy is included in the LICENSE file that
15+ * accompanied this code).
16+ *
17+ * You should have received a copy of the GNU General Public License version
18+ * 2 along with this work; if not, write to the Free Software Foundation,
19+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+ *
21+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+ * or visit www.oracle.com if you need additional information or have any
23+ * questions.
24+ */
25+
26+package com.sun.tools.example.debug.event;
27+
28+import com.sun.jdi.event.*;
29+
30+public class VMDisconnectEventSet extends AbstractEventSet {
31+
32+ private static final long serialVersionUID = 7968123152344675342L;
33+
34+ VMDisconnectEventSet(EventSet jdiEventSet) {
35+ super(jdiEventSet);
36+ }
37+
38+ @Override
39+ public void notify(JDIListener listener) {
40+ listener.vmDisconnect(this);
41+ }
42+}
java/pkg/com/sun/tools/example/debug/event/VMStartEventSet.java+53−0
@@ -0,0 +1,53 @@
1+/*
2+ * Copyright (c) 1999, Oracle and/or its affiliates. All rights reserved.
3+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+ *
5+ * This code is free software; you can redistribute it and/or modify it
6+ * under the terms of the GNU General Public License version 2 only, as
7+ * published by the Free Software Foundation. Oracle designates this
8+ * particular file as subject to the "Classpath" exception as provided
9+ * by Oracle in the LICENSE file that accompanied this code.
10+ *
11+ * This code is distributed in the hope that it will be useful, but WITHOUT
12+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+ * version 2 for more details (a copy is included in the LICENSE file that
15+ * accompanied this code).
16+ *
17+ * You should have received a copy of the GNU General Public License version
18+ * 2 along with this work; if not, write to the Free Software Foundation,
19+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+ *
21+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+ * or visit www.oracle.com if you need additional information or have any
23+ * questions.
24+ */
25+
26+package com.sun.tools.example.debug.event;
27+
28+import com.sun.jdi.*;
29+import com.sun.jdi.event.*;
30+
31+public class VMStartEventSet extends AbstractEventSet {
32+
33+ private static final long serialVersionUID = -3384957227835478191L;
34+
35+ VMStartEventSet(EventSet jdiEventSet) {
36+ super(jdiEventSet);
37+ }
38+
39+ /**
40+ * Returns the initial thread of the VM which has started.
41+ *
42+ * @return a {@link ThreadReference} which mirrors the event's
43+ * thread in the target VM.
44+ */
45+ public ThreadReference getThread() {
46+ return ((VMStartEvent)oneEvent).thread();
47+ }
48+
49+ @Override
50+ public void notify(JDIListener listener) {
51+ listener.vmStart(this);
52+ }
53+}
java/pkg/com/sun/tools/example/debug/event/WatchpointEventSet.java+66−0
@@ -0,0 +1,66 @@
1+/*
2+ * Copyright (c) 1999, Oracle and/or its affiliates. All rights reserved.
3+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+ *
5+ * This code is free software; you can redistribute it and/or modify it
6+ * under the terms of the GNU General Public License version 2 only, as
7+ * published by the Free Software Foundation. Oracle designates this
8+ * particular file as subject to the "Classpath" exception as provided
9+ * by Oracle in the LICENSE file that accompanied this code.
10+ *
11+ * This code is distributed in the hope that it will be useful, but WITHOUT
12+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+ * version 2 for more details (a copy is included in the LICENSE file that
15+ * accompanied this code).
16+ *
17+ * You should have received a copy of the GNU General Public License version
18+ * 2 along with this work; if not, write to the Free Software Foundation,
19+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+ *
21+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+ * or visit www.oracle.com if you need additional information or have any
23+ * questions.
24+ */
25+
26+package com.sun.tools.example.debug.event;
27+
28+import com.sun.jdi.*;
29+import com.sun.jdi.event.*;
30+
31+public abstract class WatchpointEventSet extends LocatableEventSet {
32+
33+ private static final long serialVersionUID = 5606285209703845409L;
34+
35+ WatchpointEventSet(EventSet jdiEventSet) {
36+ super(jdiEventSet);
37+ }
38+
39+ /**
40+ * Returns the field that is about to be accessed/modified.
41+ *
42+ * @return a {@link Field} which mirrors the field
43+ * in the target VM.
44+ */
45+ public Field getField() {
46+ return ((WatchpointEvent)oneEvent).field();
47+ }
48+
49+ /**
50+ * Returns the object whose field is about to be accessed/modified.
51+ * Return null is the access is to a static field.
52+ *
53+ * @return a {@link ObjectReference} which mirrors the event's
54+ * object in the target VM.
55+ */
56+ public ObjectReference getObject() {
57+ return ((WatchpointEvent)oneEvent).object();
58+ }
59+
60+ /**
61+ * Current value of the field.
62+ */
63+ public Value getValueCurrent() {
64+ return ((WatchpointEvent)oneEvent).valueCurrent();
65+ }
66+}
java/pkg/com/sun/tools/example/debug/event/mkfile+23−0
@@ -0,0 +1,23 @@
1+<../../../../../../../../mkconfig
2+
3+TARG=\
4+ AbstractEventSet.dis\
5+ AccessWatchpointEventSet.dis\
6+ ClassPrepareEventSet.dis\
7+ ClassUnloadEventSet.dis\
8+ ExceptionEventSet.dis\
9+ JDIAdapter.dis\
10+ JDIListener.dis\
11+ LocatableEventSet.dis\
12+ LocationTriggerEventSet.dis\
13+ ModificationWatchpointEventSet.dis\
14+ ThreadDeathEventSet.dis\
15+ ThreadStartEventSet.dis\
16+ VMDeathEventSet.dis\
17+ VMDisconnectEventSet.dis\
18+ VMStartEventSet.dis\
19+ WatchpointEventSet.dis\
20+
21+DISBIN=$ROOT/java/dis/java/java/com/sun/tools/example/debug/event
22+
23+<$ROOT/mkfiles/mkjava
java/pkg/com/sun/tools/example/debug/expr/ASCII_UCodeESC_CharStream.java+524−0
@@ -0,0 +1,524 @@
1+/*
2+ * Copyright (c) 1999, 2004, Oracle and/or its affiliates. All rights reserved.
3+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+ *
5+ * This code is free software; you can redistribute it and/or modify it
6+ * under the terms of the GNU General Public License version 2 only, as
7+ * published by the Free Software Foundation. Oracle designates this
8+ * particular file as subject to the "Classpath" exception as provided
9+ * by Oracle in the LICENSE file that accompanied this code.
10+ *
11+ * This code is distributed in the hope that it will be useful, but WITHOUT
12+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+ * version 2 for more details (a copy is included in the LICENSE file that
15+ * accompanied this code).
16+ *
17+ * You should have received a copy of the GNU General Public License version
18+ * 2 along with this work; if not, write to the Free Software Foundation,
19+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+ *
21+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+ * or visit www.oracle.com if you need additional information or have any
23+ * questions.
24+ */
25+
26+/* Generated By:JavaCC: Do not edit this line. ASCII_UCodeESC_CharStream.java Version 0.7pre6 */
27+
28+package com.sun.tools.example.debug.expr;
29+
30+/**
31+ * An implementation of interface CharStream, where the stream is assumed to
32+ * contain only ASCII characters (with java-like unicode escape processing).
33+ */
34+
35+public final class ASCII_UCodeESC_CharStream
36+{
37+ public static final boolean staticFlag = false;
38+ static final int hexval(char c) throws java.io.IOException {
39+ switch(c)
40+ {
41+ case '0' :
42+ return 0;
43+ case '1' :
44+ return 1;
45+ case '2' :
46+ return 2;
47+ case '3' :
48+ return 3;
49+ case '4' :
50+ return 4;
51+ case '5' :
52+ return 5;
53+ case '6' :
54+ return 6;
55+ case '7' :
56+ return 7;
57+ case '8' :
58+ return 8;
59+ case '9' :
60+ return 9;
61+
62+ case 'a' :
63+ case 'A' :
64+ return 10;
65+ case 'b' :
66+ case 'B' :
67+ return 11;
68+ case 'c' :
69+ case 'C' :
70+ return 12;
71+ case 'd' :
72+ case 'D' :
73+ return 13;
74+ case 'e' :
75+ case 'E' :
76+ return 14;
77+ case 'f' :
78+ case 'F' :
79+ return 15;
80+ }
81+
82+ throw new java.io.IOException(); // Should never come here
83+ }
84+
85+ public int bufpos = -1;
86+ int bufsize;
87+ int available;
88+ int tokenBegin;
89+ private int bufline[];
90+ private int bufcolumn[];
91+
92+ private int column = 0;
93+ private int line = 1;
94+
95+ private java.io.InputStream inputStream;
96+
97+ private boolean prevCharIsCR = false;
98+ private boolean prevCharIsLF = false;
99+
100+ private byte[] nextCharBuf;
101+ private char[] buffer;
102+ private int maxNextCharInd = 0;
103+ private int nextCharInd = -1;
104+ private int inBuf = 0;
105+
106+ private final void ExpandBuff(boolean wrapAround)
107+ {
108+ char[] newbuffer = new char[bufsize + 2048];
109+ int newbufline[] = new int[bufsize + 2048];
110+ int newbufcolumn[] = new int[bufsize + 2048];
111+
112+ try
113+ {
114+ if (wrapAround)
115+ {
116+ System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin);
117+ System.arraycopy(buffer, 0, newbuffer,
118+ bufsize - tokenBegin, bufpos);
119+ buffer = newbuffer;
120+
121+ System.arraycopy(bufline, tokenBegin, newbufline, 0, bufsize - tokenBegin);
122+ System.arraycopy(bufline, 0, newbufline, bufsize - tokenBegin, bufpos);
123+ bufline = newbufline;
124+
125+ System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0, bufsize - tokenBegin);
126+ System.arraycopy(bufcolumn, 0, newbufcolumn, bufsize - tokenBegin, bufpos);
127+ bufcolumn = newbufcolumn;
128+
129+ bufpos += (bufsize - tokenBegin);
130+ }
131+ else
132+ {
133+ System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin);
134+ buffer = newbuffer;
135+
136+ System.arraycopy(bufline, tokenBegin, newbufline, 0, bufsize - tokenBegin);
137+ bufline = newbufline;
138+
139+ System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0, bufsize - tokenBegin);
140+ bufcolumn = newbufcolumn;
141+
142+ bufpos -= tokenBegin;
143+ }
144+ }
145+ catch (Throwable t)
146+ {
147+ throw new Error(t.getMessage());
148+ }
149+
150+ available = (bufsize += 2048);
151+ tokenBegin = 0;
152+ }
153+
154+ private final void FillBuff() throws java.io.IOException
155+ {
156+ int i;
157+ if (maxNextCharInd == 4096)
158+ maxNextCharInd = nextCharInd = 0;
159+
160+ try {
161+ if ((i = inputStream.read(nextCharBuf, maxNextCharInd,
162+ 4096 - maxNextCharInd)) == -1)
163+ {
164+ inputStream.close();
165+ throw new java.io.IOException();
166+ }
167+ else
168+ maxNextCharInd += i;
169+ return;
170+ }
171+ catch(java.io.IOException e) {
172+ if (bufpos != 0)
173+ {
174+ --bufpos;
175+ backup(0);
176+ }
177+ else
178+ {
179+ bufline[bufpos] = line;
180+ bufcolumn[bufpos] = column;
181+ }
182+ throw e;
183+ }
184+ }
185+
186+ private final byte ReadByte() throws java.io.IOException
187+ {
188+ if (++nextCharInd >= maxNextCharInd)
189+ FillBuff();
190+
191+ return nextCharBuf[nextCharInd];
192+ }
193+
194+ public final char BeginToken() throws java.io.IOException
195+ {
196+ if (inBuf > 0)
197+ {
198+ --inBuf;
199+ return buffer[tokenBegin = (bufpos == bufsize - 1) ? (bufpos = 0)
200+ : ++bufpos];
201+ }
202+
203+ tokenBegin = 0;
204+ bufpos = -1;
205+
206+ return readChar();
207+ }
208+
209+ private final void AdjustBuffSize()
210+ {
211+ if (available == bufsize)
212+ {
213+ if (tokenBegin > 2048)
214+ {
215+ bufpos = 0;
216+ available = tokenBegin;
217+ }
218+ else
219+ ExpandBuff(false);
220+ }
221+ else if (available > tokenBegin)
222+ available = bufsize;
223+ else if ((tokenBegin - available) < 2048)
224+ ExpandBuff(true);
225+ else
226+ available = tokenBegin;
227+ }
228+
229+ private final void UpdateLineColumn(char c)
230+ {
231+ column++;
232+
233+ if (prevCharIsLF)
234+ {
235+ prevCharIsLF = false;
236+ line += (column = 1);
237+ }
238+ else if (prevCharIsCR)
239+ {
240+ prevCharIsCR = false;
241+ if (c == '\n')
242+ {
243+ prevCharIsLF = true;
244+ }
245+ else
246+ line += (column = 1);
247+ }
248+
249+ switch (c)
250+ {
251+ case '\r' :
252+ prevCharIsCR = true;
253+ break;
254+ case '\n' :
255+ prevCharIsLF = true;
256+ break;
257+ case '\t' :
258+ column--;
259+ column += (8 - (column & 07));
260+ break;
261+ default :
262+ break;
263+ }
264+
265+ bufline[bufpos] = line;
266+ bufcolumn[bufpos] = column;
267+ }
268+
269+ public final char readChar() throws java.io.IOException
270+ {
271+ if (inBuf > 0)
272+ {
273+ --inBuf;
274+ return buffer[(bufpos == bufsize - 1) ? (bufpos = 0) : ++bufpos];
275+ }
276+
277+ char c;
278+
279+ if (++bufpos == available)
280+ AdjustBuffSize();
281+
282+ if (((buffer[bufpos] = c = (char)((char)0xff & ReadByte())) == '\\'))
283+ {
284+ UpdateLineColumn(c);
285+
286+ int backSlashCnt = 1;
287+
288+ for (;;) // Read all the backslashes
289+ {
290+ if (++bufpos == available)
291+ AdjustBuffSize();
292+
293+ try
294+ {
295+ if ((buffer[bufpos] = c = (char)((char)0xff & ReadByte())) != '\\')
296+ {
297+ UpdateLineColumn(c);
298+ // found a non-backslash char.
299+ if ((c == 'u') && ((backSlashCnt & 1) == 1))
300+ {
301+ if (--bufpos < 0)
302+ bufpos = bufsize - 1;
303+
304+ break;
305+ }
306+
307+ backup(backSlashCnt);
308+ return '\\';
309+ }
310+ }
311+ catch(java.io.IOException e)
312+ {
313+ if (backSlashCnt > 1)
314+ backup(backSlashCnt);
315+
316+ return '\\';
317+ }
318+
319+ UpdateLineColumn(c);
320+ backSlashCnt++;
321+ }
322+
323+ // Here, we have seen an odd number of backslash's followed by a 'u'
324+ try
325+ {
326+ while ((c = (char)((char)0xff & ReadByte())) == 'u')
327+ ++column;
328+
329+ buffer[bufpos] = c = (char)(hexval(c) << 12 |
330+ hexval((char)((char)0xff & ReadByte())) << 8 |
331+ hexval((char)((char)0xff & ReadByte())) << 4 |
332+ hexval((char)((char)0xff & ReadByte())));
333+
334+ column += 4;
335+ }
336+ catch(java.io.IOException e)
337+ {
338+ throw new Error("Invalid escape character at line " + line +
339+ " column " + column + ".");
340+ }
341+
342+ if (backSlashCnt == 1)
343+ return c;
344+ else
345+ {
346+ backup(backSlashCnt - 1);
347+ return '\\';
348+ }
349+ }
350+ else
351+ {
352+ UpdateLineColumn(c);
353+ return (c);
354+ }
355+ }
356+
357+ /**
358+ * @deprecated
359+ * @see #getEndColumn
360+ */
361+ @Deprecated
362+ public final int getColumn() {
363+ return bufcolumn[bufpos];
364+ }
365+
366+ /**
367+ * @deprecated
368+ * @see #getEndLine
369+ */
370+ @Deprecated
371+ public final int getLine() {
372+ return bufline[bufpos];
373+ }
374+
375+ public final int getEndColumn() {
376+ return bufcolumn[bufpos];
377+ }
378+
379+ public final int getEndLine() {
380+ return bufline[bufpos];
381+ }
382+
383+ public final int getBeginColumn() {
384+ return bufcolumn[tokenBegin];
385+ }
386+
387+ public final int getBeginLine() {
388+ return bufline[tokenBegin];
389+ }
390+
391+ public final void backup(int amount) {
392+
393+ inBuf += amount;
394+ if ((bufpos -= amount) < 0)
395+ bufpos += bufsize;
396+ }
397+
398+ public ASCII_UCodeESC_CharStream(java.io.InputStream dstream,
399+ int startline, int startcolumn, int buffersize)
400+ {
401+ inputStream = dstream;
402+ line = startline;
403+ column = startcolumn - 1;
404+
405+ available = bufsize = buffersize;
406+ buffer = new char[buffersize];
407+ bufline = new int[buffersize];
408+ bufcolumn = new int[buffersize];
409+ nextCharBuf = new byte[4096];
410+ }
411+
412+ public ASCII_UCodeESC_CharStream(java.io.InputStream dstream,
413+ int startline, int startcolumn)
414+ {
415+ this(dstream, startline, startcolumn, 4096);
416+ }
417+ public void ReInit(java.io.InputStream dstream,
418+ int startline, int startcolumn, int buffersize)
419+ {
420+ inputStream = dstream;
421+ line = startline;
422+ column = startcolumn - 1;
423+
424+ if (buffer == null || buffersize != buffer.length)
425+ {
426+ available = bufsize = buffersize;
427+ buffer = new char[buffersize];
428+ bufline = new int[buffersize];
429+ bufcolumn = new int[buffersize];
430+ nextCharBuf = new byte[4096];
431+ }
432+ prevCharIsLF = prevCharIsCR = false;
433+ tokenBegin = inBuf = maxNextCharInd = 0;
434+ nextCharInd = bufpos = -1;
435+ }
436+
437+ public void ReInit(java.io.InputStream dstream,
438+ int startline, int startcolumn)
439+ {
440+ ReInit(dstream, startline, startcolumn, 4096);
441+ }
442+
443+ public final String GetImage()
444+ {
445+ if (bufpos >= tokenBegin)
446+ return new String(buffer, tokenBegin, bufpos - tokenBegin + 1);
447+ else
448+ return new String(buffer, tokenBegin, bufsize - tokenBegin) +
449+ new String(buffer, 0, bufpos + 1);
450+ }
451+
452+ public final char[] GetSuffix(int len)
453+ {
454+ char[] ret = new char[len];
455+
456+ if ((bufpos + 1) >= len)
457+ System.arraycopy(buffer, bufpos - len + 1, ret, 0, len);
458+ else
459+ {
460+ System.arraycopy(buffer, bufsize - (len - bufpos - 1), ret, 0,
461+ len - bufpos - 1);
462+ System.arraycopy(buffer, 0, ret, len - bufpos - 1, bufpos + 1);
463+ }
464+
465+ return ret;
466+ }
467+
468+ public void Done()
469+ {
470+ nextCharBuf = null;
471+ buffer = null;
472+ bufline = null;
473+ bufcolumn = null;
474+ }
475+
476+ /**
477+ * Method to adjust line and column numbers for the start of a token.<BR>
478+ */
479+ public void adjustBeginLineColumn(int newLine, int newCol)
480+ {
481+ int start = tokenBegin;
482+ int len;
483+
484+ if (bufpos >= tokenBegin)
485+ {
486+ len = bufpos - tokenBegin + inBuf + 1;
487+ }
488+ else
489+ {
490+ len = bufsize - tokenBegin + bufpos + 1 + inBuf;
491+ }
492+
493+ int i = 0, j = 0, k = 0;
494+ int nextColDiff = 0, columnDiff = 0;
495+
496+ while (i < len &&
497+ bufline[j = start % bufsize] == bufline[k = ++start % bufsize])
498+ {
499+ bufline[j] = newLine;
500+ nextColDiff = columnDiff + bufcolumn[k] - bufcolumn[j];
501+ bufcolumn[j] = newCol + columnDiff;
502+ columnDiff = nextColDiff;
503+ i++;
504+ }
505+
506+ if (i < len)
507+ {
508+ bufline[j] = newLine++;
509+ bufcolumn[j] = newCol + columnDiff;
510+
511+ while (i++ < len)
512+ {
513+ if (bufline[j = start % bufsize] != bufline[++start % bufsize])
514+ bufline[j] = newLine++;
515+ else
516+ bufline[j] = newLine;
517+ }
518+ }
519+
520+ line = bufline[j];
521+ column = bufcolumn[j];
522+ }
523+
524+}
java/pkg/com/sun/tools/example/debug/expr/Expr.jj+724−0
@@ -0,0 +1,724 @@
1+/*
2+ * Copyright (c) 1998, 2003, Oracle and/or its affiliates. All rights reserved.
3+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+ *
5+ * This code is free software; you can redistribute it and/or modify it
6+ * under the terms of the GNU General Public License version 2 only, as
7+ * published by the Free Software Foundation. Oracle designates this
8+ * particular file as subject to the "Classpath" exception as provided
9+ * by Oracle in the LICENSE file that accompanied this code.
10+ *
11+ * This code is distributed in the hope that it will be useful, but WITHOUT
12+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+ * version 2 for more details (a copy is included in the LICENSE file that
15+ * accompanied this code).
16+ *
17+ * You should have received a copy of the GNU General Public License version
18+ * 2 along with this work; if not, write to the Free Software Foundation,
19+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+ *
21+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+ * or visit www.oracle.com if you need additional information or have any
23+ * questions.
24+ */
25+
26+options {
27+ JAVA_UNICODE_ESCAPE = true;
28+ STATIC = false;
29+}
30+
31+PARSER_BEGIN(ExpressionParser)
32+
33+package com.sun.tools.example.debug.expr;
34+
35+import com.sun.jdi.*;
36+import java.util.Stack;
37+import java.util.List;
38+import java.util.ArrayList;
39+
40+public class ExpressionParser {
41+
42+ Stack stack = new Stack();
43+ VirtualMachine vm = null;
44+ GetFrame frameGetter = null;
45+ private static GetFrame lastFrameGetter;
46+ private static LValue lastLValue;
47+
48+ LValue peek() {
49+ return (LValue)stack.peek();
50+ }
51+
52+ LValue pop() {
53+ return (LValue)stack.pop();
54+ }
55+
56+ void push(LValue lval) {
57+ stack.push(lval);
58+ }
59+
60+ public static Value getMassagedValue() throws ParseException {
61+ return lastLValue.getMassagedValue(lastFrameGetter);
62+ }
63+
64+ public interface GetFrame {
65+ StackFrame get() throws IncompatibleThreadStateException;
66+ }
67+
68+ public static Value evaluate(String expr, VirtualMachine vm,
69+ GetFrame frameGetter) throws ParseException,
70+ InvocationException,
71+ InvalidTypeException,
72+ ClassNotLoadedException,
73+ IncompatibleThreadStateException {
74+ // TODO StringBufferInputStream is deprecated.
75+ java.io.InputStream in = new java.io.StringBufferInputStream(expr);
76+ ExpressionParser parser = new ExpressionParser(in);
77+ parser.vm = vm;
78+ parser.frameGetter = frameGetter;
79+ Value value = null;
80+ parser.Expression();
81+ lastFrameGetter = frameGetter;
82+ lastLValue = parser.pop();
83+ return lastLValue.getValue();
84+ }
85+
86+ public static void main(String args[]) {
87+ ExpressionParser parser;
88+ System.out.print("Java Expression Parser: ");
89+ if (args.length == 0) {
90+ System.out.println("Reading from standard input . . .");
91+ parser = new ExpressionParser(System.in);
92+ } else if (args.length == 1) {
93+ System.out.println("Reading from file " + args[0] + " . . .");
94+ try {
95+ parser = new ExpressionParser(new java.io.FileInputStream(args[0]));
96+ } catch (java.io.FileNotFoundException e) {
97+ System.out.println("Java Parser Version 1.0.2: File " +
98+ args[0] + " not found.");
99+ return;
100+ }
101+ } else {
102+ System.out.println("Usage is one of:");
103+ System.out.println(" java ExpressionParser < inputfile");
104+ System.out.println("OR");
105+ System.out.println(" java ExpressionParser inputfile");
106+ return;
107+ }
108+ try {
109+ parser.Expression();
110+ System.out.print("Java Expression Parser: ");
111+ System.out.println("Java program parsed successfully.");
112+ } catch (ParseException e) {
113+ System.out.print("Java Expression Parser: ");
114+ System.out.println("Encountered errors during parse.");
115+ }
116+ }
117+
118+}
119+
120+PARSER_END(ExpressionParser)
121+
122+
123+SKIP : /* WHITE SPACE */
124+{
125+ " "
126+| "\t"
127+| "\n"
128+| "\r"
129+| "\f"
130+}
131+
132+SPECIAL_TOKEN : /* COMMENTS */
133+{
134+ <SINGLE_LINE_COMMENT: "//" (~["\n","\r"])* ("\n"|"\r"|"\r\n")>
135+| <FORMAL_COMMENT: "/**" (~["*"])* "*" ("*" | (~["*","/"] (~["*"])* "*"))* "/">
136+| <MULTI_LINE_COMMENT: "/*" (~["*"])* "*" ("*" | (~["*","/"] (~["*"])* "*"))* "/">
137+}
138+
139+TOKEN : /* RESERVED WORDS AND LITERALS */
140+{
141+ < ABSTRACT: "abstract" >
142+| < BOOLEAN: "boolean" >
143+| < BREAK: "break" >
144+| < BYTE: "byte" >
145+| < CASE: "case" >
146+| < CATCH: "catch" >
147+| < CHAR: "char" >
148+| < CLASS: "class" >
149+| < CONST: "const" >
150+| < CONTINUE: "continue" >
151+| < _DEFAULT: "default" >
152+| < DO: "do" >
153+| < DOUBLE: "double" >
154+| < ELSE: "else" >
155+| < EXTENDS: "extends" >
156+| < FALSE: "false" >
157+| < FINAL: "final" >
158+| < FINALLY: "finally" >
159+| < FLOAT: "float" >
160+| < FOR: "for" >
161+| < GOTO: "goto" >
162+| < IF: "if" >
163+| < IMPLEMENTS: "implements" >
164+| < IMPORT: "import" >
165+| < INSTANCEOF: "instanceof" >
166+| < INT: "int" >
167+| < INTERFACE: "interface" >
168+| < LONG: "long" >
169+| < NATIVE: "native" >
170+| < NEW: "new" >
171+| < NULL: "null" >
172+| < PACKAGE: "package">
173+| < PRIVATE: "private" >
174+| < PROTECTED: "protected" >
175+| < PUBLIC: "public" >
176+| < RETURN: "return" >
177+| < SHORT: "short" >
178+| < STATIC: "static" >
179+| < SUPER: "super" >
180+| < SWITCH: "switch" >
181+| < SYNCHRONIZED: "synchronized" >
182+| < THIS: "this" >
183+| < THROW: "throw" >
184+| < THROWS: "throws" >
185+| < TRANSIENT: "transient" >
186+| < TRUE: "true" >
187+| < TRY: "try" >
188+| < VOID: "void" >
189+| < VOLATILE: "volatile" >
190+| < WHILE: "while" >
191+}
192+
193+TOKEN : /* LITERALS */
194+{
195+ <
196+ INTEGER_LITERAL:
197+ <DECIMAL_LITERAL> (["l","L"])?
198+ | <HEX_LITERAL> (["l","L"])?
199+ | <OCTAL_LITERAL> (["l","L"])?
200+ >
201+|
202+ < #DECIMAL_LITERAL: ["1"-"9"] (["0"-"9"])* >
203+|
204+ < #HEX_LITERAL: "0" ["x","X"] (["0"-"9","a"-"f","A"-"F"])+ >
205+|
206+ < #OCTAL_LITERAL: "0" (["0"-"7"])* >
207+|
208+ < FLOATING_POINT_LITERAL:
209+ (["0"-"9"])+ "." (["0"-"9"])* (<EXPONENT>)? (["f","F","d","D"])?
210+ | "." (["0"-"9"])+ (<EXPONENT>)? (["f","F","d","D"])?
211+ | (["0"-"9"])+ <EXPONENT> (["f","F","d","D"])?
212+ | (["0"-"9"])+ (<EXPONENT>)? ["f","F","d","D"]
213+ >
214+|
215+ < #EXPONENT: ["e","E"] (["+","-"])? (["0"-"9"])+ >
216+|
217+ < CHARACTER_LITERAL:
218+ "'"
219+ ( (~["'","\\","\n","\r"])
220+ | ("\\"
221+ ( ["n","t","b","r","f","\\","'","\""]
222+ | ["0"-"7"] ( ["0"-"7"] )?
223+ | ["0"-"3"] ["0"-"7"] ["0"-"7"]
224+ )
225+ )
226+ )
227+ "'"
228+ >
229+|
230+ < STRING_LITERAL:
231+ "\""
232+ ( (~["\"","\\","\n","\r"])
233+ | ("\\"
234+ ( ["n","t","b","r","f","\\","'","\""]
235+ | ["0"-"7"] ( ["0"-"7"] )?
236+ | ["0"-"3"] ["0"-"7"] ["0"-"7"]
237+ )
238+ )
239+ )*
240+ "\""
241+ >
242+}
243+
244+TOKEN : /* IDENTIFIERS */
245+{
246+ < IDENTIFIER: <LETTER> (<LETTER>|<DIGIT>)* >
247+|
248+ < #LETTER:
249+ [
250+ "\u0024",
251+ "\u0041"-"\u005a",
252+ "\u005f",
253+ "\u0061"-"\u007a",
254+ "\u00c0"-"\u00d6",
255+ "\u00d8"-"\u00f6",
256+ "\u00f8"-"\u00ff",
257+ "\u0100"-"\u1fff",
258+ "\u3040"-"\u318f",
259+ "\u3300"-"\u337f",
260+ "\u3400"-"\u3d2d",
261+ "\u4e00"-"\u9fff",
262+ "\uf900"-"\ufaff"
263+ ]
264+ >
265+|
266+ < #DIGIT:
267+ [
268+ "\u0030"-"\u0039",
269+ "\u0660"-"\u0669",
270+ "\u06f0"-"\u06f9",
271+ "\u0966"-"\u096f",
272+ "\u09e6"-"\u09ef",
273+ "\u0a66"-"\u0a6f",
274+ "\u0ae6"-"\u0aef",
275+ "\u0b66"-"\u0b6f",
276+ "\u0be7"-"\u0bef",
277+ "\u0c66"-"\u0c6f",
278+ "\u0ce6"-"\u0cef",
279+ "\u0d66"-"\u0d6f",
280+ "\u0e50"-"\u0e59",
281+ "\u0ed0"-"\u0ed9",
282+ "\u1040"-"\u1049"
283+ ]
284+ >
285+}
286+
287+TOKEN : /* SEPARATORS */
288+{
289+ < LPAREN: "(" >
290+| < RPAREN: ")" >
291+| < LBRACE: "{" >
292+| < RBRACE: "}" >
293+| < LBRACKET: "[" >
294+| < RBRACKET: "]" >
295+| < SEMICOLON: ";" >
296+| < COMMA: "," >
297+| < DOT: "." >
298+}
299+
300+TOKEN : /* OPERATORS */
301+{
302+ < ASSIGN: "=" >
303+| < GT: ">" >
304+| < LT: "<" >
305+| < BANG: "!" >
306+| < TILDE: "~" >
307+| < HOOK: "?" >
308+| < COLON: ":" >
309+| < EQ: "==" >
310+| < LE: "<=" >
311+| < GE: ">=" >
312+| < NE: "!=" >
313+| < SC_OR: "||" >
314+| < SC_AND: "&&" >
315+| < INCR: "++" >
316+| < DECR: "--" >
317+| < PLUS: "+" >
318+| < MINUS: "-" >
319+| < STAR: "*" >
320+| < SLASH: "/" >
321+| < BIT_AND: "&" >
322+| < BIT_OR: "|" >
323+| < XOR: "^" >
324+| < REM: "%" >
325+| < LSHIFT: "<<" >
326+| < RSIGNEDSHIFT: ">>" >
327+| < RUNSIGNEDSHIFT: ">>>" >
328+| < PLUSASSIGN: "+=" >
329+| < MINUSASSIGN: "-=" >
330+| < STARASSIGN: "*=" >
331+| < SLASHASSIGN: "/=" >
332+| < ANDASSIGN: "&=" >
333+| < ORASSIGN: "|=" >
334+| < XORASSIGN: "^=" >
335+| < REMASSIGN: "%=" >
336+| < LSHIFTASSIGN: "<<=" >
337+| < RSIGNEDSHIFTASSIGN: ">>=" >
338+| < RUNSIGNEDSHIFTASSIGN: ">>>=" >
339+}
340+
341+
342+/*****************************************
343+ * THE JAVA LANGUAGE GRAMMAR STARTS HERE *
344+ *****************************************/
345+
346+/*
347+ * Type, name and expression syntax follows.
348+ */
349+
350+void Type() :
351+{}
352+{
353+ ( PrimitiveType() | Name() ) ( "[" "]" )*
354+}
355+
356+void PrimitiveType() :
357+{}
358+{
359+ "boolean"
360+|
361+ "char"
362+|
363+ "byte"
364+|
365+ "short"
366+|
367+ "int"
368+|
369+ "long"
370+|
371+ "float"
372+|
373+ "double"
374+}
375+
376+
377+String Name() :
378+{StringBuffer sb = new StringBuffer();}
379+{
380+ <IDENTIFIER> { sb.append(token); }
381+ ( LOOKAHEAD(2) "." <IDENTIFIER> { sb.append('.'); sb.append(token); }
382+ )*
383+ { return sb.toString(); }
384+}
385+
386+void NameList() :
387+{}
388+{
389+ Name()
390+ ( "," Name()
391+ )*
392+}
393+
394+
395+/*
396+ * Expression syntax follows.
397+ */
398+
399+void Expression() :
400+{}
401+{
402+ LOOKAHEAD( PrimaryExpression() AssignmentOperator() )
403+ Assignment()
404+|
405+ ConditionalExpression()
406+}
407+
408+void Assignment() :
409+{}
410+{
411+ PrimaryExpression() AssignmentOperator() Expression()
412+ { LValue exprVal = pop(); pop().setValue(exprVal); push(exprVal);}
413+}
414+
415+void AssignmentOperator() :
416+{}
417+{
418+ "=" | "*=" | "/=" | "%=" | "+=" | "-=" | "<<=" | ">>=" | ">>>=" | "&=" | "^=" | "|="
419+}
420+
421+void ConditionalExpression() :
422+{}
423+{
424+ ConditionalOrExpression()
425+ [ "?" Expression() ":" ConditionalExpression()
426+ { LValue falseBranch = pop(); LValue trueBranch = pop();
427+ Value cond = pop().interiorGetValue();
428+ if (cond instanceof BooleanValue) {
429+ push(((BooleanValue)cond).booleanValue()?
430+ trueBranch : falseBranch);
431+ } else {
432+ throw new ParseException("Condition must be boolean");
433+ }
434+ }
435+ ]
436+}
437+
438+void ConditionalOrExpression() :
439+{}
440+{
441+ ConditionalAndExpression()
442+ ( "||" ConditionalAndExpression()
443+ { throw new ParseException("operation not yet supported"); }
444+ )*
445+}
446+
447+void ConditionalAndExpression() :
448+{}
449+{
450+ InclusiveOrExpression()
451+ ( "&&" InclusiveOrExpression()
452+ { throw new ParseException("operation not yet supported"); }
453+ )*
454+}
455+
456+void InclusiveOrExpression() :
457+{}
458+{
459+ ExclusiveOrExpression()
460+ ( "|" ExclusiveOrExpression()
461+ { throw new ParseException("operation not yet supported"); }
462+ )*
463+}
464+
465+void ExclusiveOrExpression() :
466+{}
467+{
468+ AndExpression()
469+ ( "^" AndExpression()
470+ { throw new ParseException("operation not yet supported"); }
471+ )*
472+}
473+
474+void AndExpression() :
475+{}
476+{
477+ EqualityExpression()
478+ ( "&" EqualityExpression()
479+ { throw new ParseException("operation not yet supported"); }
480+ )*
481+}
482+
483+void EqualityExpression() :
484+{Token tok;}
485+{
486+ InstanceOfExpression()
487+ ( ( tok = "==" | tok = "!=" ) InstanceOfExpression()
488+ { LValue left = pop();
489+ push( LValue.booleanOperation(vm, tok, pop(), left) ); }
490+ )*
491+}
492+
493+void InstanceOfExpression() :
494+{}
495+{
496+ RelationalExpression()
497+ [ "instanceof" Type()
498+ { throw new ParseException("operation not yet supported"); }
499+ ]
500+}
501+
502+void RelationalExpression() :
503+{Token tok;}
504+{
505+ ShiftExpression()
506+ ( ( tok = "<" | tok = ">" | tok = "<=" | tok = ">=" ) ShiftExpression()
507+ { LValue left = pop();
508+ push( LValue.booleanOperation(vm, tok, pop(), left) ); }
509+ )*
510+}
511+
512+void ShiftExpression() :
513+{}
514+{
515+ AdditiveExpression()
516+ ( ( "<<" | ">>" | ">>>" ) AdditiveExpression()
517+ { throw new ParseException("operation not yet supported"); }
518+ )*
519+}
520+
521+void AdditiveExpression() :
522+{Token tok;}
523+{
524+ MultiplicativeExpression()
525+ ( ( tok = "+" | tok = "-" ) MultiplicativeExpression()
526+ { LValue left = pop();
527+ push( LValue.operation(vm, tok, pop(), left, frameGetter) ); }
528+ )*
529+}
530+
531+void MultiplicativeExpression() :
532+{Token tok;}
533+{
534+ UnaryExpression()
535+ ( ( tok = "*" | tok = "/" | tok = "%" ) UnaryExpression()
536+ { LValue left = pop();
537+ push( LValue.operation(vm, tok, pop(), left, frameGetter) ); }
538+ )*
539+}
540+
541+void UnaryExpression() :
542+{}
543+{
544+ ( "+" | "-" ) UnaryExpression()
545+ { throw new ParseException("operation not yet supported"); }
546+|
547+ PreIncrementExpression()
548+|
549+ PreDecrementExpression()
550+|
551+ UnaryExpressionNotPlusMinus()
552+}
553+
554+void PreIncrementExpression() :
555+{}
556+{
557+ "++" PrimaryExpression()
558+ { throw new ParseException("operation not yet supported"); }
559+}
560+
561+void PreDecrementExpression() :
562+{}
563+{
564+ "--" PrimaryExpression()
565+ { throw new ParseException("operation not yet supported"); }
566+}
567+
568+void UnaryExpressionNotPlusMinus() :
569+{}
570+{
571+ ( "~" | "!" ) UnaryExpression()
572+ { throw new ParseException("operation not yet supported"); }
573+|
574+ LOOKAHEAD( CastLookahead() )
575+ CastExpression()
576+|
577+ PostfixExpression()
578+}
579+
580+// This production is to determine lookahead only. The LOOKAHEAD specifications
581+// below are not used, but they are there just to indicate that we know about
582+// this.
583+void CastLookahead() :
584+{}
585+{
586+ LOOKAHEAD(2)
587+ "(" PrimitiveType()
588+|
589+ LOOKAHEAD("(" Name() "[")
590+ "(" Name() "[" "]"
591+|
592+ "(" Name() ")" ( "~" | "!" | "(" | <IDENTIFIER> | "this" | "super" | "new" | Literal() )
593+}
594+
595+void PostfixExpression() :
596+{}
597+{
598+ PrimaryExpression()
599+ [ "++" | "--"
600+ { throw new ParseException("operation not yet supported"); }
601+ ]
602+}
603+
604+void CastExpression() :
605+{}
606+{
607+ LOOKAHEAD(2)
608+ "(" PrimitiveType() ( "[" "]" )* ")" UnaryExpression()
609+|
610+ "(" Name() ( "[" "]" )* ")" UnaryExpressionNotPlusMinus()
611+}
612+
613+void PrimaryExpression() :
614+{}
615+{
616+ PrimaryPrefix() ( PrimarySuffix() )*
617+}
618+
619+void PrimaryPrefix() :
620+{String name;}
621+{
622+ Literal()
623+|
624+ name = Name()
625+ { push(LValue.makeName(vm, frameGetter, name)); }
626+|
627+ "this"
628+ { push(LValue.makeThisObject(vm, frameGetter, token)); }
629+|
630+ "super" "." <IDENTIFIER>
631+ { throw new ParseException("operation not yet supported"); }
632+|
633+ "(" Expression() ")"
634+|
635+ AllocationExpression()
636+}
637+
638+void PrimarySuffix() :
639+{List argList;}
640+{
641+ "[" Expression() "]"
642+ { LValue index = pop();
643+ push(pop().arrayElementLValue(index)); }
644+|
645+ "." <IDENTIFIER>
646+ { push(pop().memberLValue(frameGetter, token.image)); }
647+|
648+ argList = Arguments()
649+ { peek().invokeWith(argList); }
650+}
651+
652+void Literal() :
653+{}
654+{
655+ <INTEGER_LITERAL>
656+ { push(LValue.makeInteger(vm, token)); }
657+|
658+ <FLOATING_POINT_LITERAL>
659+ { push(LValue.makeFloat(vm, token)); }
660+|
661+ <CHARACTER_LITERAL>
662+ { push(LValue.makeCharacter(vm, token)); }
663+|
664+ <STRING_LITERAL>
665+ { push(LValue.makeString(vm, token)); }
666+|
667+ BooleanLiteral()
668+ { push(LValue.makeBoolean(vm, token)); }
669+|
670+ NullLiteral()
671+ { push(LValue.makeNull(vm, token)); }
672+}
673+
674+void BooleanLiteral() :
675+{}
676+{
677+ "true"
678+|
679+ "false"
680+}
681+
682+void NullLiteral() :
683+{}
684+{
685+ "null"
686+}
687+
688+List Arguments() :
689+{List argList = new ArrayList();}
690+{
691+ "(" [ ArgumentList(argList) ] ")"
692+ { return argList; }
693+}
694+
695+void ArgumentList(List argList) :
696+{}
697+{
698+ Expression() {argList.add(pop().interiorGetValue());}
699+ ( "," Expression() {argList.add(pop().interiorGetValue());} )*
700+}
701+
702+void AllocationExpression() :
703+{List argList; String className;}
704+{
705+ LOOKAHEAD(2)
706+ "new" PrimitiveType() ArrayDimensions()
707+|
708+ "new" className = Name() ( argList = Arguments()
709+ { push(LValue.makeNewObject(vm, frameGetter, className, argList)); }
710+ | ArrayDimensions()
711+ { throw new ParseException("operation not yet supported"); }
712+ )
713+}
714+
715+/*
716+ * The second LOOKAHEAD specification below is to parse to PrimarySuffix
717+ * if there is an expression between the "[...]".
718+ */
719+void ArrayDimensions() :
720+{}
721+{
722+ ( LOOKAHEAD(2) "[" Expression() "]" )+ ( LOOKAHEAD(2) "[" "]" )*
723+}
724+
java/pkg/com/sun/tools/example/debug/expr/ExpressionParser.java+3933−0
@@ -0,0 +1,3933 @@
1+/*
2+ * Copyright (c) 1999, 2003, Oracle and/or its affiliates. All rights reserved.
3+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+ *
5+ * This code is free software; you can redistribute it and/or modify it
6+ * under the terms of the GNU General Public License version 2 only, as
7+ * published by the Free Software Foundation. Oracle designates this
8+ * particular file as subject to the "Classpath" exception as provided
9+ * by Oracle in the LICENSE file that accompanied this code.
10+ *
11+ * This code is distributed in the hope that it will be useful, but WITHOUT
12+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+ * version 2 for more details (a copy is included in the LICENSE file that
15+ * accompanied this code).
16+ *
17+ * You should have received a copy of the GNU General Public License version
18+ * 2 along with this work; if not, write to the Free Software Foundation,
19+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+ *
21+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+ * or visit www.oracle.com if you need additional information or have any
23+ * questions.
24+ */
25+
26+/* Generated By:JavaCC: Do not edit this line. ExpressionParser.java */
27+package com.sun.tools.example.debug.expr;
28+
29+import com.sun.jdi.*;
30+
31+import java.util.Stack;
32+import java.util.List;
33+import java.util.ArrayList;
34+
35+public class ExpressionParser implements ExpressionParserConstants {
36+
37+ Stack<LValue> stack = new Stack<LValue>();
38+ VirtualMachine vm = null;
39+ GetFrame frameGetter = null;
40+ private static GetFrame lastFrameGetter;
41+ private static LValue lastLValue;
42+
43+ LValue peek() {
44+ return stack.peek();
45+ }
46+
47+ LValue pop() {
48+ return stack.pop();
49+ }
50+
51+ void push(LValue lval) {
52+ stack.push(lval);
53+ }
54+
55+ public static Value getMassagedValue() throws ParseException {
56+ return lastLValue.getMassagedValue(lastFrameGetter);
57+ }
58+
59+ public interface GetFrame {
60+ StackFrame get() throws IncompatibleThreadStateException;
61+ }
62+
63+ public static Value evaluate(String expr, VirtualMachine vm,
64+ GetFrame frameGetter) throws ParseException, InvocationException,
65+ InvalidTypeException, ClassNotLoadedException,
66+ IncompatibleThreadStateException {
67+ // TODO StringBufferInputStream is deprecated.
68+ java.io.InputStream in = new java.io.StringBufferInputStream(expr);
69+ ExpressionParser parser = new ExpressionParser(in);
70+ parser.vm = vm;
71+ parser.frameGetter = frameGetter;
72+ parser.Expression();
73+ lastFrameGetter = frameGetter;
74+ lastLValue = parser.pop();
75+ return lastLValue.getValue();
76+ }
77+
78+ public static void main(String args[]) {
79+ ExpressionParser parser;
80+ System.out.print("Java Expression Parser: ");
81+ if (args.length == 0) {
82+ System.out.println("Reading from standard input . . .");
83+ parser = new ExpressionParser(System.in);
84+ } else if (args.length == 1) {
85+ System.out.println("Reading from file " + args[0] + " . . .");
86+ try {
87+ parser = new ExpressionParser(new java.io.FileInputStream(args[0]));
88+ } catch (java.io.FileNotFoundException e) {
89+ System.out.println("Java Parser Version 1.0.2: File " + args[0]
90+ + " not found.");
91+ return;
92+ }
93+ } else {
94+ System.out.println("Usage is one of:");
95+ System.out.println(" java ExpressionParser < inputfile");
96+ System.out.println("OR");
97+ System.out.println(" java ExpressionParser inputfile");
98+ return;
99+ }
100+ try {
101+ parser.Expression();
102+ System.out.print("Java Expression Parser: ");
103+ System.out.println("Java program parsed successfully.");
104+ } catch (ParseException e) {
105+ System.out.print("Java Expression Parser: ");
106+ System.out.println("Encountered errors during parse.");
107+ }
108+ }
109+
110+/*****************************************
111+ * THE JAVA LANGUAGE GRAMMAR STARTS HERE *
112+ *****************************************/
113+
114+/*
115+ * Type, name and expression syntax follows.
116+ */
117+ final public void Type() throws ParseException {
118+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
119+ case BOOLEAN:
120+ case BYTE:
121+ case CHAR:
122+ case DOUBLE:
123+ case FLOAT:
124+ case INT:
125+ case LONG:
126+ case SHORT:
127+ PrimitiveType();
128+ break;
129+ case IDENTIFIER:
130+ Name();
131+ break;
132+ default:
133+ jj_la1[0] = jj_gen;
134+ jj_consume_token(-1);
135+ throw new ParseException();
136+ }
137+ label_1: while (true) {
138+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
139+ case LBRACKET:
140+ ;
141+ break;
142+ default:
143+ jj_la1[1] = jj_gen;
144+ break label_1;
145+ }
146+ jj_consume_token(LBRACKET);
147+ jj_consume_token(RBRACKET);
148+ }
149+ }
150+
151+ final public void PrimitiveType() throws ParseException {
152+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
153+ case BOOLEAN:
154+ jj_consume_token(BOOLEAN);
155+ break;
156+ case CHAR:
157+ jj_consume_token(CHAR);
158+ break;
159+ case BYTE:
160+ jj_consume_token(BYTE);
161+ break;
162+ case SHORT:
163+ jj_consume_token(SHORT);
164+ break;
165+ case INT:
166+ jj_consume_token(INT);
167+ break;
168+ case LONG:
169+ jj_consume_token(LONG);
170+ break;
171+ case FLOAT:
172+ jj_consume_token(FLOAT);
173+ break;
174+ case DOUBLE:
175+ jj_consume_token(DOUBLE);
176+ break;
177+ default:
178+ jj_la1[2] = jj_gen;
179+ jj_consume_token(-1);
180+ throw new ParseException();
181+ }
182+ }
183+
184+ final public String Name() throws ParseException {
185+ StringBuffer sb = new StringBuffer();
186+ jj_consume_token(IDENTIFIER);
187+ sb.append(token);
188+ label_2: while (true) {
189+ if (jj_2_1(2)) {
190+ ;
191+ } else {
192+ break label_2;
193+ }
194+ jj_consume_token(DOT);
195+ jj_consume_token(IDENTIFIER);
196+ sb.append('.');
197+ sb.append(token);
198+ }
199+ if (true) {
200+ return sb.toString();
201+ }
202+ throw new Error("Missing return statement in function");
203+ }
204+
205+ final public void NameList() throws ParseException {
206+ Name();
207+ label_3: while (true) {
208+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
209+ case COMMA:
210+ ;
211+ break;
212+ default:
213+ jj_la1[3] = jj_gen;
214+ break label_3;
215+ }
216+ jj_consume_token(COMMA);
217+ Name();
218+ }
219+ }
220+
221+/*
222+ * Expression syntax follows.
223+ */
224+ final public void Expression() throws ParseException {
225+ if (jj_2_2(2147483647)) {
226+ Assignment();
227+ } else {
228+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
229+ case FALSE:
230+ case NEW:
231+ case NULL:
232+ case SUPER:
233+ case THIS:
234+ case TRUE:
235+ case INTEGER_LITERAL:
236+ case FLOATING_POINT_LITERAL:
237+ case CHARACTER_LITERAL:
238+ case STRING_LITERAL:
239+ case IDENTIFIER:
240+ case LPAREN:
241+ case BANG:
242+ case TILDE:
243+ case INCR:
244+ case DECR:
245+ case PLUS:
246+ case MINUS:
247+ ConditionalExpression();
248+ break;
249+ default:
250+ jj_la1[4] = jj_gen;
251+ jj_consume_token(-1);
252+ throw new ParseException();
253+ }
254+ }
255+ }
256+
257+ final public void Assignment() throws ParseException {
258+ PrimaryExpression();
259+ AssignmentOperator();
260+ Expression();
261+ LValue exprVal = pop();
262+ pop().setValue(exprVal);
263+ push(exprVal);
264+ }
265+
266+ final public void AssignmentOperator() throws ParseException {
267+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
268+ case ASSIGN:
269+ jj_consume_token(ASSIGN);
270+ break;
271+ case STARASSIGN:
272+ jj_consume_token(STARASSIGN);
273+ break;
274+ case SLASHASSIGN:
275+ jj_consume_token(SLASHASSIGN);
276+ break;
277+ case REMASSIGN:
278+ jj_consume_token(REMASSIGN);
279+ break;
280+ case PLUSASSIGN:
281+ jj_consume_token(PLUSASSIGN);
282+ break;
283+ case MINUSASSIGN:
284+ jj_consume_token(MINUSASSIGN);
285+ break;
286+ case LSHIFTASSIGN:
287+ jj_consume_token(LSHIFTASSIGN);
288+ break;
289+ case RSIGNEDSHIFTASSIGN:
290+ jj_consume_token(RSIGNEDSHIFTASSIGN);
291+ break;
292+ case RUNSIGNEDSHIFTASSIGN:
293+ jj_consume_token(RUNSIGNEDSHIFTASSIGN);
294+ break;
295+ case ANDASSIGN:
296+ jj_consume_token(ANDASSIGN);
297+ break;
298+ case XORASSIGN:
299+ jj_consume_token(XORASSIGN);
300+ break;
301+ case ORASSIGN:
302+ jj_consume_token(ORASSIGN);
303+ break;
304+ default:
305+ jj_la1[5] = jj_gen;
306+ jj_consume_token(-1);
307+ throw new ParseException();
308+ }
309+ }
310+
311+ final public void ConditionalExpression() throws ParseException {
312+ ConditionalOrExpression();
313+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
314+ case HOOK:
315+ jj_consume_token(HOOK);
316+ Expression();
317+ jj_consume_token(COLON);
318+ ConditionalExpression();
319+ LValue falseBranch = pop();
320+ LValue trueBranch = pop();
321+ Value cond = pop().interiorGetValue();
322+ if (cond instanceof BooleanValue) {
323+ push(((BooleanValue) cond).booleanValue() ? trueBranch
324+ : falseBranch);
325+ } else {
326+ {
327+ if (true) {
328+ throw new ParseException("Condition must be boolean");
329+ }
330+ }
331+ }
332+ break;
333+ default:
334+ jj_la1[6] = jj_gen;
335+ ;
336+ }
337+ }
338+
339+ final public void ConditionalOrExpression() throws ParseException {
340+ ConditionalAndExpression();
341+ label_4: while (true) {
342+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
343+ case SC_OR:
344+ ;
345+ break;
346+ default:
347+ jj_la1[7] = jj_gen;
348+ break label_4;
349+ }
350+ jj_consume_token(SC_OR);
351+ ConditionalAndExpression();
352+ {
353+ if (true) {
354+ throw new ParseException("operation not yet supported");
355+ }
356+ }
357+ }
358+ }
359+
360+ final public void ConditionalAndExpression() throws ParseException {
361+ InclusiveOrExpression();
362+ label_5: while (true) {
363+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
364+ case SC_AND:
365+ ;
366+ break;
367+ default:
368+ jj_la1[8] = jj_gen;
369+ break label_5;
370+ }
371+ jj_consume_token(SC_AND);
372+ InclusiveOrExpression();
373+ {
374+ if (true) {
375+ throw new ParseException("operation not yet supported");
376+ }
377+ }
378+ }
379+ }
380+
381+ final public void InclusiveOrExpression() throws ParseException {
382+ ExclusiveOrExpression();
383+ label_6: while (true) {
384+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
385+ case BIT_OR:
386+ ;
387+ break;
388+ default:
389+ jj_la1[9] = jj_gen;
390+ break label_6;
391+ }
392+ jj_consume_token(BIT_OR);
393+ ExclusiveOrExpression();
394+ {
395+ if (true) {
396+ throw new ParseException("operation not yet supported");
397+ }
398+ }
399+ }
400+ }
401+
402+ final public void ExclusiveOrExpression() throws ParseException {
403+ AndExpression();
404+ label_7: while (true) {
405+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
406+ case XOR:
407+ ;
408+ break;
409+ default:
410+ jj_la1[10] = jj_gen;
411+ break label_7;
412+ }
413+ jj_consume_token(XOR);
414+ AndExpression();
415+ {
416+ if (true) {
417+ throw new ParseException("operation not yet supported");
418+ }
419+ }
420+ }
421+ }
422+
423+ final public void AndExpression() throws ParseException {
424+ EqualityExpression();
425+ label_8: while (true) {
426+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
427+ case BIT_AND:
428+ ;
429+ break;
430+ default:
431+ jj_la1[11] = jj_gen;
432+ break label_8;
433+ }
434+ jj_consume_token(BIT_AND);
435+ EqualityExpression();
436+ {
437+ if (true) {
438+ throw new ParseException("operation not yet supported");
439+ }
440+ }
441+ }
442+ }
443+
444+ final public void EqualityExpression() throws ParseException {
445+ Token tok;
446+ InstanceOfExpression();
447+ label_9: while (true) {
448+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
449+ case EQ:
450+ case NE:
451+ ;
452+ break;
453+ default:
454+ jj_la1[12] = jj_gen;
455+ break label_9;
456+ }
457+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
458+ case EQ:
459+ tok = jj_consume_token(EQ);
460+ break;
461+ case NE:
462+ tok = jj_consume_token(NE);
463+ break;
464+ default:
465+ jj_la1[13] = jj_gen;
466+ jj_consume_token(-1);
467+ throw new ParseException();
468+ }
469+ InstanceOfExpression();
470+ LValue left = pop();
471+ push( LValue.booleanOperation(vm, tok, pop(), left) );
472+ }
473+ }
474+
475+ final public void InstanceOfExpression() throws ParseException {
476+ RelationalExpression();
477+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
478+ case INSTANCEOF:
479+ jj_consume_token(INSTANCEOF);
480+ Type();
481+ {
482+ if (true) {
483+ throw new ParseException("operation not yet supported");
484+ }
485+ }
486+ break;
487+ default:
488+ jj_la1[14] = jj_gen;
489+ ;
490+ }
491+ }
492+
493+ final public void RelationalExpression() throws ParseException {
494+ Token tok;
495+ ShiftExpression();
496+ label_10: while (true) {
497+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
498+ case GT:
499+ case LT:
500+ case LE:
501+ case GE:
502+ ;
503+ break;
504+ default:
505+ jj_la1[15] = jj_gen;
506+ break label_10;
507+ }
508+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
509+ case LT:
510+ tok = jj_consume_token(LT);
511+ break;
512+ case GT:
513+ tok = jj_consume_token(GT);
514+ break;
515+ case LE:
516+ tok = jj_consume_token(LE);
517+ break;
518+ case GE:
519+ tok = jj_consume_token(GE);
520+ break;
521+ default:
522+ jj_la1[16] = jj_gen;
523+ jj_consume_token(-1);
524+ throw new ParseException();
525+ }
526+ ShiftExpression();
527+ LValue left = pop();
528+ push( LValue.booleanOperation(vm, tok, pop(), left) );
529+ }
530+ }
531+
532+ final public void ShiftExpression() throws ParseException {
533+ AdditiveExpression();
534+ label_11: while (true) {
535+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
536+ case LSHIFT:
537+ case RSIGNEDSHIFT:
538+ case RUNSIGNEDSHIFT:
539+ ;
540+ break;
541+ default:
542+ jj_la1[17] = jj_gen;
543+ break label_11;
544+ }
545+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
546+ case LSHIFT:
547+ jj_consume_token(LSHIFT);
548+ break;
549+ case RSIGNEDSHIFT:
550+ jj_consume_token(RSIGNEDSHIFT);
551+ break;
552+ case RUNSIGNEDSHIFT:
553+ jj_consume_token(RUNSIGNEDSHIFT);
554+ break;
555+ default:
556+ jj_la1[18] = jj_gen;
557+ jj_consume_token(-1);
558+ throw new ParseException();
559+ }
560+ AdditiveExpression();
561+ {
562+ if (true) {
563+ throw new ParseException("operation not yet supported");
564+ }
565+ }
566+ }
567+ }
568+
569+ final public void AdditiveExpression() throws ParseException {
570+ Token tok;
571+ MultiplicativeExpression();
572+ label_12: while (true) {
573+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
574+ case PLUS:
575+ case MINUS:
576+ ;
577+ break;
578+ default:
579+ jj_la1[19] = jj_gen;
580+ break label_12;
581+ }
582+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
583+ case PLUS:
584+ tok = jj_consume_token(PLUS);
585+ break;
586+ case MINUS:
587+ tok = jj_consume_token(MINUS);
588+ break;
589+ default:
590+ jj_la1[20] = jj_gen;
591+ jj_consume_token(-1);
592+ throw new ParseException();
593+ }
594+ MultiplicativeExpression();
595+ LValue left = pop();
596+ push( LValue.operation(vm, tok, pop(), left, frameGetter) );
597+ }
598+ }
599+
600+ final public void MultiplicativeExpression() throws ParseException {
601+ Token tok;
602+ UnaryExpression();
603+ label_13: while (true) {
604+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
605+ case STAR:
606+ case SLASH:
607+ case REM:
608+ ;
609+ break;
610+ default:
611+ jj_la1[21] = jj_gen;
612+ break label_13;
613+ }
614+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
615+ case STAR:
616+ tok = jj_consume_token(STAR);
617+ break;
618+ case SLASH:
619+ tok = jj_consume_token(SLASH);
620+ break;
621+ case REM:
622+ tok = jj_consume_token(REM);
623+ break;
624+ default:
625+ jj_la1[22] = jj_gen;
626+ jj_consume_token(-1);
627+ throw new ParseException();
628+ }
629+ UnaryExpression();
630+ LValue left = pop();
631+ push( LValue.operation(vm, tok, pop(), left, frameGetter) );
632+ }
633+ }
634+
635+ final public void UnaryExpression() throws ParseException {
636+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
637+ case PLUS:
638+ case MINUS:
639+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
640+ case PLUS:
641+ jj_consume_token(PLUS);
642+ break;
643+ case MINUS:
644+ jj_consume_token(MINUS);
645+ break;
646+ default:
647+ jj_la1[23] = jj_gen;
648+ jj_consume_token(-1);
649+ throw new ParseException();
650+ }
651+ UnaryExpression();
652+ {
653+ if (true) {
654+ throw new ParseException("operation not yet supported");
655+ }
656+ }
657+ break;
658+ case INCR:
659+ PreIncrementExpression();
660+ break;
661+ case DECR:
662+ PreDecrementExpression();
663+ break;
664+ case FALSE:
665+ case NEW:
666+ case NULL:
667+ case SUPER:
668+ case THIS:
669+ case TRUE:
670+ case INTEGER_LITERAL:
671+ case FLOATING_POINT_LITERAL:
672+ case CHARACTER_LITERAL:
673+ case STRING_LITERAL:
674+ case IDENTIFIER:
675+ case LPAREN:
676+ case BANG:
677+ case TILDE:
678+ UnaryExpressionNotPlusMinus();
679+ break;
680+ default:
681+ jj_la1[24] = jj_gen;
682+ jj_consume_token(-1);
683+ throw new ParseException();
684+ }
685+ }
686+
687+ final public void PreIncrementExpression() throws ParseException {
688+ jj_consume_token(INCR);
689+ PrimaryExpression();
690+ {
691+ if (true) {
692+ throw new ParseException("operation not yet supported");
693+ }
694+ }
695+ }
696+
697+ final public void PreDecrementExpression() throws ParseException {
698+ jj_consume_token(DECR);
699+ PrimaryExpression();
700+ {
701+ if (true) {
702+ throw new ParseException("operation not yet supported");
703+ }
704+ }
705+ }
706+
707+ final public void UnaryExpressionNotPlusMinus() throws ParseException {
708+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
709+ case BANG:
710+ case TILDE:
711+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
712+ case TILDE:
713+ jj_consume_token(TILDE);
714+ break;
715+ case BANG:
716+ jj_consume_token(BANG);
717+ break;
718+ default:
719+ jj_la1[25] = jj_gen;
720+ jj_consume_token(-1);
721+ throw new ParseException();
722+ }
723+ UnaryExpression();
724+ {
725+ if (true) {
726+ throw new ParseException("operation not yet supported");
727+ }
728+ }
729+ break;
730+ default:
731+ jj_la1[26] = jj_gen;
732+ if (jj_2_3(2147483647)) {
733+ CastExpression();
734+ } else {
735+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
736+ case FALSE:
737+ case NEW:
738+ case NULL:
739+ case SUPER:
740+ case THIS:
741+ case TRUE:
742+ case INTEGER_LITERAL:
743+ case FLOATING_POINT_LITERAL:
744+ case CHARACTER_LITERAL:
745+ case STRING_LITERAL:
746+ case IDENTIFIER:
747+ case LPAREN:
748+ PostfixExpression();
749+ break;
750+ default:
751+ jj_la1[27] = jj_gen;
752+ jj_consume_token(-1);
753+ throw new ParseException();
754+ }
755+ }
756+ }
757+ }
758+
759+ // This production is to determine lookahead only. The LOOKAHEAD
760+ // specifications
761+ // below are not used, but they are there just to indicate that we know
762+ // about
763+// this.
764+ final public void CastLookahead() throws ParseException {
765+ if (jj_2_4(2)) {
766+ jj_consume_token(LPAREN);
767+ PrimitiveType();
768+ } else if (jj_2_5(2147483647)) {
769+ jj_consume_token(LPAREN);
770+ Name();
771+ jj_consume_token(LBRACKET);
772+ jj_consume_token(RBRACKET);
773+ } else {
774+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
775+ case LPAREN:
776+ jj_consume_token(LPAREN);
777+ Name();
778+ jj_consume_token(RPAREN);
779+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
780+ case TILDE:
781+ jj_consume_token(TILDE);
782+ break;
783+ case BANG:
784+ jj_consume_token(BANG);
785+ break;
786+ case LPAREN:
787+ jj_consume_token(LPAREN);
788+ break;
789+ case IDENTIFIER:
790+ jj_consume_token(IDENTIFIER);
791+ break;
792+ case THIS:
793+ jj_consume_token(THIS);
794+ break;
795+ case SUPER:
796+ jj_consume_token(SUPER);
797+ break;
798+ case NEW:
799+ jj_consume_token(NEW);
800+ break;
801+ case FALSE:
802+ case NULL:
803+ case TRUE:
804+ case INTEGER_LITERAL:
805+ case FLOATING_POINT_LITERAL:
806+ case CHARACTER_LITERAL:
807+ case STRING_LITERAL:
808+ Literal();
809+ break;
810+ default:
811+ jj_la1[28] = jj_gen;
812+ jj_consume_token(-1);
813+ throw new ParseException();
814+ }
815+ break;
816+ default:
817+ jj_la1[29] = jj_gen;
818+ jj_consume_token(-1);
819+ throw new ParseException();
820+ }
821+ }
822+ }
823+
824+ final public void PostfixExpression() throws ParseException {
825+ PrimaryExpression();
826+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
827+ case INCR:
828+ case DECR:
829+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
830+ case INCR:
831+ jj_consume_token(INCR);
832+ break;
833+ case DECR:
834+ jj_consume_token(DECR);
835+ {
836+ if (true) {
837+ throw new ParseException("operation not yet supported");
838+ }
839+ }
840+ break;
841+ default:
842+ jj_la1[30] = jj_gen;
843+ jj_consume_token(-1);
844+ throw new ParseException();
845+ }
846+ break;
847+ default:
848+ jj_la1[31] = jj_gen;
849+ ;
850+ }
851+ }
852+
853+ final public void CastExpression() throws ParseException {
854+ if (jj_2_6(2)) {
855+ jj_consume_token(LPAREN);
856+ PrimitiveType();
857+ label_14: while (true) {
858+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
859+ case LBRACKET:
860+ ;
861+ break;
862+ default:
863+ jj_la1[32] = jj_gen;
864+ break label_14;
865+ }
866+ jj_consume_token(LBRACKET);
867+ jj_consume_token(RBRACKET);
868+ }
869+ jj_consume_token(RPAREN);
870+ UnaryExpression();
871+ } else {
872+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
873+ case LPAREN:
874+ jj_consume_token(LPAREN);
875+ Name();
876+ label_15: while (true) {
877+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
878+ case LBRACKET:
879+ ;
880+ break;
881+ default:
882+ jj_la1[33] = jj_gen;
883+ break label_15;
884+ }
885+ jj_consume_token(LBRACKET);
886+ jj_consume_token(RBRACKET);
887+ }
888+ jj_consume_token(RPAREN);
889+ UnaryExpressionNotPlusMinus();
890+ break;
891+ default:
892+ jj_la1[34] = jj_gen;
893+ jj_consume_token(-1);
894+ throw new ParseException();
895+ }
896+ }
897+ }
898+
899+ final public void PrimaryExpression() throws ParseException {
900+ PrimaryPrefix();
901+ label_16: while (true) {
902+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
903+ case LPAREN:
904+ case LBRACKET:
905+ case DOT:
906+ ;
907+ break;
908+ default:
909+ jj_la1[35] = jj_gen;
910+ break label_16;
911+ }
912+ PrimarySuffix();
913+ }
914+ }
915+
916+ final public void PrimaryPrefix() throws ParseException {
917+ String name;
918+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
919+ case FALSE:
920+ case NULL:
921+ case TRUE:
922+ case INTEGER_LITERAL:
923+ case FLOATING_POINT_LITERAL:
924+ case CHARACTER_LITERAL:
925+ case STRING_LITERAL:
926+ Literal();
927+ break;
928+ case IDENTIFIER:
929+ name = Name();
930+ push(LValue.makeName(vm, frameGetter, name));
931+ break;
932+ case THIS:
933+ jj_consume_token(THIS);
934+ push(LValue.makeThisObject(vm, frameGetter, token));
935+ break;
936+ case SUPER:
937+ jj_consume_token(SUPER);
938+ jj_consume_token(DOT);
939+ jj_consume_token(IDENTIFIER);
940+ {
941+ if (true) {
942+ throw new ParseException("operation not yet supported");
943+ }
944+ }
945+ break;
946+ case LPAREN:
947+ jj_consume_token(LPAREN);
948+ Expression();
949+ jj_consume_token(RPAREN);
950+ break;
951+ case NEW:
952+ AllocationExpression();
953+ break;
954+ default:
955+ jj_la1[36] = jj_gen;
956+ jj_consume_token(-1);
957+ throw new ParseException();
958+ }
959+ }
960+
961+ final public void PrimarySuffix() throws ParseException {
962+ List<Value> argList;
963+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
964+ case LBRACKET:
965+ jj_consume_token(LBRACKET);
966+ Expression();
967+ jj_consume_token(RBRACKET);
968+ LValue index = pop();
969+ push(pop().arrayElementLValue(index));
970+ break;
971+ case DOT:
972+ jj_consume_token(DOT);
973+ jj_consume_token(IDENTIFIER);
974+ push(pop().memberLValue(frameGetter, token.image));
975+ break;
976+ case LPAREN:
977+ argList = Arguments();
978+ peek().invokeWith(argList);
979+ break;
980+ default:
981+ jj_la1[37] = jj_gen;
982+ jj_consume_token(-1);
983+ throw new ParseException();
984+ }
985+ }
986+
987+ final public void Literal() throws ParseException {
988+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
989+ case INTEGER_LITERAL:
990+ jj_consume_token(INTEGER_LITERAL);
991+ push(LValue.makeInteger(vm, token));
992+ break;
993+ case FLOATING_POINT_LITERAL:
994+ jj_consume_token(FLOATING_POINT_LITERAL);
995+ push(LValue.makeFloat(vm, token));
996+ break;
997+ case CHARACTER_LITERAL:
998+ jj_consume_token(CHARACTER_LITERAL);
999+ push(LValue.makeCharacter(vm, token));
1000+ break;
1001+ case STRING_LITERAL:
1002+ jj_consume_token(STRING_LITERAL);
1003+ push(LValue.makeString(vm, token));
1004+ break;
1005+ case FALSE:
1006+ case TRUE:
1007+ BooleanLiteral();
1008+ push(LValue.makeBoolean(vm, token));
1009+ break;
1010+ case NULL:
1011+ NullLiteral();
1012+ push(LValue.makeNull(vm, token));
1013+ break;
1014+ default:
1015+ jj_la1[38] = jj_gen;
1016+ jj_consume_token(-1);
1017+ throw new ParseException();
1018+ }
1019+ }
1020+
1021+ final public void BooleanLiteral() throws ParseException {
1022+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
1023+ case TRUE:
1024+ jj_consume_token(TRUE);
1025+ break;
1026+ case FALSE:
1027+ jj_consume_token(FALSE);
1028+ break;
1029+ default:
1030+ jj_la1[39] = jj_gen;
1031+ jj_consume_token(-1);
1032+ throw new ParseException();
1033+ }
1034+ }
1035+
1036+ final public void NullLiteral() throws ParseException {
1037+ jj_consume_token(NULL);
1038+ }
1039+
1040+ final public List<Value> Arguments() throws ParseException {
1041+ List<Value> argList = new ArrayList<Value>();
1042+ jj_consume_token(LPAREN);
1043+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
1044+ case FALSE:
1045+ case NEW:
1046+ case NULL:
1047+ case SUPER:
1048+ case THIS:
1049+ case TRUE:
1050+ case INTEGER_LITERAL:
1051+ case FLOATING_POINT_LITERAL:
1052+ case CHARACTER_LITERAL:
1053+ case STRING_LITERAL:
1054+ case IDENTIFIER:
1055+ case LPAREN:
1056+ case BANG:
1057+ case TILDE:
1058+ case INCR:
1059+ case DECR:
1060+ case PLUS:
1061+ case MINUS:
1062+ ArgumentList(argList);
1063+ break;
1064+ default:
1065+ jj_la1[40] = jj_gen;
1066+ ;
1067+ }
1068+ jj_consume_token(RPAREN);
1069+ {
1070+ if (true) {
1071+ return argList;
1072+ }
1073+ }
1074+ throw new Error("Missing return statement in function");
1075+ }
1076+
1077+ final public void ArgumentList(List<Value> argList) throws ParseException {
1078+ Expression();
1079+ argList.add(pop().interiorGetValue());
1080+ label_17: while (true) {
1081+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
1082+ case COMMA:
1083+ ;
1084+ break;
1085+ default:
1086+ jj_la1[41] = jj_gen;
1087+ break label_17;
1088+ }
1089+ jj_consume_token(COMMA);
1090+ Expression();
1091+ argList.add(pop().interiorGetValue());
1092+ }
1093+ }
1094+
1095+ final public void AllocationExpression() throws ParseException {
1096+ List<Value> argList;
1097+ String className;
1098+ if (jj_2_7(2)) {
1099+ jj_consume_token(NEW);
1100+ PrimitiveType();
1101+ ArrayDimensions();
1102+ } else {
1103+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
1104+ case NEW:
1105+ jj_consume_token(NEW);
1106+ className = Name();
1107+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
1108+ case LPAREN:
1109+ argList = Arguments();
1110+ push(LValue.makeNewObject(vm, frameGetter, className, argList));
1111+ break;
1112+ case LBRACKET:
1113+ ArrayDimensions();
1114+ {
1115+ if (true) {
1116+ throw new ParseException("operation not yet supported");
1117+ }
1118+ }
1119+ break;
1120+ default:
1121+ jj_la1[42] = jj_gen;
1122+ jj_consume_token(-1);
1123+ throw new ParseException();
1124+ }
1125+ break;
1126+ default:
1127+ jj_la1[43] = jj_gen;
1128+ jj_consume_token(-1);
1129+ throw new ParseException();
1130+ }
1131+ }
1132+ }
1133+
1134+/*
1135+ * The second LOOKAHEAD specification below is to parse to PrimarySuffix if
1136+ * there is an expression between the "[...]".
1137+ */
1138+ final public void ArrayDimensions() throws ParseException {
1139+ label_18: while (true) {
1140+ jj_consume_token(LBRACKET);
1141+ Expression();
1142+ jj_consume_token(RBRACKET);
1143+ if (jj_2_8(2)) {
1144+ ;
1145+ } else {
1146+ break label_18;
1147+ }
1148+ }
1149+ label_19: while (true) {
1150+ if (jj_2_9(2)) {
1151+ ;
1152+ } else {
1153+ break label_19;
1154+ }
1155+ jj_consume_token(LBRACKET);
1156+ jj_consume_token(RBRACKET);
1157+ }
1158+ }
1159+
1160+ final private boolean jj_2_1(int xla) {
1161+ jj_la = xla;
1162+ jj_lastpos = jj_scanpos = token;
1163+ boolean retval = !jj_3_1();
1164+ jj_save(0, xla);
1165+ return retval;
1166+ }
1167+
1168+ final private boolean jj_2_2(int xla) {
1169+ jj_la = xla;
1170+ jj_lastpos = jj_scanpos = token;
1171+ boolean retval = !jj_3_2();
1172+ jj_save(1, xla);
1173+ return retval;
1174+ }
1175+
1176+ final private boolean jj_2_3(int xla) {
1177+ jj_la = xla;
1178+ jj_lastpos = jj_scanpos = token;
1179+ boolean retval = !jj_3_3();
1180+ jj_save(2, xla);
1181+ return retval;
1182+ }
1183+
1184+ final private boolean jj_2_4(int xla) {
1185+ jj_la = xla;
1186+ jj_lastpos = jj_scanpos = token;
1187+ boolean retval = !jj_3_4();
1188+ jj_save(3, xla);
1189+ return retval;
1190+ }
1191+
1192+ final private boolean jj_2_5(int xla) {
1193+ jj_la = xla;
1194+ jj_lastpos = jj_scanpos = token;
1195+ boolean retval = !jj_3_5();
1196+ jj_save(4, xla);
1197+ return retval;
1198+ }
1199+
1200+ final private boolean jj_2_6(int xla) {
1201+ jj_la = xla;
1202+ jj_lastpos = jj_scanpos = token;
1203+ boolean retval = !jj_3_6();
1204+ jj_save(5, xla);
1205+ return retval;
1206+ }
1207+
1208+ final private boolean jj_2_7(int xla) {
1209+ jj_la = xla;
1210+ jj_lastpos = jj_scanpos = token;
1211+ boolean retval = !jj_3_7();
1212+ jj_save(6, xla);
1213+ return retval;
1214+ }
1215+
1216+ final private boolean jj_2_8(int xla) {
1217+ jj_la = xla;
1218+ jj_lastpos = jj_scanpos = token;
1219+ boolean retval = !jj_3_8();
1220+ jj_save(7, xla);
1221+ return retval;
1222+ }
1223+
1224+ final private boolean jj_2_9(int xla) {
1225+ jj_la = xla;
1226+ jj_lastpos = jj_scanpos = token;
1227+ boolean retval = !jj_3_9();
1228+ jj_save(8, xla);
1229+ return retval;
1230+ }
1231+
1232+ final private boolean jj_3R_154() {
1233+ if (jj_scan_token(INCR)) {
1234+ return true;
1235+ }
1236+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
1237+ return false;
1238+ }
1239+ return false;
1240+ }
1241+
1242+ final private boolean jj_3R_151() {
1243+ Token xsp;
1244+ xsp = jj_scanpos;
1245+ if (jj_3R_154()) {
1246+ jj_scanpos = xsp;
1247+ if (jj_3R_155()) {
1248+ return true;
1249+ }
1250+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
1251+ return false;
1252+ }
1253+ } else if (jj_la == 0 && jj_scanpos == jj_lastpos) {
1254+ return false;
1255+ }
1256+ return false;
1257+ }
1258+
1259+ final private boolean jj_3R_148() {
1260+ Token xsp;
1261+ xsp = jj_scanpos;
1262+ if (jj_3_6()) {
1263+ jj_scanpos = xsp;
1264+ if (jj_3R_150()) {
1265+ return true;
1266+ }
1267+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
1268+ return false;
1269+ }
1270+ } else if (jj_la == 0 && jj_scanpos == jj_lastpos) {
1271+ return false;
1272+ }
1273+ return false;
1274+ }
1275+
1276+ final private boolean jj_3_6() {
1277+ if (jj_scan_token(LPAREN)) {
1278+ return true;
1279+ }
1280+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
1281+ return false;
1282+ }
1283+ if (jj_3R_23()) {
1284+ return true;
1285+ }
1286+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
1287+ return false;
1288+ }
1289+ Token xsp;
1290+ while (true) {
1291+ xsp = jj_scanpos;
1292+ if (jj_3R_152()) {
1293+ jj_scanpos = xsp;
1294+ break;
1295+ }
1296+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
1297+ return false;
1298+ }
1299+ }
1300+ if (jj_scan_token(RPAREN)) {
1301+ return true;
1302+ }
1303+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
1304+ return false;
1305+ }
1306+ if (jj_3R_115()) {
1307+ return true;
1308+ }
1309+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
1310+ return false;
1311+ }
1312+ return false;
1313+ }
1314+
1315+ final private boolean jj_3R_25() {
1316+ Token xsp;
1317+ xsp = jj_scanpos;
1318+ if (jj_3R_50()) {
1319+ jj_scanpos = xsp;
1320+ if (jj_3R_51()) {
1321+ return true;
1322+ }
1323+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
1324+ return false;
1325+ }
1326+ } else if (jj_la == 0 && jj_scanpos == jj_lastpos) {
1327+ return false;
1328+ }
1329+ return false;
1330+ }
1331+
1332+ final private boolean jj_3R_50() {
1333+ if (jj_3R_67()) {
1334+ return true;
1335+ }
1336+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
1337+ return false;
1338+ }
1339+ return false;
1340+ }
1341+
1342+ final private boolean jj_3_5() {
1343+ if (jj_scan_token(LPAREN)) {
1344+ return true;
1345+ }
1346+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
1347+ return false;
1348+ }
1349+ if (jj_3R_24()) {
1350+ return true;
1351+ }
1352+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
1353+ return false;
1354+ }
1355+ if (jj_scan_token(LBRACKET)) {
1356+ return true;
1357+ }
1358+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
1359+ return false;
1360+ }
1361+ return false;
1362+ }
1363+
1364+ final private boolean jj_3R_149() {
1365+ if (jj_3R_20()) {
1366+ return true;
1367+ }
1368+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
1369+ return false;
1370+ }
1371+ Token xsp;
1372+ xsp = jj_scanpos;
1373+ if (jj_3R_151()) {
1374+ jj_scanpos = xsp;
1375+ } else if (jj_la == 0 && jj_scanpos == jj_lastpos) {
1376+ return false;
1377+ }
1378+ return false;
1379+ }
1380+
1381+ final private boolean jj_3R_41() {
1382+ if (jj_scan_token(LPAREN)) {
1383+ return true;
1384+ }
1385+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
1386+ return false;
1387+ }
1388+ if (jj_3R_24()) {
1389+ return true;
1390+ }
1391+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
1392+ return false;
1393+ }
1394+ if (jj_scan_token(RPAREN)) {
1395+ return true;
1396+ }
1397+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
1398+ return false;
1399+ }
1400+ Token xsp;
1401+ xsp = jj_scanpos;
1402+ if (jj_3R_59()) {
1403+ jj_scanpos = xsp;
1404+ if (jj_3R_60()) {
1405+ jj_scanpos = xsp;
1406+ if (jj_3R_61()) {
1407+ jj_scanpos = xsp;
1408+ if (jj_3R_62()) {
1409+ jj_scanpos = xsp;
1410+ if (jj_3R_63()) {
1411+ jj_scanpos = xsp;
1412+ if (jj_3R_64()) {
1413+ jj_scanpos = xsp;
1414+ if (jj_3R_65()) {
1415+ jj_scanpos = xsp;
1416+ if (jj_3R_66()) {
1417+ return true;
1418+ }
1419+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
1420+ return false;
1421+ }
1422+ } else if (jj_la == 0 && jj_scanpos == jj_lastpos) {
1423+ return false;
1424+ }
1425+ } else if (jj_la == 0 && jj_scanpos == jj_lastpos) {
1426+ return false;
1427+ }
1428+ } else if (jj_la == 0 && jj_scanpos == jj_lastpos) {
1429+ return false;
1430+ }
1431+ } else if (jj_la == 0 && jj_scanpos == jj_lastpos) {
1432+ return false;
1433+ }
1434+ } else if (jj_la == 0 && jj_scanpos == jj_lastpos) {
1435+ return false;
1436+ }
1437+ } else if (jj_la == 0 && jj_scanpos == jj_lastpos) {
1438+ return false;
1439+ }
1440+ } else if (jj_la == 0 && jj_scanpos == jj_lastpos) {
1441+ return false;
1442+ }
1443+ return false;
1444+ }
1445+
1446+ final private boolean jj_3R_40() {
1447+ if (jj_scan_token(LPAREN)) {
1448+ return true;
1449+ }
1450+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
1451+ return false;
1452+ }
1453+ if (jj_3R_24()) {
1454+ return true;
1455+ }
1456+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
1457+ return false;
1458+ }
1459+ if (jj_scan_token(LBRACKET)) {
1460+ return true;
1461+ }
1462+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
1463+ return false;
1464+ }
1465+ if (jj_scan_token(RBRACKET)) {
1466+ return true;
1467+ }
1468+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
1469+ return false;
1470+ }
1471+ return false;
1472+ }
1473+
1474+ final private boolean jj_3R_123() {
1475+ if (jj_scan_token(LBRACKET)) {
1476+ return true;
1477+ }
1478+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
1479+ return false;
1480+ }
1481+ if (jj_scan_token(RBRACKET)) {
1482+ return true;
1483+ }
1484+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
1485+ return false;
1486+ }
1487+ return false;
1488+ }
1489+
1490+ final private boolean jj_3_1() {
1491+ if (jj_scan_token(DOT)) {
1492+ return true;
1493+ }
1494+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
1495+ return false;
1496+ }
1497+ if (jj_scan_token(IDENTIFIER)) {
1498+ return true;
1499+ }
1500+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
1501+ return false;
1502+ }
1503+ return false;
1504+ }
1505+
1506+ final private boolean jj_3_4() {
1507+ if (jj_scan_token(LPAREN)) {
1508+ return true;
1509+ }
1510+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
1511+ return false;
1512+ }
1513+ if (jj_3R_23()) {
1514+ return true;
1515+ }
1516+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
1517+ return false;
1518+ }
1519+ return false;
1520+ }
1521+
1522+ final private boolean jj_3R_22() {
1523+ Token xsp;
1524+ xsp = jj_scanpos;
1525+ if (jj_3_4()) {
1526+ jj_scanpos = xsp;
1527+ if (jj_3R_40()) {
1528+ jj_scanpos = xsp;
1529+ if (jj_3R_41()) {
1530+ return true;
1531+ }
1532+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
1533+ return false;
1534+ }
1535+ } else if (jj_la == 0 && jj_scanpos == jj_lastpos) {
1536+ return false;
1537+ }
1538+ } else if (jj_la == 0 && jj_scanpos == jj_lastpos) {
1539+ return false;
1540+ }
1541+ return false;
1542+ }
1543+
1544+ final private boolean jj_3_3() {
1545+ if (jj_3R_22()) {
1546+ return true;
1547+ }
1548+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
1549+ return false;
1550+ }
1551+ return false;
1552+ }
1553+
1554+ final private boolean jj_3R_24() {
1555+ if (jj_scan_token(IDENTIFIER)) {
1556+ return true;
1557+ }
1558+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
1559+ return false;
1560+ }
1561+ Token xsp;
1562+ while (true) {
1563+ xsp = jj_scanpos;
1564+ if (jj_3_1()) {
1565+ jj_scanpos = xsp;
1566+ break;
1567+ }
1568+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
1569+ return false;
1570+ }
1571+ }
1572+ return false;
1573+ }
1574+
1575+ final private boolean jj_3R_147() {
1576+ if (jj_scan_token(BANG)) {
1577+ return true;
1578+ }
1579+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
1580+ return false;
1581+ }
1582+ return false;
1583+ }
1584+
1585+ final private boolean jj_3R_142() {
1586+ if (jj_3R_149()) {
1587+ return true;
1588+ }
1589+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
1590+ return false;
1591+ }
1592+ return false;
1593+ }
1594+
1595+ final private boolean jj_3R_122() {
1596+ if (jj_3R_24()) {
1597+ return true;
1598+ }
1599+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
1600+ return false;
1601+ }
1602+ return false;
1603+ }
1604+
1605+ final private boolean jj_3R_49() {
1606+ if (jj_scan_token(DOUBLE)) {
1607+ return true;
1608+ }
1609+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
1610+ return false;
1611+ }
1612+ return false;
1613+ }
1614+
1615+ final private boolean jj_3R_141() {
1616+ if (jj_3R_148()) {
1617+ return true;
1618+ }
1619+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
1620+ return false;
1621+ }
1622+ return false;
1623+ }
1624+
1625+ final private boolean jj_3R_48() {
1626+ if (jj_scan_token(FLOAT)) {
1627+ return true;
1628+ }
1629+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
1630+ return false;
1631+ }
1632+ return false;
1633+ }
1634+
1635+ final private boolean jj_3R_146() {
1636+ if (jj_scan_token(TILDE)) {
1637+ return true;
1638+ }
1639+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
1640+ return false;
1641+ }
1642+ return false;
1643+ }
1644+
1645+ final private boolean jj_3R_47() {
1646+ if (jj_scan_token(LONG)) {
1647+ return true;
1648+ }
1649+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
1650+ return false;
1651+ }
1652+ return false;
1653+ }
1654+
1655+ final private boolean jj_3R_140() {
1656+ Token xsp;
1657+ xsp = jj_scanpos;
1658+ if (jj_3R_146()) {
1659+ jj_scanpos = xsp;
1660+ if (jj_3R_147()) {
1661+ return true;
1662+ }
1663+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
1664+ return false;
1665+ }
1666+ } else if (jj_la == 0 && jj_scanpos == jj_lastpos) {
1667+ return false;
1668+ }
1669+ if (jj_3R_115()) {
1670+ return true;
1671+ }
1672+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
1673+ return false;
1674+ }
1675+ return false;
1676+ }
1677+
1678+ final private boolean jj_3R_136() {
1679+ Token xsp;
1680+ xsp = jj_scanpos;
1681+ if (jj_3R_140()) {
1682+ jj_scanpos = xsp;
1683+ if (jj_3R_141()) {
1684+ jj_scanpos = xsp;
1685+ if (jj_3R_142()) {
1686+ return true;
1687+ }
1688+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
1689+ return false;
1690+ }
1691+ } else if (jj_la == 0 && jj_scanpos == jj_lastpos) {
1692+ return false;
1693+ }
1694+ } else if (jj_la == 0 && jj_scanpos == jj_lastpos) {
1695+ return false;
1696+ }
1697+ return false;
1698+ }
1699+
1700+ final private boolean jj_3R_46() {
1701+ if (jj_scan_token(INT)) {
1702+ return true;
1703+ }
1704+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
1705+ return false;
1706+ }
1707+ return false;
1708+ }
1709+
1710+ final private boolean jj_3R_145() {
1711+ if (jj_scan_token(REM)) {
1712+ return true;
1713+ }
1714+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
1715+ return false;
1716+ }
1717+ return false;
1718+ }
1719+
1720+ final private boolean jj_3R_45() {
1721+ if (jj_scan_token(SHORT)) {
1722+ return true;
1723+ }
1724+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
1725+ return false;
1726+ }
1727+ return false;
1728+ }
1729+
1730+ final private boolean jj_3R_44() {
1731+ if (jj_scan_token(BYTE)) {
1732+ return true;
1733+ }
1734+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
1735+ return false;
1736+ }
1737+ return false;
1738+ }
1739+
1740+ final private boolean jj_3R_135() {
1741+ if (jj_scan_token(DECR)) {
1742+ return true;
1743+ }
1744+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
1745+ return false;
1746+ }
1747+ if (jj_3R_20()) {
1748+ return true;
1749+ }
1750+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
1751+ return false;
1752+ }
1753+ return false;
1754+ }
1755+
1756+ final private boolean jj_3R_43() {
1757+ if (jj_scan_token(CHAR)) {
1758+ return true;
1759+ }
1760+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
1761+ return false;
1762+ }
1763+ return false;
1764+ }
1765+
1766+ final private boolean jj_3R_23() {
1767+ Token xsp;
1768+ xsp = jj_scanpos;
1769+ if (jj_3R_42()) {
1770+ jj_scanpos = xsp;
1771+ if (jj_3R_43()) {
1772+ jj_scanpos = xsp;
1773+ if (jj_3R_44()) {
1774+ jj_scanpos = xsp;
1775+ if (jj_3R_45()) {
1776+ jj_scanpos = xsp;
1777+ if (jj_3R_46()) {
1778+ jj_scanpos = xsp;
1779+ if (jj_3R_47()) {
1780+ jj_scanpos = xsp;
1781+ if (jj_3R_48()) {
1782+ jj_scanpos = xsp;
1783+ if (jj_3R_49()) {
1784+ return true;
1785+ }
1786+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
1787+ return false;
1788+ }
1789+ } else if (jj_la == 0 && jj_scanpos == jj_lastpos) {
1790+ return false;
1791+ }
1792+ } else if (jj_la == 0 && jj_scanpos == jj_lastpos) {
1793+ return false;
1794+ }
1795+ } else if (jj_la == 0 && jj_scanpos == jj_lastpos) {
1796+ return false;
1797+ }
1798+ } else if (jj_la == 0 && jj_scanpos == jj_lastpos) {
1799+ return false;
1800+ }
1801+ } else if (jj_la == 0 && jj_scanpos == jj_lastpos) {
1802+ return false;
1803+ }
1804+ } else if (jj_la == 0 && jj_scanpos == jj_lastpos) {
1805+ return false;
1806+ }
1807+ } else if (jj_la == 0 && jj_scanpos == jj_lastpos) {
1808+ return false;
1809+ }
1810+ return false;
1811+ }
1812+
1813+ final private boolean jj_3R_42() {
1814+ if (jj_scan_token(BOOLEAN)) {
1815+ return true;
1816+ }
1817+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
1818+ return false;
1819+ }
1820+ return false;
1821+ }
1822+
1823+ final private boolean jj_3_9() {
1824+ if (jj_scan_token(LBRACKET)) {
1825+ return true;
1826+ }
1827+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
1828+ return false;
1829+ }
1830+ if (jj_scan_token(RBRACKET)) {
1831+ return true;
1832+ }
1833+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
1834+ return false;
1835+ }
1836+ return false;
1837+ }
1838+
1839+ final private boolean jj_3R_121() {
1840+ if (jj_3R_23()) {
1841+ return true;
1842+ }
1843+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
1844+ return false;
1845+ }
1846+ return false;
1847+ }
1848+
1849+ final private boolean jj_3R_144() {
1850+ if (jj_scan_token(SLASH)) {
1851+ return true;
1852+ }
1853+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
1854+ return false;
1855+ }
1856+ return false;
1857+ }
1858+
1859+ final private boolean jj_3R_134() {
1860+ if (jj_scan_token(INCR)) {
1861+ return true;
1862+ }
1863+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
1864+ return false;
1865+ }
1866+ if (jj_3R_20()) {
1867+ return true;
1868+ }
1869+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
1870+ return false;
1871+ }
1872+ return false;
1873+ }
1874+
1875+ final private boolean jj_3R_114() {
1876+ Token xsp;
1877+ xsp = jj_scanpos;
1878+ if (jj_3R_121()) {
1879+ jj_scanpos = xsp;
1880+ if (jj_3R_122()) {
1881+ return true;
1882+ }
1883+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
1884+ return false;
1885+ }
1886+ } else if (jj_la == 0 && jj_scanpos == jj_lastpos) {
1887+ return false;
1888+ }
1889+ while (true) {
1890+ xsp = jj_scanpos;
1891+ if (jj_3R_123()) {
1892+ jj_scanpos = xsp;
1893+ break;
1894+ }
1895+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
1896+ return false;
1897+ }
1898+ }
1899+ return false;
1900+ }
1901+
1902+ final private boolean jj_3R_120() {
1903+ if (jj_scan_token(GE)) {
1904+ return true;
1905+ }
1906+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
1907+ return false;
1908+ }
1909+ return false;
1910+ }
1911+
1912+ final private boolean jj_3R_133() {
1913+ if (jj_scan_token(MINUS)) {
1914+ return true;
1915+ }
1916+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
1917+ return false;
1918+ }
1919+ return false;
1920+ }
1921+
1922+ final private boolean jj_3R_127() {
1923+ if (jj_3R_136()) {
1924+ return true;
1925+ }
1926+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
1927+ return false;
1928+ }
1929+ return false;
1930+ }
1931+
1932+ final private boolean jj_3R_126() {
1933+ if (jj_3R_135()) {
1934+ return true;
1935+ }
1936+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
1937+ return false;
1938+ }
1939+ return false;
1940+ }
1941+
1942+ final private boolean jj_3R_139() {
1943+ if (jj_scan_token(MINUS)) {
1944+ return true;
1945+ }
1946+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
1947+ return false;
1948+ }
1949+ return false;
1950+ }
1951+
1952+ final private boolean jj_3R_125() {
1953+ if (jj_3R_134()) {
1954+ return true;
1955+ }
1956+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
1957+ return false;
1958+ }
1959+ return false;
1960+ }
1961+
1962+ final private boolean jj_3R_132() {
1963+ if (jj_scan_token(PLUS)) {
1964+ return true;
1965+ }
1966+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
1967+ return false;
1968+ }
1969+ return false;
1970+ }
1971+
1972+ final private boolean jj_3R_143() {
1973+ if (jj_scan_token(STAR)) {
1974+ return true;
1975+ }
1976+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
1977+ return false;
1978+ }
1979+ return false;
1980+ }
1981+
1982+ final private boolean jj_3R_124() {
1983+ Token xsp;
1984+ xsp = jj_scanpos;
1985+ if (jj_3R_132()) {
1986+ jj_scanpos = xsp;
1987+ if (jj_3R_133()) {
1988+ return true;
1989+ }
1990+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
1991+ return false;
1992+ }
1993+ } else if (jj_la == 0 && jj_scanpos == jj_lastpos) {
1994+ return false;
1995+ }
1996+ if (jj_3R_115()) {
1997+ return true;
1998+ }
1999+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
2000+ return false;
2001+ }
2002+ return false;
2003+ }
2004+
2005+ final private boolean jj_3R_115() {
2006+ Token xsp;
2007+ xsp = jj_scanpos;
2008+ if (jj_3R_124()) {
2009+ jj_scanpos = xsp;
2010+ if (jj_3R_125()) {
2011+ jj_scanpos = xsp;
2012+ if (jj_3R_126()) {
2013+ jj_scanpos = xsp;
2014+ if (jj_3R_127()) {
2015+ return true;
2016+ }
2017+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
2018+ return false;
2019+ }
2020+ } else if (jj_la == 0 && jj_scanpos == jj_lastpos) {
2021+ return false;
2022+ }
2023+ } else if (jj_la == 0 && jj_scanpos == jj_lastpos) {
2024+ return false;
2025+ }
2026+ } else if (jj_la == 0 && jj_scanpos == jj_lastpos) {
2027+ return false;
2028+ }
2029+ return false;
2030+ }
2031+
2032+ final private boolean jj_3R_137() {
2033+ Token xsp;
2034+ xsp = jj_scanpos;
2035+ if (jj_3R_143()) {
2036+ jj_scanpos = xsp;
2037+ if (jj_3R_144()) {
2038+ jj_scanpos = xsp;
2039+ if (jj_3R_145()) {
2040+ return true;
2041+ }
2042+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
2043+ return false;
2044+ }
2045+ } else if (jj_la == 0 && jj_scanpos == jj_lastpos) {
2046+ return false;
2047+ }
2048+ } else if (jj_la == 0 && jj_scanpos == jj_lastpos) {
2049+ return false;
2050+ }
2051+ if (jj_3R_115()) {
2052+ return true;
2053+ }
2054+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
2055+ return false;
2056+ }
2057+ return false;
2058+ }
2059+
2060+ final private boolean jj_3R_131() {
2061+ if (jj_scan_token(RUNSIGNEDSHIFT)) {
2062+ return true;
2063+ }
2064+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
2065+ return false;
2066+ }
2067+ return false;
2068+ }
2069+
2070+ final private boolean jj_3R_119() {
2071+ if (jj_scan_token(LE)) {
2072+ return true;
2073+ }
2074+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
2075+ return false;
2076+ }
2077+ return false;
2078+ }
2079+
2080+ final private boolean jj_3R_138() {
2081+ if (jj_scan_token(PLUS)) {
2082+ return true;
2083+ }
2084+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
2085+ return false;
2086+ }
2087+ return false;
2088+ }
2089+
2090+ final private boolean jj_3R_112() {
2091+ if (jj_3R_115()) {
2092+ return true;
2093+ }
2094+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
2095+ return false;
2096+ }
2097+ Token xsp;
2098+ while (true) {
2099+ xsp = jj_scanpos;
2100+ if (jj_3R_137()) {
2101+ jj_scanpos = xsp;
2102+ break;
2103+ }
2104+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
2105+ return false;
2106+ }
2107+ }
2108+ return false;
2109+ }
2110+
2111+ final private boolean jj_3R_88() {
2112+ if (jj_3R_86()) {
2113+ return true;
2114+ }
2115+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
2116+ return false;
2117+ }
2118+ return false;
2119+ }
2120+
2121+ final private boolean jj_3R_130() {
2122+ if (jj_scan_token(RSIGNEDSHIFT)) {
2123+ return true;
2124+ }
2125+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
2126+ return false;
2127+ }
2128+ return false;
2129+ }
2130+
2131+ final private boolean jj_3R_128() {
2132+ Token xsp;
2133+ xsp = jj_scanpos;
2134+ if (jj_3R_138()) {
2135+ jj_scanpos = xsp;
2136+ if (jj_3R_139()) {
2137+ return true;
2138+ }
2139+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
2140+ return false;
2141+ }
2142+ } else if (jj_la == 0 && jj_scanpos == jj_lastpos) {
2143+ return false;
2144+ }
2145+ if (jj_3R_112()) {
2146+ return true;
2147+ }
2148+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
2149+ return false;
2150+ }
2151+ return false;
2152+ }
2153+
2154+ final private boolean jj_3R_87() {
2155+ if (jj_3R_82()) {
2156+ return true;
2157+ }
2158+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
2159+ return false;
2160+ }
2161+ return false;
2162+ }
2163+
2164+ final private boolean jj_3R_118() {
2165+ if (jj_scan_token(GT)) {
2166+ return true;
2167+ }
2168+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
2169+ return false;
2170+ }
2171+ return false;
2172+ }
2173+
2174+ final private boolean jj_3R_129() {
2175+ if (jj_scan_token(LSHIFT)) {
2176+ return true;
2177+ }
2178+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
2179+ return false;
2180+ }
2181+ return false;
2182+ }
2183+
2184+ final private boolean jj_3R_116() {
2185+ Token xsp;
2186+ xsp = jj_scanpos;
2187+ if (jj_3R_129()) {
2188+ jj_scanpos = xsp;
2189+ if (jj_3R_130()) {
2190+ jj_scanpos = xsp;
2191+ if (jj_3R_131()) {
2192+ return true;
2193+ }
2194+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
2195+ return false;
2196+ }
2197+ } else if (jj_la == 0 && jj_scanpos == jj_lastpos) {
2198+ return false;
2199+ }
2200+ } else if (jj_la == 0 && jj_scanpos == jj_lastpos) {
2201+ return false;
2202+ }
2203+ if (jj_3R_108()) {
2204+ return true;
2205+ }
2206+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
2207+ return false;
2208+ }
2209+ return false;
2210+ }
2211+
2212+ final private boolean jj_3R_108() {
2213+ if (jj_3R_112()) {
2214+ return true;
2215+ }
2216+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
2217+ return false;
2218+ }
2219+ Token xsp;
2220+ while (true) {
2221+ xsp = jj_scanpos;
2222+ if (jj_3R_128()) {
2223+ jj_scanpos = xsp;
2224+ break;
2225+ }
2226+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
2227+ return false;
2228+ }
2229+ }
2230+ return false;
2231+ }
2232+
2233+ final private boolean jj_3_8() {
2234+ if (jj_scan_token(LBRACKET)) {
2235+ return true;
2236+ }
2237+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
2238+ return false;
2239+ }
2240+ if (jj_3R_25()) {
2241+ return true;
2242+ }
2243+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
2244+ return false;
2245+ }
2246+ if (jj_scan_token(RBRACKET)) {
2247+ return true;
2248+ }
2249+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
2250+ return false;
2251+ }
2252+ return false;
2253+ }
2254+
2255+ final private boolean jj_3R_86() {
2256+ Token xsp;
2257+ if (jj_3_8()) {
2258+ return true;
2259+ }
2260+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
2261+ return false;
2262+ }
2263+ while (true) {
2264+ xsp = jj_scanpos;
2265+ if (jj_3_8()) {
2266+ jj_scanpos = xsp;
2267+ break;
2268+ }
2269+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
2270+ return false;
2271+ }
2272+ }
2273+ while (true) {
2274+ xsp = jj_scanpos;
2275+ if (jj_3_9()) {
2276+ jj_scanpos = xsp;
2277+ break;
2278+ }
2279+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
2280+ return false;
2281+ }
2282+ }
2283+ return false;
2284+ }
2285+
2286+ final private boolean jj_3R_117() {
2287+ if (jj_scan_token(LT)) {
2288+ return true;
2289+ }
2290+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
2291+ return false;
2292+ }
2293+ return false;
2294+ }
2295+
2296+ final private boolean jj_3R_106() {
2297+ if (jj_3R_108()) {
2298+ return true;
2299+ }
2300+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
2301+ return false;
2302+ }
2303+ Token xsp;
2304+ while (true) {
2305+ xsp = jj_scanpos;
2306+ if (jj_3R_116()) {
2307+ jj_scanpos = xsp;
2308+ break;
2309+ }
2310+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
2311+ return false;
2312+ }
2313+ }
2314+ return false;
2315+ }
2316+
2317+ final private boolean jj_3R_113() {
2318+ Token xsp;
2319+ xsp = jj_scanpos;
2320+ if (jj_3R_117()) {
2321+ jj_scanpos = xsp;
2322+ if (jj_3R_118()) {
2323+ jj_scanpos = xsp;
2324+ if (jj_3R_119()) {
2325+ jj_scanpos = xsp;
2326+ if (jj_3R_120()) {
2327+ return true;
2328+ }
2329+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
2330+ return false;
2331+ }
2332+ } else if (jj_la == 0 && jj_scanpos == jj_lastpos) {
2333+ return false;
2334+ }
2335+ } else if (jj_la == 0 && jj_scanpos == jj_lastpos) {
2336+ return false;
2337+ }
2338+ } else if (jj_la == 0 && jj_scanpos == jj_lastpos) {
2339+ return false;
2340+ }
2341+ if (jj_3R_106()) {
2342+ return true;
2343+ }
2344+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
2345+ return false;
2346+ }
2347+ return false;
2348+ }
2349+
2350+ final private boolean jj_3R_111() {
2351+ if (jj_scan_token(NE)) {
2352+ return true;
2353+ }
2354+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
2355+ return false;
2356+ }
2357+ return false;
2358+ }
2359+
2360+ final private boolean jj_3R_109() {
2361+ if (jj_scan_token(INSTANCEOF)) {
2362+ return true;
2363+ }
2364+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
2365+ return false;
2366+ }
2367+ if (jj_3R_114()) {
2368+ return true;
2369+ }
2370+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
2371+ return false;
2372+ }
2373+ return false;
2374+ }
2375+
2376+ final private boolean jj_3R_104() {
2377+ if (jj_3R_106()) {
2378+ return true;
2379+ }
2380+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
2381+ return false;
2382+ }
2383+ Token xsp;
2384+ while (true) {
2385+ xsp = jj_scanpos;
2386+ if (jj_3R_113()) {
2387+ jj_scanpos = xsp;
2388+ break;
2389+ }
2390+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
2391+ return false;
2392+ }
2393+ }
2394+ return false;
2395+ }
2396+
2397+ final private boolean jj_3R_81() {
2398+ if (jj_scan_token(NEW)) {
2399+ return true;
2400+ }
2401+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
2402+ return false;
2403+ }
2404+ if (jj_3R_24()) {
2405+ return true;
2406+ }
2407+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
2408+ return false;
2409+ }
2410+ Token xsp;
2411+ xsp = jj_scanpos;
2412+ if (jj_3R_87()) {
2413+ jj_scanpos = xsp;
2414+ if (jj_3R_88()) {
2415+ return true;
2416+ }
2417+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
2418+ return false;
2419+ }
2420+ } else if (jj_la == 0 && jj_scanpos == jj_lastpos) {
2421+ return false;
2422+ }
2423+ return false;
2424+ }
2425+
2426+ final private boolean jj_3_7() {
2427+ if (jj_scan_token(NEW)) {
2428+ return true;
2429+ }
2430+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
2431+ return false;
2432+ }
2433+ if (jj_3R_23()) {
2434+ return true;
2435+ }
2436+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
2437+ return false;
2438+ }
2439+ if (jj_3R_86()) {
2440+ return true;
2441+ }
2442+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
2443+ return false;
2444+ }
2445+ return false;
2446+ }
2447+
2448+ final private boolean jj_3R_70() {
2449+ Token xsp;
2450+ xsp = jj_scanpos;
2451+ if (jj_3_7()) {
2452+ jj_scanpos = xsp;
2453+ if (jj_3R_81()) {
2454+ return true;
2455+ }
2456+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
2457+ return false;
2458+ }
2459+ } else if (jj_la == 0 && jj_scanpos == jj_lastpos) {
2460+ return false;
2461+ }
2462+ return false;
2463+ }
2464+
2465+ final private boolean jj_3R_97() {
2466+ if (jj_scan_token(COMMA)) {
2467+ return true;
2468+ }
2469+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
2470+ return false;
2471+ }
2472+ if (jj_3R_25()) {
2473+ return true;
2474+ }
2475+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
2476+ return false;
2477+ }
2478+ return false;
2479+ }
2480+
2481+ final private boolean jj_3R_39() {
2482+ if (jj_scan_token(ORASSIGN)) {
2483+ return true;
2484+ }
2485+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
2486+ return false;
2487+ }
2488+ return false;
2489+ }
2490+
2491+ final private boolean jj_3R_110() {
2492+ if (jj_scan_token(EQ)) {
2493+ return true;
2494+ }
2495+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
2496+ return false;
2497+ }
2498+ return false;
2499+ }
2500+
2501+ final private boolean jj_3R_102() {
2502+ if (jj_3R_104()) {
2503+ return true;
2504+ }
2505+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
2506+ return false;
2507+ }
2508+ Token xsp;
2509+ xsp = jj_scanpos;
2510+ if (jj_3R_109()) {
2511+ jj_scanpos = xsp;
2512+ } else if (jj_la == 0 && jj_scanpos == jj_lastpos) {
2513+ return false;
2514+ }
2515+ return false;
2516+ }
2517+
2518+ final private boolean jj_3R_107() {
2519+ Token xsp;
2520+ xsp = jj_scanpos;
2521+ if (jj_3R_110()) {
2522+ jj_scanpos = xsp;
2523+ if (jj_3R_111()) {
2524+ return true;
2525+ }
2526+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
2527+ return false;
2528+ }
2529+ } else if (jj_la == 0 && jj_scanpos == jj_lastpos) {
2530+ return false;
2531+ }
2532+ if (jj_3R_102()) {
2533+ return true;
2534+ }
2535+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
2536+ return false;
2537+ }
2538+ return false;
2539+ }
2540+
2541+ final private boolean jj_3R_94() {
2542+ if (jj_3R_25()) {
2543+ return true;
2544+ }
2545+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
2546+ return false;
2547+ }
2548+ Token xsp;
2549+ while (true) {
2550+ xsp = jj_scanpos;
2551+ if (jj_3R_97()) {
2552+ jj_scanpos = xsp;
2553+ break;
2554+ }
2555+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
2556+ return false;
2557+ }
2558+ }
2559+ return false;
2560+ }
2561+
2562+ final private boolean jj_3R_89() {
2563+ if (jj_3R_94()) {
2564+ return true;
2565+ }
2566+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
2567+ return false;
2568+ }
2569+ return false;
2570+ }
2571+
2572+ final private boolean jj_3R_38() {
2573+ if (jj_scan_token(XORASSIGN)) {
2574+ return true;
2575+ }
2576+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
2577+ return false;
2578+ }
2579+ return false;
2580+ }
2581+
2582+ final private boolean jj_3R_82() {
2583+ if (jj_scan_token(LPAREN)) {
2584+ return true;
2585+ }
2586+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
2587+ return false;
2588+ }
2589+ Token xsp;
2590+ xsp = jj_scanpos;
2591+ if (jj_3R_89()) {
2592+ jj_scanpos = xsp;
2593+ } else if (jj_la == 0 && jj_scanpos == jj_lastpos) {
2594+ return false;
2595+ }
2596+ if (jj_scan_token(RPAREN)) {
2597+ return true;
2598+ }
2599+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
2600+ return false;
2601+ }
2602+ return false;
2603+ }
2604+
2605+ final private boolean jj_3R_105() {
2606+ if (jj_scan_token(BIT_AND)) {
2607+ return true;
2608+ }
2609+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
2610+ return false;
2611+ }
2612+ if (jj_3R_100()) {
2613+ return true;
2614+ }
2615+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
2616+ return false;
2617+ }
2618+ return false;
2619+ }
2620+
2621+ final private boolean jj_3R_100() {
2622+ if (jj_3R_102()) {
2623+ return true;
2624+ }
2625+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
2626+ return false;
2627+ }
2628+ Token xsp;
2629+ while (true) {
2630+ xsp = jj_scanpos;
2631+ if (jj_3R_107()) {
2632+ jj_scanpos = xsp;
2633+ break;
2634+ }
2635+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
2636+ return false;
2637+ }
2638+ }
2639+ return false;
2640+ }
2641+
2642+ final private boolean jj_3R_37() {
2643+ if (jj_scan_token(ANDASSIGN)) {
2644+ return true;
2645+ }
2646+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
2647+ return false;
2648+ }
2649+ return false;
2650+ }
2651+
2652+ final private boolean jj_3R_85() {
2653+ if (jj_scan_token(NULL)) {
2654+ return true;
2655+ }
2656+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
2657+ return false;
2658+ }
2659+ return false;
2660+ }
2661+
2662+ final private boolean jj_3R_103() {
2663+ if (jj_scan_token(XOR)) {
2664+ return true;
2665+ }
2666+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
2667+ return false;
2668+ }
2669+ if (jj_3R_98()) {
2670+ return true;
2671+ }
2672+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
2673+ return false;
2674+ }
2675+ return false;
2676+ }
2677+
2678+ final private boolean jj_3R_98() {
2679+ if (jj_3R_100()) {
2680+ return true;
2681+ }
2682+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
2683+ return false;
2684+ }
2685+ Token xsp;
2686+ while (true) {
2687+ xsp = jj_scanpos;
2688+ if (jj_3R_105()) {
2689+ jj_scanpos = xsp;
2690+ break;
2691+ }
2692+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
2693+ return false;
2694+ }
2695+ }
2696+ return false;
2697+ }
2698+
2699+ final private boolean jj_3R_92() {
2700+ if (jj_scan_token(FALSE)) {
2701+ return true;
2702+ }
2703+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
2704+ return false;
2705+ }
2706+ return false;
2707+ }
2708+
2709+ final private boolean jj_3R_36() {
2710+ if (jj_scan_token(RUNSIGNEDSHIFTASSIGN)) {
2711+ return true;
2712+ }
2713+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
2714+ return false;
2715+ }
2716+ return false;
2717+ }
2718+
2719+ final private boolean jj_3R_91() {
2720+ if (jj_scan_token(TRUE)) {
2721+ return true;
2722+ }
2723+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
2724+ return false;
2725+ }
2726+ return false;
2727+ }
2728+
2729+ final private boolean jj_3R_84() {
2730+ Token xsp;
2731+ xsp = jj_scanpos;
2732+ if (jj_3R_91()) {
2733+ jj_scanpos = xsp;
2734+ if (jj_3R_92()) {
2735+ return true;
2736+ }
2737+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
2738+ return false;
2739+ }
2740+ } else if (jj_la == 0 && jj_scanpos == jj_lastpos) {
2741+ return false;
2742+ }
2743+ return false;
2744+ }
2745+
2746+ final private boolean jj_3R_101() {
2747+ if (jj_scan_token(BIT_OR)) {
2748+ return true;
2749+ }
2750+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
2751+ return false;
2752+ }
2753+ if (jj_3R_95()) {
2754+ return true;
2755+ }
2756+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
2757+ return false;
2758+ }
2759+ return false;
2760+ }
2761+
2762+ final private boolean jj_3R_95() {
2763+ if (jj_3R_98()) {
2764+ return true;
2765+ }
2766+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
2767+ return false;
2768+ }
2769+ Token xsp;
2770+ while (true) {
2771+ xsp = jj_scanpos;
2772+ if (jj_3R_103()) {
2773+ jj_scanpos = xsp;
2774+ break;
2775+ }
2776+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
2777+ return false;
2778+ }
2779+ }
2780+ return false;
2781+ }
2782+
2783+ final private boolean jj_3R_35() {
2784+ if (jj_scan_token(RSIGNEDSHIFTASSIGN)) {
2785+ return true;
2786+ }
2787+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
2788+ return false;
2789+ }
2790+ return false;
2791+ }
2792+
2793+ final private boolean jj_3R_80() {
2794+ if (jj_3R_85()) {
2795+ return true;
2796+ }
2797+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
2798+ return false;
2799+ }
2800+ return false;
2801+ }
2802+
2803+ final private boolean jj_3R_66() {
2804+ if (jj_3R_69()) {
2805+ return true;
2806+ }
2807+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
2808+ return false;
2809+ }
2810+ return false;
2811+ }
2812+
2813+ final private boolean jj_3R_79() {
2814+ if (jj_3R_84()) {
2815+ return true;
2816+ }
2817+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
2818+ return false;
2819+ }
2820+ return false;
2821+ }
2822+
2823+ final private boolean jj_3R_78() {
2824+ if (jj_scan_token(STRING_LITERAL)) {
2825+ return true;
2826+ }
2827+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
2828+ return false;
2829+ }
2830+ return false;
2831+ }
2832+
2833+ final private boolean jj_3R_99() {
2834+ if (jj_scan_token(SC_AND)) {
2835+ return true;
2836+ }
2837+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
2838+ return false;
2839+ }
2840+ if (jj_3R_90()) {
2841+ return true;
2842+ }
2843+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
2844+ return false;
2845+ }
2846+ return false;
2847+ }
2848+
2849+ final private boolean jj_3R_90() {
2850+ if (jj_3R_95()) {
2851+ return true;
2852+ }
2853+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
2854+ return false;
2855+ }
2856+ Token xsp;
2857+ while (true) {
2858+ xsp = jj_scanpos;
2859+ if (jj_3R_101()) {
2860+ jj_scanpos = xsp;
2861+ break;
2862+ }
2863+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
2864+ return false;
2865+ }
2866+ }
2867+ return false;
2868+ }
2869+
2870+ final private boolean jj_3R_34() {
2871+ if (jj_scan_token(LSHIFTASSIGN)) {
2872+ return true;
2873+ }
2874+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
2875+ return false;
2876+ }
2877+ return false;
2878+ }
2879+
2880+ final private boolean jj_3R_65() {
2881+ if (jj_scan_token(NEW)) {
2882+ return true;
2883+ }
2884+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
2885+ return false;
2886+ }
2887+ return false;
2888+ }
2889+
2890+ final private boolean jj_3R_77() {
2891+ if (jj_scan_token(CHARACTER_LITERAL)) {
2892+ return true;
2893+ }
2894+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
2895+ return false;
2896+ }
2897+ return false;
2898+ }
2899+
2900+ final private boolean jj_3R_76() {
2901+ if (jj_scan_token(FLOATING_POINT_LITERAL)) {
2902+ return true;
2903+ }
2904+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
2905+ return false;
2906+ }
2907+ return false;
2908+ }
2909+
2910+ final private boolean jj_3R_33() {
2911+ if (jj_scan_token(MINUSASSIGN)) {
2912+ return true;
2913+ }
2914+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
2915+ return false;
2916+ }
2917+ return false;
2918+ }
2919+
2920+ final private boolean jj_3R_69() {
2921+ Token xsp;
2922+ xsp = jj_scanpos;
2923+ if (jj_3R_75()) {
2924+ jj_scanpos = xsp;
2925+ if (jj_3R_76()) {
2926+ jj_scanpos = xsp;
2927+ if (jj_3R_77()) {
2928+ jj_scanpos = xsp;
2929+ if (jj_3R_78()) {
2930+ jj_scanpos = xsp;
2931+ if (jj_3R_79()) {
2932+ jj_scanpos = xsp;
2933+ if (jj_3R_80()) {
2934+ return true;
2935+ }
2936+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
2937+ return false;
2938+ }
2939+ } else if (jj_la == 0 && jj_scanpos == jj_lastpos) {
2940+ return false;
2941+ }
2942+ } else if (jj_la == 0 && jj_scanpos == jj_lastpos) {
2943+ return false;
2944+ }
2945+ } else if (jj_la == 0 && jj_scanpos == jj_lastpos) {
2946+ return false;
2947+ }
2948+ } else if (jj_la == 0 && jj_scanpos == jj_lastpos) {
2949+ return false;
2950+ }
2951+ } else if (jj_la == 0 && jj_scanpos == jj_lastpos) {
2952+ return false;
2953+ }
2954+ return false;
2955+ }
2956+
2957+ final private boolean jj_3R_75() {
2958+ if (jj_scan_token(INTEGER_LITERAL)) {
2959+ return true;
2960+ }
2961+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
2962+ return false;
2963+ }
2964+ return false;
2965+ }
2966+
2967+ final private boolean jj_3R_96() {
2968+ if (jj_scan_token(SC_OR)) {
2969+ return true;
2970+ }
2971+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
2972+ return false;
2973+ }
2974+ if (jj_3R_83()) {
2975+ return true;
2976+ }
2977+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
2978+ return false;
2979+ }
2980+ return false;
2981+ }
2982+
2983+ final private boolean jj_3R_83() {
2984+ if (jj_3R_90()) {
2985+ return true;
2986+ }
2987+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
2988+ return false;
2989+ }
2990+ Token xsp;
2991+ while (true) {
2992+ xsp = jj_scanpos;
2993+ if (jj_3R_99()) {
2994+ jj_scanpos = xsp;
2995+ break;
2996+ }
2997+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
2998+ return false;
2999+ }
3000+ }
3001+ return false;
3002+ }
3003+
3004+ final private boolean jj_3R_64() {
3005+ if (jj_scan_token(SUPER)) {
3006+ return true;
3007+ }
3008+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
3009+ return false;
3010+ }
3011+ return false;
3012+ }
3013+
3014+ final private boolean jj_3R_32() {
3015+ if (jj_scan_token(PLUSASSIGN)) {
3016+ return true;
3017+ }
3018+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
3019+ return false;
3020+ }
3021+ return false;
3022+ }
3023+
3024+ final private boolean jj_3R_73() {
3025+ if (jj_3R_82()) {
3026+ return true;
3027+ }
3028+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
3029+ return false;
3030+ }
3031+ return false;
3032+ }
3033+
3034+ final private boolean jj_3R_72() {
3035+ if (jj_scan_token(DOT)) {
3036+ return true;
3037+ }
3038+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
3039+ return false;
3040+ }
3041+ if (jj_scan_token(IDENTIFIER)) {
3042+ return true;
3043+ }
3044+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
3045+ return false;
3046+ }
3047+ return false;
3048+ }
3049+
3050+ final private boolean jj_3R_74() {
3051+ if (jj_3R_83()) {
3052+ return true;
3053+ }
3054+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
3055+ return false;
3056+ }
3057+ Token xsp;
3058+ while (true) {
3059+ xsp = jj_scanpos;
3060+ if (jj_3R_96()) {
3061+ jj_scanpos = xsp;
3062+ break;
3063+ }
3064+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
3065+ return false;
3066+ }
3067+ }
3068+ return false;
3069+ }
3070+
3071+ final private boolean jj_3R_63() {
3072+ if (jj_scan_token(THIS)) {
3073+ return true;
3074+ }
3075+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
3076+ return false;
3077+ }
3078+ return false;
3079+ }
3080+
3081+ final private boolean jj_3R_31() {
3082+ if (jj_scan_token(REMASSIGN)) {
3083+ return true;
3084+ }
3085+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
3086+ return false;
3087+ }
3088+ return false;
3089+ }
3090+
3091+ final private boolean jj_3R_58() {
3092+ Token xsp;
3093+ xsp = jj_scanpos;
3094+ if (jj_3R_71()) {
3095+ jj_scanpos = xsp;
3096+ if (jj_3R_72()) {
3097+ jj_scanpos = xsp;
3098+ if (jj_3R_73()) {
3099+ return true;
3100+ }
3101+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
3102+ return false;
3103+ }
3104+ } else if (jj_la == 0 && jj_scanpos == jj_lastpos) {
3105+ return false;
3106+ }
3107+ } else if (jj_la == 0 && jj_scanpos == jj_lastpos) {
3108+ return false;
3109+ }
3110+ return false;
3111+ }
3112+
3113+ final private boolean jj_3R_71() {
3114+ if (jj_scan_token(LBRACKET)) {
3115+ return true;
3116+ }
3117+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
3118+ return false;
3119+ }
3120+ if (jj_3R_25()) {
3121+ return true;
3122+ }
3123+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
3124+ return false;
3125+ }
3126+ if (jj_scan_token(RBRACKET)) {
3127+ return true;
3128+ }
3129+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
3130+ return false;
3131+ }
3132+ return false;
3133+ }
3134+
3135+ final private boolean jj_3R_93() {
3136+ if (jj_scan_token(HOOK)) {
3137+ return true;
3138+ }
3139+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
3140+ return false;
3141+ }
3142+ if (jj_3R_25()) {
3143+ return true;
3144+ }
3145+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
3146+ return false;
3147+ }
3148+ if (jj_scan_token(COLON)) {
3149+ return true;
3150+ }
3151+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
3152+ return false;
3153+ }
3154+ if (jj_3R_68()) {
3155+ return true;
3156+ }
3157+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
3158+ return false;
3159+ }
3160+ return false;
3161+ }
3162+
3163+ final private boolean jj_3R_57() {
3164+ if (jj_3R_70()) {
3165+ return true;
3166+ }
3167+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
3168+ return false;
3169+ }
3170+ return false;
3171+ }
3172+
3173+ final private boolean jj_3R_30() {
3174+ if (jj_scan_token(SLASHASSIGN)) {
3175+ return true;
3176+ }
3177+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
3178+ return false;
3179+ }
3180+ return false;
3181+ }
3182+
3183+ final private boolean jj_3R_27() {
3184+ if (jj_3R_58()) {
3185+ return true;
3186+ }
3187+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
3188+ return false;
3189+ }
3190+ return false;
3191+ }
3192+
3193+ final private boolean jj_3R_56() {
3194+ if (jj_scan_token(LPAREN)) {
3195+ return true;
3196+ }
3197+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
3198+ return false;
3199+ }
3200+ if (jj_3R_25()) {
3201+ return true;
3202+ }
3203+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
3204+ return false;
3205+ }
3206+ if (jj_scan_token(RPAREN)) {
3207+ return true;
3208+ }
3209+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
3210+ return false;
3211+ }
3212+ return false;
3213+ }
3214+
3215+ final private boolean jj_3R_152() {
3216+ if (jj_scan_token(LBRACKET)) {
3217+ return true;
3218+ }
3219+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
3220+ return false;
3221+ }
3222+ if (jj_scan_token(RBRACKET)) {
3223+ return true;
3224+ }
3225+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
3226+ return false;
3227+ }
3228+ return false;
3229+ }
3230+
3231+ final private boolean jj_3R_55() {
3232+ if (jj_scan_token(SUPER)) {
3233+ return true;
3234+ }
3235+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
3236+ return false;
3237+ }
3238+ if (jj_scan_token(DOT)) {
3239+ return true;
3240+ }
3241+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
3242+ return false;
3243+ }
3244+ if (jj_scan_token(IDENTIFIER)) {
3245+ return true;
3246+ }
3247+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
3248+ return false;
3249+ }
3250+ return false;
3251+ }
3252+
3253+ final private boolean jj_3R_29() {
3254+ if (jj_scan_token(STARASSIGN)) {
3255+ return true;
3256+ }
3257+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
3258+ return false;
3259+ }
3260+ return false;
3261+ }
3262+
3263+ final private boolean jj_3R_68() {
3264+ if (jj_3R_74()) {
3265+ return true;
3266+ }
3267+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
3268+ return false;
3269+ }
3270+ Token xsp;
3271+ xsp = jj_scanpos;
3272+ if (jj_3R_93()) {
3273+ jj_scanpos = xsp;
3274+ } else if (jj_la == 0 && jj_scanpos == jj_lastpos) {
3275+ return false;
3276+ }
3277+ return false;
3278+ }
3279+
3280+ final private boolean jj_3R_54() {
3281+ if (jj_scan_token(THIS)) {
3282+ return true;
3283+ }
3284+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
3285+ return false;
3286+ }
3287+ return false;
3288+ }
3289+
3290+ final private boolean jj_3R_62() {
3291+ if (jj_scan_token(IDENTIFIER)) {
3292+ return true;
3293+ }
3294+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
3295+ return false;
3296+ }
3297+ return false;
3298+ }
3299+
3300+ final private boolean jj_3R_53() {
3301+ if (jj_3R_24()) {
3302+ return true;
3303+ }
3304+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
3305+ return false;
3306+ }
3307+ return false;
3308+ }
3309+
3310+ final private boolean jj_3R_153() {
3311+ if (jj_scan_token(LBRACKET)) {
3312+ return true;
3313+ }
3314+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
3315+ return false;
3316+ }
3317+ if (jj_scan_token(RBRACKET)) {
3318+ return true;
3319+ }
3320+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
3321+ return false;
3322+ }
3323+ return false;
3324+ }
3325+
3326+ final private boolean jj_3R_26() {
3327+ Token xsp;
3328+ xsp = jj_scanpos;
3329+ if (jj_3R_52()) {
3330+ jj_scanpos = xsp;
3331+ if (jj_3R_53()) {
3332+ jj_scanpos = xsp;
3333+ if (jj_3R_54()) {
3334+ jj_scanpos = xsp;
3335+ if (jj_3R_55()) {
3336+ jj_scanpos = xsp;
3337+ if (jj_3R_56()) {
3338+ jj_scanpos = xsp;
3339+ if (jj_3R_57()) {
3340+ return true;
3341+ }
3342+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
3343+ return false;
3344+ }
3345+ } else if (jj_la == 0 && jj_scanpos == jj_lastpos) {
3346+ return false;
3347+ }
3348+ } else if (jj_la == 0 && jj_scanpos == jj_lastpos) {
3349+ return false;
3350+ }
3351+ } else if (jj_la == 0 && jj_scanpos == jj_lastpos) {
3352+ return false;
3353+ }
3354+ } else if (jj_la == 0 && jj_scanpos == jj_lastpos) {
3355+ return false;
3356+ }
3357+ } else if (jj_la == 0 && jj_scanpos == jj_lastpos) {
3358+ return false;
3359+ }
3360+ return false;
3361+ }
3362+
3363+ final private boolean jj_3R_52() {
3364+ if (jj_3R_69()) {
3365+ return true;
3366+ }
3367+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
3368+ return false;
3369+ }
3370+ return false;
3371+ }
3372+
3373+ final private boolean jj_3R_21() {
3374+ Token xsp;
3375+ xsp = jj_scanpos;
3376+ if (jj_3R_28()) {
3377+ jj_scanpos = xsp;
3378+ if (jj_3R_29()) {
3379+ jj_scanpos = xsp;
3380+ if (jj_3R_30()) {
3381+ jj_scanpos = xsp;
3382+ if (jj_3R_31()) {
3383+ jj_scanpos = xsp;
3384+ if (jj_3R_32()) {
3385+ jj_scanpos = xsp;
3386+ if (jj_3R_33()) {
3387+ jj_scanpos = xsp;
3388+ if (jj_3R_34()) {
3389+ jj_scanpos = xsp;
3390+ if (jj_3R_35()) {
3391+ jj_scanpos = xsp;
3392+ if (jj_3R_36()) {
3393+ jj_scanpos = xsp;
3394+ if (jj_3R_37()) {
3395+ jj_scanpos = xsp;
3396+ if (jj_3R_38()) {
3397+ jj_scanpos = xsp;
3398+ if (jj_3R_39()) {
3399+ return true;
3400+ }
3401+ if (jj_la == 0
3402+ && jj_scanpos == jj_lastpos) {
3403+ return false;
3404+ }
3405+ } else if (jj_la == 0
3406+ && jj_scanpos == jj_lastpos) {
3407+ return false;
3408+ }
3409+ } else if (jj_la == 0
3410+ && jj_scanpos == jj_lastpos) {
3411+ return false;
3412+ }
3413+ } else if (jj_la == 0 && jj_scanpos == jj_lastpos) {
3414+ return false;
3415+ }
3416+ } else if (jj_la == 0 && jj_scanpos == jj_lastpos) {
3417+ return false;
3418+ }
3419+ } else if (jj_la == 0 && jj_scanpos == jj_lastpos) {
3420+ return false;
3421+ }
3422+ } else if (jj_la == 0 && jj_scanpos == jj_lastpos) {
3423+ return false;
3424+ }
3425+ } else if (jj_la == 0 && jj_scanpos == jj_lastpos) {
3426+ return false;
3427+ }
3428+ } else if (jj_la == 0 && jj_scanpos == jj_lastpos) {
3429+ return false;
3430+ }
3431+ } else if (jj_la == 0 && jj_scanpos == jj_lastpos) {
3432+ return false;
3433+ }
3434+ } else if (jj_la == 0 && jj_scanpos == jj_lastpos) {
3435+ return false;
3436+ }
3437+ } else if (jj_la == 0 && jj_scanpos == jj_lastpos) {
3438+ return false;
3439+ }
3440+ return false;
3441+ }
3442+
3443+ final private boolean jj_3R_28() {
3444+ if (jj_scan_token(ASSIGN)) {
3445+ return true;
3446+ }
3447+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
3448+ return false;
3449+ }
3450+ return false;
3451+ }
3452+
3453+ final private boolean jj_3R_61() {
3454+ if (jj_scan_token(LPAREN)) {
3455+ return true;
3456+ }
3457+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
3458+ return false;
3459+ }
3460+ return false;
3461+ }
3462+
3463+ final private boolean jj_3_2() {
3464+ if (jj_3R_20()) {
3465+ return true;
3466+ }
3467+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
3468+ return false;
3469+ }
3470+ if (jj_3R_21()) {
3471+ return true;
3472+ }
3473+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
3474+ return false;
3475+ }
3476+ return false;
3477+ }
3478+
3479+ final private boolean jj_3R_20() {
3480+ if (jj_3R_26()) {
3481+ return true;
3482+ }
3483+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
3484+ return false;
3485+ }
3486+ Token xsp;
3487+ while (true) {
3488+ xsp = jj_scanpos;
3489+ if (jj_3R_27()) {
3490+ jj_scanpos = xsp;
3491+ break;
3492+ }
3493+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
3494+ return false;
3495+ }
3496+ }
3497+ return false;
3498+ }
3499+
3500+ final private boolean jj_3R_60() {
3501+ if (jj_scan_token(BANG)) {
3502+ return true;
3503+ }
3504+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
3505+ return false;
3506+ }
3507+ return false;
3508+ }
3509+
3510+ final private boolean jj_3R_155() {
3511+ if (jj_scan_token(DECR)) {
3512+ return true;
3513+ }
3514+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
3515+ return false;
3516+ }
3517+ return false;
3518+ }
3519+
3520+ final private boolean jj_3R_67() {
3521+ if (jj_3R_20()) {
3522+ return true;
3523+ }
3524+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
3525+ return false;
3526+ }
3527+ if (jj_3R_21()) {
3528+ return true;
3529+ }
3530+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
3531+ return false;
3532+ }
3533+ if (jj_3R_25()) {
3534+ return true;
3535+ }
3536+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
3537+ return false;
3538+ }
3539+ return false;
3540+ }
3541+
3542+ final private boolean jj_3R_150() {
3543+ if (jj_scan_token(LPAREN)) {
3544+ return true;
3545+ }
3546+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
3547+ return false;
3548+ }
3549+ if (jj_3R_24()) {
3550+ return true;
3551+ }
3552+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
3553+ return false;
3554+ }
3555+ Token xsp;
3556+ while (true) {
3557+ xsp = jj_scanpos;
3558+ if (jj_3R_153()) {
3559+ jj_scanpos = xsp;
3560+ break;
3561+ }
3562+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
3563+ return false;
3564+ }
3565+ }
3566+ if (jj_scan_token(RPAREN)) {
3567+ return true;
3568+ }
3569+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
3570+ return false;
3571+ }
3572+ if (jj_3R_136()) {
3573+ return true;
3574+ }
3575+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
3576+ return false;
3577+ }
3578+ return false;
3579+ }
3580+
3581+ final private boolean jj_3R_59() {
3582+ if (jj_scan_token(TILDE)) {
3583+ return true;
3584+ }
3585+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
3586+ return false;
3587+ }
3588+ return false;
3589+ }
3590+
3591+ final private boolean jj_3R_51() {
3592+ if (jj_3R_68()) {
3593+ return true;
3594+ }
3595+ if (jj_la == 0 && jj_scanpos == jj_lastpos) {
3596+ return false;
3597+ }
3598+ return false;
3599+ }
3600+
3601+ public ExpressionParserTokenManager token_source;
3602+ ASCII_UCodeESC_CharStream jj_input_stream;
3603+ public Token token, jj_nt;
3604+ private int jj_ntk;
3605+ private Token jj_scanpos, jj_lastpos;
3606+ private int jj_la;
3607+ public boolean lookingAhead = false;
3608+ private int jj_gen;
3609+ final private int[] jj_la1 = new int[44];
3610+ final private int[] jj_la1_0 = { 0x8209400, 0x0, 0x8209400, 0x0, 0x1000000,
3611+ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
3612+ 0x0, 0x0, 0x0, 0x0, 0x0, 0x1000000, 0x0, 0x0, 0x1000000, 0x1000000,
3613+ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1000000, 0x0, 0x1000000,
3614+ 0x1000000, 0x1000000, 0x0, 0x0, 0x0, };
3615+ final private int[] jj_la1_1 = { 0x2014, 0x0, 0x2014, 0x0, 0x884480c0, 0x0,
3616+ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x2, 0x0, 0x0, 0x0, 0x0, 0x0,
3617+ 0x0, 0x0, 0x0, 0x0, 0x884480c0, 0x0, 0x0, 0x884480c0, 0x884480c0, 0x0,
3618+ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x884480c0, 0x0, 0x88400080, 0x400000,
3619+ 0x884480c0, 0x0, 0x0, 0x40, };
3620+ final private int[] jj_la1_2 = { 0x8, 0x400, 0x0, 0x2000, 0xf00c004e,
3621+ 0x8000, 0x100000, 0x4000000, 0x8000000, 0x0, 0x0, 0x0, 0x2400000,
3622+ 0x2400000, 0x0, 0x1830000, 0x1830000, 0x0, 0x0, 0xc0000000,
3623+ 0xc0000000, 0x0, 0x0, 0xc0000000, 0xf00c004e, 0xc0000, 0xc0000, 0x4e,
3624+ 0xc004e, 0x40, 0x30000000, 0x30000000, 0x400, 0x400, 0x40, 0x4440,
3625+ 0x4e, 0x4440, 0x6, 0x0, 0xf00c004e, 0x2000, 0x440, 0x0, };
3626+ final private int[] jj_la1_3 = { 0x0, 0x0, 0x0, 0x0, 0x0, 0xffe00, 0x0, 0x0,
3627+ 0x0, 0x8, 0x10, 0x4, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1c0, 0x1c0, 0x0, 0x0,
3628+ 0x23, 0x23, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
3629+ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, };
3630+ final private JJExpressionParserCalls[] jj_2_rtns = new JJExpressionParserCalls[9];
3631+ private boolean jj_rescan = false;
3632+ private int jj_gc = 0;
3633+
3634+ public ExpressionParser(java.io.InputStream stream) {
3635+ jj_input_stream = new ASCII_UCodeESC_CharStream(stream, 1, 1);
3636+ token_source = new ExpressionParserTokenManager(jj_input_stream);
3637+ token = new Token();
3638+ jj_ntk = -1;
3639+ jj_gen = 0;
3640+ for (int i = 0; i < 44; i++) {
3641+ jj_la1[i] = -1;
3642+ }
3643+ for (int i = 0; i < jj_2_rtns.length; i++) {
3644+ jj_2_rtns[i] = new JJExpressionParserCalls();
3645+ }
3646+ }
3647+
3648+ public void ReInit(java.io.InputStream stream) {
3649+ jj_input_stream.ReInit(stream, 1, 1);
3650+ token_source.ReInit(jj_input_stream);
3651+ token = new Token();
3652+ jj_ntk = -1;
3653+ jj_gen = 0;
3654+ for (int i = 0; i < 44; i++) {
3655+ jj_la1[i] = -1;
3656+ }
3657+ for (int i = 0; i < jj_2_rtns.length; i++) {
3658+ jj_2_rtns[i] = new JJExpressionParserCalls();
3659+ }
3660+ }
3661+
3662+ public ExpressionParser(ExpressionParserTokenManager tm) {
3663+ token_source = tm;
3664+ token = new Token();
3665+ jj_ntk = -1;
3666+ jj_gen = 0;
3667+ for (int i = 0; i < 44; i++) {
3668+ jj_la1[i] = -1;
3669+ }
3670+ for (int i = 0; i < jj_2_rtns.length; i++) {
3671+ jj_2_rtns[i] = new JJExpressionParserCalls();
3672+ }
3673+ }
3674+
3675+ public void ReInit(ExpressionParserTokenManager tm) {
3676+ token_source = tm;
3677+ token = new Token();
3678+ jj_ntk = -1;
3679+ jj_gen = 0;
3680+ for (int i = 0; i < 44; i++) {
3681+ jj_la1[i] = -1;
3682+ }
3683+ for (int i = 0; i < jj_2_rtns.length; i++) {
3684+ jj_2_rtns[i] = new JJExpressionParserCalls();
3685+ }
3686+ }
3687+
3688+ final private Token jj_consume_token(int kind) throws ParseException {
3689+ Token oldToken;
3690+ if ((oldToken = token).next != null) {
3691+ token = token.next;
3692+ } else {
3693+ token = token.next = token_source.getNextToken();
3694+ }
3695+ jj_ntk = -1;
3696+ if (token.kind == kind) {
3697+ jj_gen++;
3698+ if (++jj_gc > 100) {
3699+ jj_gc = 0;
3700+ for (JJExpressionParserCalls jj_2_rtn : jj_2_rtns) {
3701+ JJExpressionParserCalls c = jj_2_rtn;
3702+ while (c != null) {
3703+ if (c.gen < jj_gen) {
3704+ c.first = null;
3705+ }
3706+ c = c.next;
3707+ }
3708+ }
3709+ }
3710+ return token;
3711+ }
3712+ token = oldToken;
3713+ jj_kind = kind;
3714+ throw generateParseException();
3715+ }
3716+
3717+ final private boolean jj_scan_token(int kind) {
3718+ if (jj_scanpos == jj_lastpos) {
3719+ jj_la--;
3720+ if (jj_scanpos.next == null) {
3721+ jj_lastpos = jj_scanpos = jj_scanpos.next = token_source
3722+ .getNextToken();
3723+ } else {
3724+ jj_lastpos = jj_scanpos = jj_scanpos.next;
3725+ }
3726+ } else {
3727+ jj_scanpos = jj_scanpos.next;
3728+ }
3729+ if (jj_rescan) {
3730+ int i = 0;
3731+ Token tok = token;
3732+ while (tok != null && tok != jj_scanpos) {
3733+ i++;
3734+ tok = tok.next;
3735+ }
3736+ if (tok != null) {
3737+ jj_add_error_token(kind, i);
3738+ }
3739+ }
3740+ return (jj_scanpos.kind != kind);
3741+ }
3742+
3743+ final public Token getNextToken() {
3744+ if (token.next != null) {
3745+ token = token.next;
3746+ } else {
3747+ token = token.next = token_source.getNextToken();
3748+ }
3749+ jj_ntk = -1;
3750+ jj_gen++;
3751+ return token;
3752+ }
3753+
3754+ final public Token getToken(int index) {
3755+ Token t = lookingAhead ? jj_scanpos : token;
3756+ for (int i = 0; i < index; i++) {
3757+ if (t.next != null) {
3758+ t = t.next;
3759+ } else {
3760+ t = t.next = token_source.getNextToken();
3761+ }
3762+ }
3763+ return t;
3764+ }
3765+
3766+ final private int jj_ntk() {
3767+ if ((jj_nt = token.next) == null) {
3768+ return (jj_ntk = (token.next=token_source.getNextToken()).kind);
3769+ } else {
3770+ return (jj_ntk = jj_nt.kind);
3771+ }
3772+ }
3773+
3774+ private java.util.Vector<int[]> jj_expentries = new java.util.Vector<int[]>();
3775+ private int[] jj_expentry;
3776+ private int jj_kind = -1;
3777+ private int[] jj_lasttokens = new int[100];
3778+ private int jj_endpos;
3779+
3780+ private void jj_add_error_token(int kind, int pos) {
3781+ if (pos >= 100) {
3782+ return;
3783+ }
3784+ if (pos == jj_endpos + 1) {
3785+ jj_lasttokens[jj_endpos++] = kind;
3786+ } else if (jj_endpos != 0) {
3787+ jj_expentry = new int[jj_endpos];
3788+ for (int i = 0; i < jj_endpos; i++) {
3789+ jj_expentry[i] = jj_lasttokens[i];
3790+ }
3791+ boolean exists = false;
3792+ for (java.util.Enumeration<int[]> enum_ = jj_expentries.elements(); enum_
3793+ .hasMoreElements();) {
3794+ int[] oldentry = (enum_.nextElement());
3795+ if (oldentry.length == jj_expentry.length) {
3796+ exists = true;
3797+ for (int i = 0; i < jj_expentry.length; i++) {
3798+ if (oldentry[i] != jj_expentry[i]) {
3799+ exists = false;
3800+ break;
3801+ }
3802+ }
3803+ if (exists) {
3804+ break;
3805+ }
3806+ }
3807+ }
3808+ if (!exists) {
3809+ jj_expentries.addElement(jj_expentry);
3810+ }
3811+ if (pos != 0) {
3812+ jj_lasttokens[(jj_endpos = pos) - 1] = kind;
3813+ }
3814+ }
3815+ }
3816+
3817+ final public ParseException generateParseException() {
3818+ jj_expentries.removeAllElements();
3819+ boolean[] la1tokens = new boolean[116];
3820+ for (int i = 0; i < 116; i++) {
3821+ la1tokens[i] = false;
3822+ }
3823+ if (jj_kind >= 0) {
3824+ la1tokens[jj_kind] = true;
3825+ jj_kind = -1;
3826+ }
3827+ for (int i = 0; i < 44; i++) {
3828+ if (jj_la1[i] == jj_gen) {
3829+ for (int j = 0; j < 32; j++) {
3830+ if ((jj_la1_0[i] & (1<<j)) != 0) {
3831+ la1tokens[j] = true;
3832+ }
3833+ if ((jj_la1_1[i] & (1<<j)) != 0) {
3834+ la1tokens[32+j] = true;
3835+ }
3836+ if ((jj_la1_2[i] & (1<<j)) != 0) {
3837+ la1tokens[64+j] = true;
3838+ }
3839+ if ((jj_la1_3[i] & (1<<j)) != 0) {
3840+ la1tokens[96+j] = true;
3841+ }
3842+ }
3843+ }
3844+ }
3845+ for (int i = 0; i < 116; i++) {
3846+ if (la1tokens[i]) {
3847+ jj_expentry = new int[1];
3848+ jj_expentry[0] = i;
3849+ jj_expentries.addElement(jj_expentry);
3850+ }
3851+ }
3852+ jj_endpos = 0;
3853+ jj_rescan_token();
3854+ jj_add_error_token(0, 0);
3855+ int[][] exptokseq = new int[jj_expentries.size()][];
3856+ for (int i = 0; i < jj_expentries.size(); i++) {
3857+ exptokseq[i] = jj_expentries.elementAt(i);
3858+ }
3859+ return new ParseException(token, exptokseq, tokenImage);
3860+ }
3861+
3862+ final public void enable_tracing() {
3863+ }
3864+
3865+ final public void disable_tracing() {
3866+ }
3867+
3868+ final private void jj_rescan_token() {
3869+ jj_rescan = true;
3870+ for (int i = 0; i < 9; i++) {
3871+ JJExpressionParserCalls p = jj_2_rtns[i];
3872+ do {
3873+ if (p.gen > jj_gen) {
3874+ jj_la = p.arg;
3875+ jj_lastpos = jj_scanpos = p.first;
3876+ switch (i) {
3877+ case 0:
3878+ jj_3_1();
3879+ break;
3880+ case 1:
3881+ jj_3_2();
3882+ break;
3883+ case 2:
3884+ jj_3_3();
3885+ break;
3886+ case 3:
3887+ jj_3_4();
3888+ break;
3889+ case 4:
3890+ jj_3_5();
3891+ break;
3892+ case 5:
3893+ jj_3_6();
3894+ break;
3895+ case 6:
3896+ jj_3_7();
3897+ break;
3898+ case 7:
3899+ jj_3_8();
3900+ break;
3901+ case 8:
3902+ jj_3_9();
3903+ break;
3904+ }
3905+ }
3906+ p = p.next;
3907+ } while (p != null);
3908+ }
3909+ jj_rescan = false;
3910+ }
3911+
3912+ final private void jj_save(int index, int xla) {
3913+ JJExpressionParserCalls p = jj_2_rtns[index];
3914+ while (p.gen > jj_gen) {
3915+ if (p.next == null) {
3916+ p = p.next = new JJExpressionParserCalls();
3917+ break;
3918+ }
3919+ p = p.next;
3920+ }
3921+ p.gen = jj_gen + xla - jj_la;
3922+ p.first = token;
3923+ p.arg = xla;
3924+ }
3925+
3926+}
3927+
3928+final class JJExpressionParserCalls {
3929+ int gen;
3930+ Token first;
3931+ int arg;
3932+ JJExpressionParserCalls next;
3933+}
java/pkg/com/sun/tools/example/debug/expr/ExpressionParserConstants.java+264−0
@@ -0,0 +1,264 @@
1+/*
2+ * Copyright (c) 1999, 2001, Oracle and/or its affiliates. All rights reserved.
3+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+ *
5+ * This code is free software; you can redistribute it and/or modify it
6+ * under the terms of the GNU General Public License version 2 only, as
7+ * published by the Free Software Foundation. Oracle designates this
8+ * particular file as subject to the "Classpath" exception as provided
9+ * by Oracle in the LICENSE file that accompanied this code.
10+ *
11+ * This code is distributed in the hope that it will be useful, but WITHOUT
12+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+ * version 2 for more details (a copy is included in the LICENSE file that
15+ * accompanied this code).
16+ *
17+ * You should have received a copy of the GNU General Public License version
18+ * 2 along with this work; if not, write to the Free Software Foundation,
19+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+ *
21+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+ * or visit www.oracle.com if you need additional information or have any
23+ * questions.
24+ */
25+
26+/* Generated By:JavaCC: Do not edit this line. ExpressionParserConstants.java */
27+package com.sun.tools.example.debug.expr;
28+
29+public interface ExpressionParserConstants {
30+
31+ int EOF = 0;
32+ int SINGLE_LINE_COMMENT = 6;
33+ int FORMAL_COMMENT = 7;
34+ int MULTI_LINE_COMMENT = 8;
35+ int ABSTRACT = 9;
36+ int BOOLEAN = 10;
37+ int BREAK = 11;
38+ int BYTE = 12;
39+ int CASE = 13;
40+ int CATCH = 14;
41+ int CHAR = 15;
42+ int CLASS = 16;
43+ int CONST = 17;
44+ int CONTINUE = 18;
45+ int _DEFAULT = 19;
46+ int DO = 20;
47+ int DOUBLE = 21;
48+ int ELSE = 22;
49+ int EXTENDS = 23;
50+ int FALSE = 24;
51+ int FINAL = 25;
52+ int FINALLY = 26;
53+ int FLOAT = 27;
54+ int FOR = 28;
55+ int GOTO = 29;
56+ int IF = 30;
57+ int IMPLEMENTS = 31;
58+ int IMPORT = 32;
59+ int INSTANCEOF = 33;
60+ int INT = 34;
61+ int INTERFACE = 35;
62+ int LONG = 36;
63+ int NATIVE = 37;
64+ int NEW = 38;
65+ int NULL = 39;
66+ int PACKAGE = 40;
67+ int PRIVATE = 41;
68+ int PROTECTED = 42;
69+ int PUBLIC = 43;
70+ int RETURN = 44;
71+ int SHORT = 45;
72+ int STATIC = 46;
73+ int SUPER = 47;
74+ int SWITCH = 48;
75+ int SYNCHRONIZED = 49;
76+ int THIS = 50;
77+ int THROW = 51;
78+ int THROWS = 52;
79+ int TRANSIENT = 53;
80+ int TRUE = 54;
81+ int TRY = 55;
82+ int VOID = 56;
83+ int VOLATILE = 57;
84+ int WHILE = 58;
85+ int INTEGER_LITERAL = 59;
86+ int DECIMAL_LITERAL = 60;
87+ int HEX_LITERAL = 61;
88+ int OCTAL_LITERAL = 62;
89+ int FLOATING_POINT_LITERAL = 63;
90+ int EXPONENT = 64;
91+ int CHARACTER_LITERAL = 65;
92+ int STRING_LITERAL = 66;
93+ int IDENTIFIER = 67;
94+ int LETTER = 68;
95+ int DIGIT = 69;
96+ int LPAREN = 70;
97+ int RPAREN = 71;
98+ int LBRACE = 72;
99+ int RBRACE = 73;
100+ int LBRACKET = 74;
101+ int RBRACKET = 75;
102+ int SEMICOLON = 76;
103+ int COMMA = 77;
104+ int DOT = 78;
105+ int ASSIGN = 79;
106+ int GT = 80;
107+ int LT = 81;
108+ int BANG = 82;
109+ int TILDE = 83;
110+ int HOOK = 84;
111+ int COLON = 85;
112+ int EQ = 86;
113+ int LE = 87;
114+ int GE = 88;
115+ int NE = 89;
116+ int SC_OR = 90;
117+ int SC_AND = 91;
118+ int INCR = 92;
119+ int DECR = 93;
120+ int PLUS = 94;
121+ int MINUS = 95;
122+ int STAR = 96;
123+ int SLASH = 97;
124+ int BIT_AND = 98;
125+ int BIT_OR = 99;
126+ int XOR = 100;
127+ int REM = 101;
128+ int LSHIFT = 102;
129+ int RSIGNEDSHIFT = 103;
130+ int RUNSIGNEDSHIFT = 104;
131+ int PLUSASSIGN = 105;
132+ int MINUSASSIGN = 106;
133+ int STARASSIGN = 107;
134+ int SLASHASSIGN = 108;
135+ int ANDASSIGN = 109;
136+ int ORASSIGN = 110;
137+ int XORASSIGN = 111;
138+ int REMASSIGN = 112;
139+ int LSHIFTASSIGN = 113;
140+ int RSIGNEDSHIFTASSIGN = 114;
141+ int RUNSIGNEDSHIFTASSIGN = 115;
142+
143+ int DEFAULT = 0;
144+
145+ String[] tokenImage = {
146+ "<EOF>",
147+ "\" \"",
148+ "\"\\t\"",
149+ "\"\\n\"",
150+ "\"\\r\"",
151+ "\"\\f\"",
152+ "<SINGLE_LINE_COMMENT>",
153+ "<FORMAL_COMMENT>",
154+ "<MULTI_LINE_COMMENT>",
155+ "\"abstract\"",
156+ "\"boolean\"",
157+ "\"break\"",
158+ "\"byte\"",
159+ "\"case\"",
160+ "\"catch\"",
161+ "\"char\"",
162+ "\"class\"",
163+ "\"const\"",
164+ "\"continue\"",
165+ "\"default\"",
166+ "\"do\"",
167+ "\"double\"",
168+ "\"else\"",
169+ "\"extends\"",
170+ "\"false\"",
171+ "\"final\"",
172+ "\"finally\"",
173+ "\"float\"",
174+ "\"for\"",
175+ "\"goto\"",
176+ "\"if\"",
177+ "\"implements\"",
178+ "\"import\"",
179+ "\"instanceof\"",
180+ "\"int\"",
181+ "\"interface\"",
182+ "\"long\"",
183+ "\"native\"",
184+ "\"new\"",
185+ "\"null\"",
186+ "\"package\"",
187+ "\"private\"",
188+ "\"protected\"",
189+ "\"public\"",
190+ "\"return\"",
191+ "\"short\"",
192+ "\"static\"",
193+ "\"super\"",
194+ "\"switch\"",
195+ "\"synchronized\"",
196+ "\"this\"",
197+ "\"throw\"",
198+ "\"throws\"",
199+ "\"transient\"",
200+ "\"true\"",
201+ "\"try\"",
202+ "\"void\"",
203+ "\"volatile\"",
204+ "\"while\"",
205+ "<INTEGER_LITERAL>",
206+ "<DECIMAL_LITERAL>",
207+ "<HEX_LITERAL>",
208+ "<OCTAL_LITERAL>",
209+ "<FLOATING_POINT_LITERAL>",
210+ "<EXPONENT>",
211+ "<CHARACTER_LITERAL>",
212+ "<STRING_LITERAL>",
213+ "<IDENTIFIER>",
214+ "<LETTER>",
215+ "<DIGIT>",
216+ "\"(\"",
217+ "\")\"",
218+ "\"{\"",
219+ "\"}\"",
220+ "\"[\"",
221+ "\"]\"",
222+ "\";\"",
223+ "\",\"",
224+ "\".\"",
225+ "\"=\"",
226+ "\">\"",
227+ "\"<\"",
228+ "\"!\"",
229+ "\"~\"",
230+ "\"?\"",
231+ "\":\"",
232+ "\"==\"",
233+ "\"<=\"",
234+ "\">=\"",
235+ "\"!=\"",
236+ "\"||\"",
237+ "\"&&\"",
238+ "\"++\"",
239+ "\"--\"",
240+ "\"+\"",
241+ "\"-\"",
242+ "\"*\"",
243+ "\"/\"",
244+ "\"&\"",
245+ "\"|\"",
246+ "\"^\"",
247+ "\"%\"",
248+ "\"<<\"",
249+ "\">>\"",
250+ "\">>>\"",
251+ "\"+=\"",
252+ "\"-=\"",
253+ "\"*=\"",
254+ "\"/=\"",
255+ "\"&=\"",
256+ "\"|=\"",
257+ "\"^=\"",
258+ "\"%=\"",
259+ "\"<<=\"",
260+ "\">>=\"",
261+ "\">>>=\"",
262+ };
263+
264+}
java/pkg/com/sun/tools/example/debug/expr/ExpressionParserTokenManager.java+1757−0
@@ -0,0 +1,1757 @@
1+/*
2+ * Copyright (c) 1999, 2001, Oracle and/or its affiliates. All rights reserved.
3+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+ *
5+ * This code is free software; you can redistribute it and/or modify it
6+ * under the terms of the GNU General Public License version 2 only, as
7+ * published by the Free Software Foundation. Oracle designates this
8+ * particular file as subject to the "Classpath" exception as provided
9+ * by Oracle in the LICENSE file that accompanied this code.
10+ *
11+ * This code is distributed in the hope that it will be useful, but WITHOUT
12+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+ * version 2 for more details (a copy is included in the LICENSE file that
15+ * accompanied this code).
16+ *
17+ * You should have received a copy of the GNU General Public License version
18+ * 2 along with this work; if not, write to the Free Software Foundation,
19+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+ *
21+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+ * or visit www.oracle.com if you need additional information or have any
23+ * questions.
24+ */
25+
26+/* Generated By:JavaCC: Do not edit this line. ExpressionParserTokenManager.java */
27+package com.sun.tools.example.debug.expr;
28+
29+public class ExpressionParserTokenManager implements ExpressionParserConstants
30+{
31+private final int jjStopStringLiteralDfa_0(int pos, long active0, long active1)
32+{
33+ switch (pos)
34+ {
35+ case 0:
36+ if ((active1 & 0x4000L) != 0L) {
37+ return 4;
38+ }
39+ if ((active0 & 0x7fffffffffffe00L) != 0L)
40+ {
41+ jjmatchedKind = 67;
42+ return 28;
43+ }
44+ if ((active1 & 0x100200000000L) != 0L) {
45+ return 49;
46+ }
47+ return -1;
48+ case 1:
49+ if ((active0 & 0x7ffffffbfcffe00L) != 0L)
50+ {
51+ if (jjmatchedPos != 1)
52+ {
53+ jjmatchedKind = 67;
54+ jjmatchedPos = 1;
55+ }
56+ return 28;
57+ }
58+ if ((active0 & 0x40300000L) != 0L) {
59+ return 28;
60+ }
61+ return -1;
62+ case 2:
63+ if ((active0 & 0x77fffb3afeffe00L) != 0L)
64+ {
65+ if (jjmatchedPos != 2)
66+ {
67+ jjmatchedKind = 67;
68+ jjmatchedPos = 2;
69+ }
70+ return 28;
71+ }
72+ if ((active0 & 0x80004c10000000L) != 0L) {
73+ return 28;
74+ }
75+ return -1;
76+ case 3:
77+ if ((active0 & 0x63bff2b8faf4e00L) != 0L)
78+ {
79+ jjmatchedKind = 67;
80+ jjmatchedPos = 3;
81+ return 28;
82+ }
83+ if ((active0 & 0x14400902040b000L) != 0L) {
84+ return 28;
85+ }
86+ return -1;
87+ case 4:
88+ if ((active0 & 0x2235f2b80ac0600L) != 0L)
89+ {
90+ if (jjmatchedPos != 4)
91+ {
92+ jjmatchedKind = 67;
93+ jjmatchedPos = 4;
94+ }
95+ return 28;
96+ }
97+ if ((active0 & 0x418a0000f034800L) != 0L) {
98+ return 28;
99+ }
100+ return -1;
101+ case 5:
102+ if ((active0 & 0x222070a848c0600L) != 0L)
103+ {
104+ jjmatchedKind = 67;
105+ jjmatchedPos = 5;
106+ return 28;
107+ }
108+ if ((active0 & 0x11582100200000L) != 0L) {
109+ return 28;
110+ }
111+ return -1;
112+ case 6:
113+ if ((active0 & 0x222040a80040200L) != 0L)
114+ {
115+ jjmatchedKind = 67;
116+ jjmatchedPos = 6;
117+ return 28;
118+ }
119+ if ((active0 & 0x30004880400L) != 0L) {
120+ return 28;
121+ }
122+ return -1;
123+ case 7:
124+ if ((active0 & 0x22040a80000000L) != 0L)
125+ {
126+ jjmatchedKind = 67;
127+ jjmatchedPos = 7;
128+ return 28;
129+ }
130+ if ((active0 & 0x200000000040200L) != 0L) {
131+ return 28;
132+ }
133+ return -1;
134+ case 8:
135+ if ((active0 & 0x2000280000000L) != 0L)
136+ {
137+ jjmatchedKind = 67;
138+ jjmatchedPos = 8;
139+ return 28;
140+ }
141+ if ((active0 & 0x20040800000000L) != 0L) {
142+ return 28;
143+ }
144+ return -1;
145+ case 9:
146+ if ((active0 & 0x2000000000000L) != 0L)
147+ {
148+ jjmatchedKind = 67;
149+ jjmatchedPos = 9;
150+ return 28;
151+ }
152+ if ((active0 & 0x280000000L) != 0L) {
153+ return 28;
154+ }
155+ return -1;
156+ case 10:
157+ if ((active0 & 0x2000000000000L) != 0L)
158+ {
159+ jjmatchedKind = 67;
160+ jjmatchedPos = 10;
161+ return 28;
162+ }
163+ return -1;
164+ default :
165+ return -1;
166+ }
167+}
168+private final int jjStartNfa_0(int pos, long active0, long active1)
169+{
170+ return jjMoveNfa_0(jjStopStringLiteralDfa_0(pos, active0, active1), pos + 1);
171+}
172+private final int jjStopAtPos(int pos, int kind)
173+{
174+ jjmatchedKind = kind;
175+ jjmatchedPos = pos;
176+ return pos + 1;
177+}
178+private final int jjStartNfaWithStates_0(int pos, int kind, int state)
179+{
180+ jjmatchedKind = kind;
181+ jjmatchedPos = pos;
182+ try { curChar = input_stream.readChar(); }
183+ catch(java.io.IOException e) { return pos + 1; }
184+ return jjMoveNfa_0(state, pos + 1);
185+}
186+private final int jjMoveStringLiteralDfa0_0()
187+{
188+ switch(curChar)
189+ {
190+ case 33:
191+ jjmatchedKind = 82;
192+ return jjMoveStringLiteralDfa1_0(0x0L, 0x2000000L);
193+ case 37:
194+ jjmatchedKind = 101;
195+ return jjMoveStringLiteralDfa1_0(0x0L, 0x1000000000000L);
196+ case 38:
197+ jjmatchedKind = 98;
198+ return jjMoveStringLiteralDfa1_0(0x0L, 0x200008000000L);
199+ case 40:
200+ return jjStopAtPos(0, 70);
201+ case 41:
202+ return jjStopAtPos(0, 71);
203+ case 42:
204+ jjmatchedKind = 96;
205+ return jjMoveStringLiteralDfa1_0(0x0L, 0x80000000000L);
206+ case 43:
207+ jjmatchedKind = 94;
208+ return jjMoveStringLiteralDfa1_0(0x0L, 0x20010000000L);
209+ case 44:
210+ return jjStopAtPos(0, 77);
211+ case 45:
212+ jjmatchedKind = 95;
213+ return jjMoveStringLiteralDfa1_0(0x0L, 0x40020000000L);
214+ case 46:
215+ return jjStartNfaWithStates_0(0, 78, 4);
216+ case 47:
217+ jjmatchedKind = 97;
218+ return jjMoveStringLiteralDfa1_0(0x0L, 0x100000000000L);
219+ case 58:
220+ return jjStopAtPos(0, 85);
221+ case 59:
222+ return jjStopAtPos(0, 76);
223+ case 60:
224+ jjmatchedKind = 81;
225+ return jjMoveStringLiteralDfa1_0(0x0L, 0x2004000800000L);
226+ case 61:
227+ jjmatchedKind = 79;
228+ return jjMoveStringLiteralDfa1_0(0x0L, 0x400000L);
229+ case 62:
230+ jjmatchedKind = 80;
231+ return jjMoveStringLiteralDfa1_0(0x0L, 0xc018001000000L);
232+ case 63:
233+ return jjStopAtPos(0, 84);
234+ case 91:
235+ return jjStopAtPos(0, 74);
236+ case 93:
237+ return jjStopAtPos(0, 75);
238+ case 94:
239+ jjmatchedKind = 100;
240+ return jjMoveStringLiteralDfa1_0(0x0L, 0x800000000000L);
241+ case 97:
242+ return jjMoveStringLiteralDfa1_0(0x200L, 0x0L);
243+ case 98:
244+ return jjMoveStringLiteralDfa1_0(0x1c00L, 0x0L);
245+ case 99:
246+ return jjMoveStringLiteralDfa1_0(0x7e000L, 0x0L);
247+ case 100:
248+ return jjMoveStringLiteralDfa1_0(0x380000L, 0x0L);
249+ case 101:
250+ return jjMoveStringLiteralDfa1_0(0xc00000L, 0x0L);
251+ case 102:
252+ return jjMoveStringLiteralDfa1_0(0x1f000000L, 0x0L);
253+ case 103:
254+ return jjMoveStringLiteralDfa1_0(0x20000000L, 0x0L);
255+ case 105:
256+ return jjMoveStringLiteralDfa1_0(0xfc0000000L, 0x0L);
257+ case 108:
258+ return jjMoveStringLiteralDfa1_0(0x1000000000L, 0x0L);
259+ case 110:
260+ return jjMoveStringLiteralDfa1_0(0xe000000000L, 0x0L);
261+ case 112:
262+ return jjMoveStringLiteralDfa1_0(0xf0000000000L, 0x0L);
263+ case 114:
264+ return jjMoveStringLiteralDfa1_0(0x100000000000L, 0x0L);
265+ case 115:
266+ return jjMoveStringLiteralDfa1_0(0x3e00000000000L, 0x0L);
267+ case 116:
268+ return jjMoveStringLiteralDfa1_0(0xfc000000000000L, 0x0L);
269+ case 118:
270+ return jjMoveStringLiteralDfa1_0(0x300000000000000L, 0x0L);
271+ case 119:
272+ return jjMoveStringLiteralDfa1_0(0x400000000000000L, 0x0L);
273+ case 123:
274+ return jjStopAtPos(0, 72);
275+ case 124:
276+ jjmatchedKind = 99;
277+ return jjMoveStringLiteralDfa1_0(0x0L, 0x400004000000L);
278+ case 125:
279+ return jjStopAtPos(0, 73);
280+ case 126:
281+ return jjStopAtPos(0, 83);
282+ default :
283+ return jjMoveNfa_0(0, 0);
284+ }
285+}
286+private final int jjMoveStringLiteralDfa1_0(long active0, long active1)
287+{
288+ try { curChar = input_stream.readChar(); }
289+ catch(java.io.IOException e) {
290+ jjStopStringLiteralDfa_0(0, active0, active1);
291+ return 1;
292+ }
293+ switch(curChar)
294+ {
295+ case 38:
296+ if ((active1 & 0x8000000L) != 0L) {
297+ return jjStopAtPos(1, 91);
298+ }
299+ break;
300+ case 43:
301+ if ((active1 & 0x10000000L) != 0L) {
302+ return jjStopAtPos(1, 92);
303+ }
304+ break;
305+ case 45:
306+ if ((active1 & 0x20000000L) != 0L) {
307+ return jjStopAtPos(1, 93);
308+ }
309+ break;
310+ case 60:
311+ if ((active1 & 0x4000000000L) != 0L)
312+ {
313+ jjmatchedKind = 102;
314+ jjmatchedPos = 1;
315+ }
316+ return jjMoveStringLiteralDfa2_0(active0, 0L, active1, 0x2000000000000L);
317+ case 61:
318+ if ((active1 & 0x400000L) != 0L) {
319+ return jjStopAtPos(1, 86);
320+ } else if ((active1 & 0x800000L) != 0L) {
321+ return jjStopAtPos(1, 87);
322+ } else if ((active1 & 0x1000000L) != 0L) {
323+ return jjStopAtPos(1, 88);
324+ } else if ((active1 & 0x2000000L) != 0L) {
325+ return jjStopAtPos(1, 89);
326+ } else if ((active1 & 0x20000000000L) != 0L) {
327+ return jjStopAtPos(1, 105);
328+ } else if ((active1 & 0x40000000000L) != 0L) {
329+ return jjStopAtPos(1, 106);
330+ } else if ((active1 & 0x80000000000L) != 0L) {
331+ return jjStopAtPos(1, 107);
332+ } else if ((active1 & 0x100000000000L) != 0L) {
333+ return jjStopAtPos(1, 108);
334+ } else if ((active1 & 0x200000000000L) != 0L) {
335+ return jjStopAtPos(1, 109);
336+ } else if ((active1 & 0x400000000000L) != 0L) {
337+ return jjStopAtPos(1, 110);
338+ } else if ((active1 & 0x800000000000L) != 0L) {
339+ return jjStopAtPos(1, 111);
340+ } else if ((active1 & 0x1000000000000L) != 0L) {
341+ return jjStopAtPos(1, 112);
342+ }
343+ break;
344+ case 62:
345+ if ((active1 & 0x8000000000L) != 0L)
346+ {
347+ jjmatchedKind = 103;
348+ jjmatchedPos = 1;
349+ }
350+ return jjMoveStringLiteralDfa2_0(active0, 0L, active1, 0xc010000000000L);
351+ case 97:
352+ return jjMoveStringLiteralDfa2_0(active0, 0x12001006000L, active1, 0L);
353+ case 98:
354+ return jjMoveStringLiteralDfa2_0(active0, 0x200L, active1, 0L);
355+ case 101:
356+ return jjMoveStringLiteralDfa2_0(active0, 0x104000080000L, active1, 0L);
357+ case 102:
358+ if ((active0 & 0x40000000L) != 0L) {
359+ return jjStartNfaWithStates_0(1, 30, 28);
360+ }
361+ break;
362+ case 104:
363+ return jjMoveStringLiteralDfa2_0(active0, 0x41c200000008000L, active1, 0L);
364+ case 105:
365+ return jjMoveStringLiteralDfa2_0(active0, 0x6000000L, active1, 0L);
366+ case 108:
367+ return jjMoveStringLiteralDfa2_0(active0, 0x8410000L, active1, 0L);
368+ case 109:
369+ return jjMoveStringLiteralDfa2_0(active0, 0x180000000L, active1, 0L);
370+ case 110:
371+ return jjMoveStringLiteralDfa2_0(active0, 0xe00000000L, active1, 0L);
372+ case 111:
373+ if ((active0 & 0x100000L) != 0L)
374+ {
375+ jjmatchedKind = 20;
376+ jjmatchedPos = 1;
377+ }
378+ return jjMoveStringLiteralDfa2_0(active0, 0x300001030260400L, active1, 0L);
379+ case 114:
380+ return jjMoveStringLiteralDfa2_0(active0, 0xe0060000000800L, active1, 0L);
381+ case 116:
382+ return jjMoveStringLiteralDfa2_0(active0, 0x400000000000L, active1, 0L);
383+ case 117:
384+ return jjMoveStringLiteralDfa2_0(active0, 0x888000000000L, active1, 0L);
385+ case 119:
386+ return jjMoveStringLiteralDfa2_0(active0, 0x1000000000000L, active1, 0L);
387+ case 120:
388+ return jjMoveStringLiteralDfa2_0(active0, 0x800000L, active1, 0L);
389+ case 121:
390+ return jjMoveStringLiteralDfa2_0(active0, 0x2000000001000L, active1, 0L);
391+ case 124:
392+ if ((active1 & 0x4000000L) != 0L) {
393+ return jjStopAtPos(1, 90);
394+ }
395+ break;
396+ default :
397+ break;
398+ }
399+ return jjStartNfa_0(0, active0, active1);
400+}
401+private final int jjMoveStringLiteralDfa2_0(long old0, long active0, long old1, long active1)
402+{
403+ if (((active0 &= old0) | (active1 &= old1)) == 0L) {
404+ return jjStartNfa_0(0, old0, old1);
405+ }
406+ try { curChar = input_stream.readChar(); }
407+ catch(java.io.IOException e) {
408+ jjStopStringLiteralDfa_0(1, active0, active1);
409+ return 2;
410+ }
411+ switch(curChar)
412+ {
413+ case 61:
414+ if ((active1 & 0x2000000000000L) != 0L) {
415+ return jjStopAtPos(2, 113);
416+ } else if ((active1 & 0x4000000000000L) != 0L) {
417+ return jjStopAtPos(2, 114);
418+ }
419+ break;
420+ case 62:
421+ if ((active1 & 0x10000000000L) != 0L)
422+ {
423+ jjmatchedKind = 104;
424+ jjmatchedPos = 2;
425+ }
426+ return jjMoveStringLiteralDfa3_0(active0, 0L, active1, 0x8000000000000L);
427+ case 97:
428+ return jjMoveStringLiteralDfa3_0(active0, 0x20400000018000L, active1, 0L);
429+ case 98:
430+ return jjMoveStringLiteralDfa3_0(active0, 0x80000000000L, active1, 0L);
431+ case 99:
432+ return jjMoveStringLiteralDfa3_0(active0, 0x10000000000L, active1, 0L);
433+ case 101:
434+ return jjMoveStringLiteralDfa3_0(active0, 0x800L, active1, 0L);
435+ case 102:
436+ return jjMoveStringLiteralDfa3_0(active0, 0x80000L, active1, 0L);
437+ case 105:
438+ return jjMoveStringLiteralDfa3_0(active0, 0x505020000000000L, active1, 0L);
439+ case 108:
440+ return jjMoveStringLiteralDfa3_0(active0, 0x200008001000000L, active1, 0L);
441+ case 110:
442+ return jjMoveStringLiteralDfa3_0(active0, 0x2001006060000L, active1, 0L);
443+ case 111:
444+ return jjMoveStringLiteralDfa3_0(active0, 0x240008000400L, active1, 0L);
445+ case 112:
446+ return jjMoveStringLiteralDfa3_0(active0, 0x800180000000L, active1, 0L);
447+ case 114:
448+ if ((active0 & 0x10000000L) != 0L) {
449+ return jjStartNfaWithStates_0(2, 28, 28);
450+ }
451+ return jjMoveStringLiteralDfa3_0(active0, 0x18000000000000L, active1, 0L);
452+ case 115:
453+ return jjMoveStringLiteralDfa3_0(active0, 0x200402200L, active1, 0L);
454+ case 116:
455+ if ((active0 & 0x400000000L) != 0L)
456+ {
457+ jjmatchedKind = 34;
458+ jjmatchedPos = 2;
459+ }
460+ return jjMoveStringLiteralDfa3_0(active0, 0x102820805000L, active1, 0L);
461+ case 117:
462+ return jjMoveStringLiteralDfa3_0(active0, 0x40000000200000L, active1, 0L);
463+ case 119:
464+ if ((active0 & 0x4000000000L) != 0L) {
465+ return jjStartNfaWithStates_0(2, 38, 28);
466+ }
467+ break;
468+ case 121:
469+ if ((active0 & 0x80000000000000L) != 0L) {
470+ return jjStartNfaWithStates_0(2, 55, 28);
471+ }
472+ break;
473+ default :
474+ break;
475+ }
476+ return jjStartNfa_0(1, active0, active1);
477+}
478+private final int jjMoveStringLiteralDfa3_0(long old0, long active0, long old1, long active1)
479+{
480+ if (((active0 &= old0) | (active1 &= old1)) == 0L) {
481+ return jjStartNfa_0(1, old0, old1);
482+ }
483+ try { curChar = input_stream.readChar(); }
484+ catch(java.io.IOException e) {
485+ jjStopStringLiteralDfa_0(2, active0, active1);
486+ return 3;
487+ }
488+ switch(curChar)
489+ {
490+ case 61:
491+ if ((active1 & 0x8000000000000L) != 0L) {
492+ return jjStopAtPos(3, 115);
493+ }
494+ break;
495+ case 97:
496+ return jjMoveStringLiteralDfa4_0(active0, 0x20000000e080800L, active1, 0L);
497+ case 98:
498+ return jjMoveStringLiteralDfa4_0(active0, 0x200000L, active1, 0L);
499+ case 99:
500+ return jjMoveStringLiteralDfa4_0(active0, 0x2000000004000L, active1, 0L);
501+ case 100:
502+ if ((active0 & 0x100000000000000L) != 0L) {
503+ return jjStartNfaWithStates_0(3, 56, 28);
504+ }
505+ break;
506+ case 101:
507+ if ((active0 & 0x1000L) != 0L) {
508+ return jjStartNfaWithStates_0(3, 12, 28);
509+ } else if ((active0 & 0x2000L) != 0L) {
510+ return jjStartNfaWithStates_0(3, 13, 28);
511+ } else if ((active0 & 0x400000L) != 0L) {
512+ return jjStartNfaWithStates_0(3, 22, 28);
513+ } else if ((active0 & 0x40000000000000L) != 0L) {
514+ return jjStartNfaWithStates_0(3, 54, 28);
515+ }
516+ return jjMoveStringLiteralDfa4_0(active0, 0x800800800000L, active1, 0L);
517+ case 103:
518+ if ((active0 & 0x1000000000L) != 0L) {
519+ return jjStartNfaWithStates_0(3, 36, 28);
520+ }
521+ break;
522+ case 105:
523+ return jjMoveStringLiteralDfa4_0(active0, 0x2000000000L, active1, 0L);
524+ case 107:
525+ return jjMoveStringLiteralDfa4_0(active0, 0x10000000000L, active1, 0L);
526+ case 108:
527+ if ((active0 & 0x8000000000L) != 0L) {
528+ return jjStartNfaWithStates_0(3, 39, 28);
529+ }
530+ return jjMoveStringLiteralDfa4_0(active0, 0x400080080000400L, active1, 0L);
531+ case 110:
532+ return jjMoveStringLiteralDfa4_0(active0, 0x20000000000000L, active1, 0L);
533+ case 111:
534+ if ((active0 & 0x20000000L) != 0L) {
535+ return jjStartNfaWithStates_0(3, 29, 28);
536+ }
537+ return jjMoveStringLiteralDfa4_0(active0, 0x18000100000000L, active1, 0L);
538+ case 114:
539+ if ((active0 & 0x8000L) != 0L) {
540+ return jjStartNfaWithStates_0(3, 15, 28);
541+ }
542+ return jjMoveStringLiteralDfa4_0(active0, 0x200000000000L, active1, 0L);
543+ case 115:
544+ if ((active0 & 0x4000000000000L) != 0L) {
545+ return jjStartNfaWithStates_0(3, 50, 28);
546+ }
547+ return jjMoveStringLiteralDfa4_0(active0, 0x1030000L, active1, 0L);
548+ case 116:
549+ return jjMoveStringLiteralDfa4_0(active0, 0x1440200040200L, active1, 0L);
550+ case 117:
551+ return jjMoveStringLiteralDfa4_0(active0, 0x100000000000L, active1, 0L);
552+ case 118:
553+ return jjMoveStringLiteralDfa4_0(active0, 0x20000000000L, active1, 0L);
554+ default :
555+ break;
556+ }
557+ return jjStartNfa_0(2, active0, active1);
558+}
559+private final int jjMoveStringLiteralDfa4_0(long old0, long active0, long old1, long active1)
560+{
561+ if (((active0 &= old0) | (active1 &= old1)) == 0L) {
562+ return jjStartNfa_0(2, old0, old1);
563+ }
564+ try { curChar = input_stream.readChar(); }
565+ catch(java.io.IOException e) {
566+ jjStopStringLiteralDfa_0(3, active0, 0L);
567+ return 4;
568+ }
569+ switch(curChar)
570+ {
571+ case 97:
572+ return jjMoveStringLiteralDfa5_0(active0, 0x30200000000L);
573+ case 99:
574+ return jjMoveStringLiteralDfa5_0(active0, 0x1000000000000L);
575+ case 101:
576+ if ((active0 & 0x1000000L) != 0L) {
577+ return jjStartNfaWithStates_0(4, 24, 28);
578+ } else if ((active0 & 0x400000000000000L) != 0L) {
579+ return jjStartNfaWithStates_0(4, 58, 28);
580+ }
581+ return jjMoveStringLiteralDfa5_0(active0, 0x40080000400L);
582+ case 104:
583+ if ((active0 & 0x4000L) != 0L) {
584+ return jjStartNfaWithStates_0(4, 14, 28);
585+ }
586+ return jjMoveStringLiteralDfa5_0(active0, 0x2000000000000L);
587+ case 105:
588+ return jjMoveStringLiteralDfa5_0(active0, 0x480000040000L);
589+ case 107:
590+ if ((active0 & 0x800L) != 0L) {
591+ return jjStartNfaWithStates_0(4, 11, 28);
592+ }
593+ break;
594+ case 108:
595+ if ((active0 & 0x2000000L) != 0L)
596+ {
597+ jjmatchedKind = 25;
598+ jjmatchedPos = 4;
599+ }
600+ return jjMoveStringLiteralDfa5_0(active0, 0x4200000L);
601+ case 110:
602+ return jjMoveStringLiteralDfa5_0(active0, 0x800000L);
603+ case 114:
604+ if ((active0 & 0x800000000000L) != 0L) {
605+ return jjStartNfaWithStates_0(4, 47, 28);
606+ }
607+ return jjMoveStringLiteralDfa5_0(active0, 0x100900000200L);
608+ case 115:
609+ if ((active0 & 0x10000L) != 0L) {
610+ return jjStartNfaWithStates_0(4, 16, 28);
611+ }
612+ return jjMoveStringLiteralDfa5_0(active0, 0x20000000000000L);
613+ case 116:
614+ if ((active0 & 0x20000L) != 0L) {
615+ return jjStartNfaWithStates_0(4, 17, 28);
616+ } else if ((active0 & 0x8000000L) != 0L) {
617+ return jjStartNfaWithStates_0(4, 27, 28);
618+ } else if ((active0 & 0x200000000000L) != 0L) {
619+ return jjStartNfaWithStates_0(4, 45, 28);
620+ }
621+ return jjMoveStringLiteralDfa5_0(active0, 0x200000000000000L);
622+ case 117:
623+ return jjMoveStringLiteralDfa5_0(active0, 0x80000L);
624+ case 118:
625+ return jjMoveStringLiteralDfa5_0(active0, 0x2000000000L);
626+ case 119:
627+ if ((active0 & 0x8000000000000L) != 0L)
628+ {
629+ jjmatchedKind = 51;
630+ jjmatchedPos = 4;
631+ }
632+ return jjMoveStringLiteralDfa5_0(active0, 0x10000000000000L);
633+ default :
634+ break;
635+ }
636+ return jjStartNfa_0(3, active0, 0L);
637+}
638+private final int jjMoveStringLiteralDfa5_0(long old0, long active0)
639+{
640+ if (((active0 &= old0)) == 0L) {
641+ return jjStartNfa_0(3, old0, 0L);
642+ }
643+ try { curChar = input_stream.readChar(); }
644+ catch(java.io.IOException e) {
645+ jjStopStringLiteralDfa_0(4, active0, 0L);
646+ return 5;
647+ }
648+ switch(curChar)
649+ {
650+ case 97:
651+ return jjMoveStringLiteralDfa6_0(active0, 0x600L);
652+ case 99:
653+ if ((active0 & 0x80000000000L) != 0L) {
654+ return jjStartNfaWithStates_0(5, 43, 28);
655+ } else if ((active0 & 0x400000000000L) != 0L) {
656+ return jjStartNfaWithStates_0(5, 46, 28);
657+ }
658+ return jjMoveStringLiteralDfa6_0(active0, 0x40000000000L);
659+ case 100:
660+ return jjMoveStringLiteralDfa6_0(active0, 0x800000L);
661+ case 101:
662+ if ((active0 & 0x200000L) != 0L) {
663+ return jjStartNfaWithStates_0(5, 21, 28);
664+ } else if ((active0 & 0x2000000000L) != 0L) {
665+ return jjStartNfaWithStates_0(5, 37, 28);
666+ }
667+ break;
668+ case 102:
669+ return jjMoveStringLiteralDfa6_0(active0, 0x800000000L);
670+ case 103:
671+ return jjMoveStringLiteralDfa6_0(active0, 0x10000000000L);
672+ case 104:
673+ if ((active0 & 0x1000000000000L) != 0L) {
674+ return jjStartNfaWithStates_0(5, 48, 28);
675+ }
676+ break;
677+ case 105:
678+ return jjMoveStringLiteralDfa6_0(active0, 0x220000000000000L);
679+ case 108:
680+ return jjMoveStringLiteralDfa6_0(active0, 0x4080000L);
681+ case 109:
682+ return jjMoveStringLiteralDfa6_0(active0, 0x80000000L);
683+ case 110:
684+ if ((active0 & 0x100000000000L) != 0L) {
685+ return jjStartNfaWithStates_0(5, 44, 28);
686+ }
687+ return jjMoveStringLiteralDfa6_0(active0, 0x200040000L);
688+ case 114:
689+ return jjMoveStringLiteralDfa6_0(active0, 0x2000000000000L);
690+ case 115:
691+ if ((active0 & 0x10000000000000L) != 0L) {
692+ return jjStartNfaWithStates_0(5, 52, 28);
693+ }
694+ break;
695+ case 116:
696+ if ((active0 & 0x100000000L) != 0L) {
697+ return jjStartNfaWithStates_0(5, 32, 28);
698+ }
699+ return jjMoveStringLiteralDfa6_0(active0, 0x20000000000L);
700+ default :
701+ break;
702+ }
703+ return jjStartNfa_0(4, active0, 0L);
704+}
705+private final int jjMoveStringLiteralDfa6_0(long old0, long active0)
706+{
707+ if (((active0 &= old0)) == 0L) {
708+ return jjStartNfa_0(4, old0, 0L);
709+ }
710+ try { curChar = input_stream.readChar(); }
711+ catch(java.io.IOException e) {
712+ jjStopStringLiteralDfa_0(5, active0, 0L);
713+ return 6;
714+ }
715+ switch(curChar)
716+ {
717+ case 97:
718+ return jjMoveStringLiteralDfa7_0(active0, 0x800000000L);
719+ case 99:
720+ return jjMoveStringLiteralDfa7_0(active0, 0x200000200L);
721+ case 101:
722+ if ((active0 & 0x10000000000L) != 0L) {
723+ return jjStartNfaWithStates_0(6, 40, 28);
724+ } else if ((active0 & 0x20000000000L) != 0L) {
725+ return jjStartNfaWithStates_0(6, 41, 28);
726+ }
727+ return jjMoveStringLiteralDfa7_0(active0, 0x20000080000000L);
728+ case 108:
729+ return jjMoveStringLiteralDfa7_0(active0, 0x200000000000000L);
730+ case 110:
731+ if ((active0 & 0x400L) != 0L) {
732+ return jjStartNfaWithStates_0(6, 10, 28);
733+ }
734+ break;
735+ case 111:
736+ return jjMoveStringLiteralDfa7_0(active0, 0x2000000000000L);
737+ case 115:
738+ if ((active0 & 0x800000L) != 0L) {
739+ return jjStartNfaWithStates_0(6, 23, 28);
740+ }
741+ break;
742+ case 116:
743+ if ((active0 & 0x80000L) != 0L) {
744+ return jjStartNfaWithStates_0(6, 19, 28);
745+ }
746+ return jjMoveStringLiteralDfa7_0(active0, 0x40000000000L);
747+ case 117:
748+ return jjMoveStringLiteralDfa7_0(active0, 0x40000L);
749+ case 121:
750+ if ((active0 & 0x4000000L) != 0L) {
751+ return jjStartNfaWithStates_0(6, 26, 28);
752+ }
753+ break;
754+ default :
755+ break;
756+ }
757+ return jjStartNfa_0(5, active0, 0L);
758+}
759+private final int jjMoveStringLiteralDfa7_0(long old0, long active0)
760+{
761+ if (((active0 &= old0)) == 0L) {
762+ return jjStartNfa_0(5, old0, 0L);
763+ }
764+ try { curChar = input_stream.readChar(); }
765+ catch(java.io.IOException e) {
766+ jjStopStringLiteralDfa_0(6, active0, 0L);
767+ return 7;
768+ }
769+ switch(curChar)
770+ {
771+ case 99:
772+ return jjMoveStringLiteralDfa8_0(active0, 0x800000000L);
773+ case 101:
774+ if ((active0 & 0x40000L) != 0L) {
775+ return jjStartNfaWithStates_0(7, 18, 28);
776+ } else if ((active0 & 0x200000000000000L) != 0L) {
777+ return jjStartNfaWithStates_0(7, 57, 28);
778+ }
779+ return jjMoveStringLiteralDfa8_0(active0, 0x40200000000L);
780+ case 110:
781+ return jjMoveStringLiteralDfa8_0(active0, 0x22000080000000L);
782+ case 116:
783+ if ((active0 & 0x200L) != 0L) {
784+ return jjStartNfaWithStates_0(7, 9, 28);
785+ }
786+ break;
787+ default :
788+ break;
789+ }
790+ return jjStartNfa_0(6, active0, 0L);
791+}
792+private final int jjMoveStringLiteralDfa8_0(long old0, long active0)
793+{
794+ if (((active0 &= old0)) == 0L) {
795+ return jjStartNfa_0(6, old0, 0L);
796+ }
797+ try { curChar = input_stream.readChar(); }
798+ catch(java.io.IOException e) {
799+ jjStopStringLiteralDfa_0(7, active0, 0L);
800+ return 8;
801+ }
802+ switch(curChar)
803+ {
804+ case 100:
805+ if ((active0 & 0x40000000000L) != 0L) {
806+ return jjStartNfaWithStates_0(8, 42, 28);
807+ }
808+ break;
809+ case 101:
810+ if ((active0 & 0x800000000L) != 0L) {
811+ return jjStartNfaWithStates_0(8, 35, 28);
812+ }
813+ break;
814+ case 105:
815+ return jjMoveStringLiteralDfa9_0(active0, 0x2000000000000L);
816+ case 111:
817+ return jjMoveStringLiteralDfa9_0(active0, 0x200000000L);
818+ case 116:
819+ if ((active0 & 0x20000000000000L) != 0L) {
820+ return jjStartNfaWithStates_0(8, 53, 28);
821+ }
822+ return jjMoveStringLiteralDfa9_0(active0, 0x80000000L);
823+ default :
824+ break;
825+ }
826+ return jjStartNfa_0(7, active0, 0L);
827+}
828+private final int jjMoveStringLiteralDfa9_0(long old0, long active0)
829+{
830+ if (((active0 &= old0)) == 0L) {
831+ return jjStartNfa_0(7, old0, 0L);
832+ }
833+ try { curChar = input_stream.readChar(); }
834+ catch(java.io.IOException e) {
835+ jjStopStringLiteralDfa_0(8, active0, 0L);
836+ return 9;
837+ }
838+ switch(curChar)
839+ {
840+ case 102:
841+ if ((active0 & 0x200000000L) != 0L) {
842+ return jjStartNfaWithStates_0(9, 33, 28);
843+ }
844+ break;
845+ case 115:
846+ if ((active0 & 0x80000000L) != 0L) {
847+ return jjStartNfaWithStates_0(9, 31, 28);
848+ }
849+ break;
850+ case 122:
851+ return jjMoveStringLiteralDfa10_0(active0, 0x2000000000000L);
852+ default :
853+ break;
854+ }
855+ return jjStartNfa_0(8, active0, 0L);
856+}
857+private final int jjMoveStringLiteralDfa10_0(long old0, long active0)
858+{
859+ if (((active0 &= old0)) == 0L) {
860+ return jjStartNfa_0(8, old0, 0L);
861+ }
862+ try { curChar = input_stream.readChar(); }
863+ catch(java.io.IOException e) {
864+ jjStopStringLiteralDfa_0(9, active0, 0L);
865+ return 10;
866+ }
867+ switch(curChar)
868+ {
869+ case 101:
870+ return jjMoveStringLiteralDfa11_0(active0, 0x2000000000000L);
871+ default :
872+ break;
873+ }
874+ return jjStartNfa_0(9, active0, 0L);
875+}
876+private final int jjMoveStringLiteralDfa11_0(long old0, long active0)
877+{
878+ if (((active0 &= old0)) == 0L) {
879+ return jjStartNfa_0(9, old0, 0L);
880+ }
881+ try { curChar = input_stream.readChar(); }
882+ catch(java.io.IOException e) {
883+ jjStopStringLiteralDfa_0(10, active0, 0L);
884+ return 11;
885+ }
886+ switch(curChar)
887+ {
888+ case 100:
889+ if ((active0 & 0x2000000000000L) != 0L) {
890+ return jjStartNfaWithStates_0(11, 49, 28);
891+ }
892+ break;
893+ default :
894+ break;
895+ }
896+ return jjStartNfa_0(10, active0, 0L);
897+}
898+private final void jjCheckNAdd(int state)
899+{
900+ if (jjrounds[state] != jjround)
901+ {
902+ jjstateSet[jjnewStateCnt++] = state;
903+ jjrounds[state] = jjround;
904+ }
905+}
906+private final void jjAddStates(int start, int end)
907+{
908+ do {
909+ jjstateSet[jjnewStateCnt++] = jjnextStates[start];
910+ } while (start++ != end);
911+}
912+private final void jjCheckNAddTwoStates(int state1, int state2)
913+{
914+ jjCheckNAdd(state1);
915+ jjCheckNAdd(state2);
916+}
917+private final void jjCheckNAddStates(int start, int end)
918+{
919+ do {
920+ jjCheckNAdd(jjnextStates[start]);
921+ } while (start++ != end);
922+}
923+private final void jjCheckNAddStates(int start)
924+{
925+ jjCheckNAdd(jjnextStates[start]);
926+ jjCheckNAdd(jjnextStates[start + 1]);
927+}
928+static final long[] jjbitVec0 = {
929+ 0xfffffffffffffffeL, 0xffffffffffffffffL, 0xffffffffffffffffL, 0xffffffffffffffffL
930+};
931+static final long[] jjbitVec2 = {
932+ 0x0L, 0x0L, 0xffffffffffffffffL, 0xffffffffffffffffL
933+};
934+static final long[] jjbitVec3 = {
935+ 0x1ff00000fffffffeL, 0xffffffffffffc000L, 0xffffffffL, 0x600000000000000L
936+};
937+static final long[] jjbitVec4 = {
938+ 0x0L, 0x0L, 0x0L, 0xff7fffffff7fffffL
939+};
940+static final long[] jjbitVec5 = {
941+ 0x0L, 0xffffffffffffffffL, 0xffffffffffffffffL, 0xffffffffffffffffL
942+};
943+static final long[] jjbitVec6 = {
944+ 0xffffffffffffffffL, 0xffffffffffffffffL, 0xffffL, 0x0L
945+};
946+static final long[] jjbitVec7 = {
947+ 0xffffffffffffffffL, 0xffffffffffffffffL, 0x0L, 0x0L
948+};
949+static final long[] jjbitVec8 = {
950+ 0x3fffffffffffL, 0x0L, 0x0L, 0x0L
951+};
952+private final int jjMoveNfa_0(int startState, int curPos)
953+{
954+ int startsAt = 0;
955+ jjnewStateCnt = 67;
956+ int i = 1;
957+ jjstateSet[0] = startState;
958+ int kind = 0x7fffffff;
959+ for (;;)
960+ {
961+ if (++jjround == 0x7fffffff) {
962+ ReInitRounds();
963+ }
964+ if (curChar < 64)
965+ {
966+ long l = 1L << curChar;
967+ //MatchLoop
968+ do
969+ {
970+ switch(jjstateSet[--i])
971+ {
972+ case 0:
973+ if ((0x3ff000000000000L & l) != 0L) {
974+ jjCheckNAddStates(0, 6);
975+ } else if (curChar == 47) {
976+ jjAddStates(7, 9);
977+ } else if (curChar == 36)
978+ {
979+ if (kind > 67) {
980+ kind = 67;
981+ }
982+ jjCheckNAdd(28);
983+ }
984+ else if (curChar == 34) {
985+ jjCheckNAddStates(10, 12);
986+ } else if (curChar == 39) {
987+ jjAddStates(13, 14);
988+ } else if (curChar == 46) {
989+ jjCheckNAdd(4);
990+ }
991+ if ((0x3fe000000000000L & l) != 0L)
992+ {
993+ if (kind > 59) {
994+ kind = 59;
995+ }
996+ jjCheckNAddTwoStates(1, 2);
997+ }
998+ else if (curChar == 48)
999+ {
1000+ if (kind > 59) {
1001+ kind = 59;
1002+ }
1003+ jjCheckNAddStates(15, 17);
1004+ }
1005+ break;
1006+ case 49:
1007+ if (curChar == 42) {
1008+ jjCheckNAddTwoStates(62, 63);
1009+ } else if (curChar == 47) {
1010+ jjCheckNAddStates(18, 20);
1011+ }
1012+ if (curChar == 42) {
1013+ jjstateSet[jjnewStateCnt++] = 54;
1014+ }
1015+ break;
1016+ case 1:
1017+ if ((0x3ff000000000000L & l) == 0L) {
1018+ break;
1019+ }
1020+ if (kind > 59) {
1021+ kind = 59;
1022+ }
1023+ jjCheckNAddTwoStates(1, 2);
1024+ break;
1025+ case 3:
1026+ if (curChar == 46) {
1027+ jjCheckNAdd(4);
1028+ }
1029+ break;
1030+ case 4:
1031+ if ((0x3ff000000000000L & l) == 0L) {
1032+ break;
1033+ }
1034+ if (kind > 63) {
1035+ kind = 63;
1036+ }
1037+ jjCheckNAddStates(21, 23);
1038+ break;
1039+ case 6:
1040+ if ((0x280000000000L & l) != 0L) {
1041+ jjCheckNAdd(7);
1042+ }
1043+ break;
1044+ case 7:
1045+ if ((0x3ff000000000000L & l) == 0L) {
1046+ break;
1047+ }
1048+ if (kind > 63) {
1049+ kind = 63;
1050+ }
1051+ jjCheckNAddTwoStates(7, 8);
1052+ break;
1053+ case 9:
1054+ if (curChar == 39) {
1055+ jjAddStates(13, 14);
1056+ }
1057+ break;
1058+ case 10:
1059+ if ((0xffffff7fffffdbffL & l) != 0L) {
1060+ jjCheckNAdd(11);
1061+ }
1062+ break;
1063+ case 11:
1064+ if (curChar == 39 && kind > 65) {
1065+ kind = 65;
1066+ }
1067+ break;
1068+ case 13:
1069+ if ((0x8400000000L & l) != 0L) {
1070+ jjCheckNAdd(11);
1071+ }
1072+ break;
1073+ case 14:
1074+ if ((0xff000000000000L & l) != 0L) {
1075+ jjCheckNAddTwoStates(15, 11);
1076+ }
1077+ break;
1078+ case 15:
1079+ if ((0xff000000000000L & l) != 0L) {
1080+ jjCheckNAdd(11);
1081+ }
1082+ break;
1083+ case 16:
1084+ if ((0xf000000000000L & l) != 0L) {
1085+ jjstateSet[jjnewStateCnt++] = 17;
1086+ }
1087+ break;
1088+ case 17:
1089+ if ((0xff000000000000L & l) != 0L) {
1090+ jjCheckNAdd(15);
1091+ }
1092+ break;
1093+ case 18:
1094+ if (curChar == 34) {
1095+ jjCheckNAddStates(10, 12);
1096+ }
1097+ break;
1098+ case 19:
1099+ if ((0xfffffffbffffdbffL & l) != 0L) {
1100+ jjCheckNAddStates(10, 12);
1101+ }
1102+ break;
1103+ case 21:
1104+ if ((0x8400000000L & l) != 0L) {
1105+ jjCheckNAddStates(10, 12);
1106+ }
1107+ break;
1108+ case 22:
1109+ if (curChar == 34 && kind > 66) {
1110+ kind = 66;
1111+ }
1112+ break;
1113+ case 23:
1114+ if ((0xff000000000000L & l) != 0L) {
1115+ jjCheckNAddStates(24, 27);
1116+ }
1117+ break;
1118+ case 24:
1119+ if ((0xff000000000000L & l) != 0L) {
1120+ jjCheckNAddStates(10, 12);
1121+ }
1122+ break;
1123+ case 25:
1124+ if ((0xf000000000000L & l) != 0L) {
1125+ jjstateSet[jjnewStateCnt++] = 26;
1126+ }
1127+ break;
1128+ case 26:
1129+ if ((0xff000000000000L & l) != 0L) {
1130+ jjCheckNAdd(24);
1131+ }
1132+ break;
1133+ case 27:
1134+ if (curChar != 36) {
1135+ break;
1136+ }
1137+ if (kind > 67) {
1138+ kind = 67;
1139+ }
1140+ jjCheckNAdd(28);
1141+ break;
1142+ case 28:
1143+ if ((0x3ff001000000000L & l) == 0L) {
1144+ break;
1145+ }
1146+ if (kind > 67) {
1147+ kind = 67;
1148+ }
1149+ jjCheckNAdd(28);
1150+ break;
1151+ case 29:
1152+ if ((0x3ff000000000000L & l) != 0L) {
1153+ jjCheckNAddStates(0, 6);
1154+ }
1155+ break;
1156+ case 30:
1157+ if ((0x3ff000000000000L & l) != 0L) {
1158+ jjCheckNAddTwoStates(30, 31);
1159+ }
1160+ break;
1161+ case 31:
1162+ if (curChar != 46) {
1163+ break;
1164+ }
1165+ if (kind > 63) {
1166+ kind = 63;
1167+ }
1168+ jjCheckNAddStates(28, 30);
1169+ break;
1170+ case 32:
1171+ if ((0x3ff000000000000L & l) == 0L) {
1172+ break;
1173+ }
1174+ if (kind > 63) {
1175+ kind = 63;
1176+ }
1177+ jjCheckNAddStates(28, 30);
1178+ break;
1179+ case 34:
1180+ if ((0x280000000000L & l) != 0L) {
1181+ jjCheckNAdd(35);
1182+ }
1183+ break;
1184+ case 35:
1185+ if ((0x3ff000000000000L & l) == 0L) {
1186+ break;
1187+ }
1188+ if (kind > 63) {
1189+ kind = 63;
1190+ }
1191+ jjCheckNAddTwoStates(35, 8);
1192+ break;
1193+ case 36:
1194+ if ((0x3ff000000000000L & l) != 0L) {
1195+ jjCheckNAddTwoStates(36, 37);
1196+ }
1197+ break;
1198+ case 38:
1199+ if ((0x280000000000L & l) != 0L) {
1200+ jjCheckNAdd(39);
1201+ }
1202+ break;
1203+ case 39:
1204+ if ((0x3ff000000000000L & l) == 0L) {
1205+ break;
1206+ }
1207+ if (kind > 63) {
1208+ kind = 63;
1209+ }
1210+ jjCheckNAddTwoStates(39, 8);
1211+ break;
1212+ case 40:
1213+ if ((0x3ff000000000000L & l) != 0L) {
1214+ jjCheckNAddStates(31, 33);
1215+ }
1216+ break;
1217+ case 42:
1218+ if ((0x280000000000L & l) != 0L) {
1219+ jjCheckNAdd(43);
1220+ }
1221+ break;
1222+ case 43:
1223+ if ((0x3ff000000000000L & l) != 0L) {
1224+ jjCheckNAddTwoStates(43, 8);
1225+ }
1226+ break;
1227+ case 44:
1228+ if (curChar != 48) {
1229+ break;
1230+ }
1231+ if (kind > 59) {
1232+ kind = 59;
1233+ }
1234+ jjCheckNAddStates(15, 17);
1235+ break;
1236+ case 46:
1237+ if ((0x3ff000000000000L & l) == 0L) {
1238+ break;
1239+ }
1240+ if (kind > 59) {
1241+ kind = 59;
1242+ }
1243+ jjCheckNAddTwoStates(46, 2);
1244+ break;
1245+ case 47:
1246+ if ((0xff000000000000L & l) == 0L) {
1247+ break;
1248+ }
1249+ if (kind > 59) {
1250+ kind = 59;
1251+ }
1252+ jjCheckNAddTwoStates(47, 2);
1253+ break;
1254+ case 48:
1255+ if (curChar == 47) {
1256+ jjAddStates(7, 9);
1257+ }
1258+ break;
1259+ case 50:
1260+ if ((0xffffffffffffdbffL & l) != 0L) {
1261+ jjCheckNAddStates(18, 20);
1262+ }
1263+ break;
1264+ case 51:
1265+ if ((0x2400L & l) != 0L && kind > 6) {
1266+ kind = 6;
1267+ }
1268+ break;
1269+ case 52:
1270+ if (curChar == 10 && kind > 6) {
1271+ kind = 6;
1272+ }
1273+ break;
1274+ case 53:
1275+ if (curChar == 13) {
1276+ jjstateSet[jjnewStateCnt++] = 52;
1277+ }
1278+ break;
1279+ case 54:
1280+ if (curChar == 42) {
1281+ jjCheckNAddTwoStates(55, 56);
1282+ }
1283+ break;
1284+ case 55:
1285+ if ((0xfffffbffffffffffL & l) != 0L) {
1286+ jjCheckNAddTwoStates(55, 56);
1287+ }
1288+ break;
1289+ case 56:
1290+ if (curChar == 42) {
1291+ jjCheckNAddStates(34, 36);
1292+ }
1293+ break;
1294+ case 57:
1295+ if ((0xffff7bffffffffffL & l) != 0L) {
1296+ jjCheckNAddTwoStates(58, 56);
1297+ }
1298+ break;
1299+ case 58:
1300+ if ((0xfffffbffffffffffL & l) != 0L) {
1301+ jjCheckNAddTwoStates(58, 56);
1302+ }
1303+ break;
1304+ case 59:
1305+ if (curChar == 47 && kind > 7) {
1306+ kind = 7;
1307+ }
1308+ break;
1309+ case 60:
1310+ if (curChar == 42) {
1311+ jjstateSet[jjnewStateCnt++] = 54;
1312+ }
1313+ break;
1314+ case 61:
1315+ if (curChar == 42) {
1316+ jjCheckNAddTwoStates(62, 63);
1317+ }
1318+ break;
1319+ case 62:
1320+ if ((0xfffffbffffffffffL & l) != 0L) {
1321+ jjCheckNAddTwoStates(62, 63);
1322+ }
1323+ break;
1324+ case 63:
1325+ if (curChar == 42) {
1326+ jjCheckNAddStates(37, 39);
1327+ }
1328+ break;
1329+ case 64:
1330+ if ((0xffff7bffffffffffL & l) != 0L) {
1331+ jjCheckNAddTwoStates(65, 63);
1332+ }
1333+ break;
1334+ case 65:
1335+ if ((0xfffffbffffffffffL & l) != 0L) {
1336+ jjCheckNAddTwoStates(65, 63);
1337+ }
1338+ break;
1339+ case 66:
1340+ if (curChar == 47 && kind > 8) {
1341+ kind = 8;
1342+ }
1343+ break;
1344+ default : break;
1345+ }
1346+ } while(i != startsAt);
1347+ }
1348+ else if (curChar < 128)
1349+ {
1350+ long l = 1L << (curChar & 077);
1351+ //MatchLoop
1352+ do
1353+ {
1354+ switch(jjstateSet[--i])
1355+ {
1356+ case 0:
1357+ case 28:
1358+ if ((0x7fffffe87fffffeL & l) == 0L) {
1359+ break;
1360+ }
1361+ if (kind > 67) {
1362+ kind = 67;
1363+ }
1364+ jjCheckNAdd(28);
1365+ break;
1366+ case 2:
1367+ if ((0x100000001000L & l) != 0L && kind > 59) {
1368+ kind = 59;
1369+ }
1370+ break;
1371+ case 5:
1372+ if ((0x2000000020L & l) != 0L) {
1373+ jjAddStates(40, 41);
1374+ }
1375+ break;
1376+ case 8:
1377+ if ((0x5000000050L & l) != 0L && kind > 63) {
1378+ kind = 63;
1379+ }
1380+ break;
1381+ case 10:
1382+ if ((0xffffffffefffffffL & l) != 0L) {
1383+ jjCheckNAdd(11);
1384+ }
1385+ break;
1386+ case 12:
1387+ if (curChar == 92) {
1388+ jjAddStates(42, 44);
1389+ }
1390+ break;
1391+ case 13:
1392+ if ((0x14404410000000L & l) != 0L) {
1393+ jjCheckNAdd(11);
1394+ }
1395+ break;
1396+ case 19:
1397+ if ((0xffffffffefffffffL & l) != 0L) {
1398+ jjCheckNAddStates(10, 12);
1399+ }
1400+ break;
1401+ case 20:
1402+ if (curChar == 92) {
1403+ jjAddStates(45, 47);
1404+ }
1405+ break;
1406+ case 21:
1407+ if ((0x14404410000000L & l) != 0L) {
1408+ jjCheckNAddStates(10, 12);
1409+ }
1410+ break;
1411+ case 33:
1412+ if ((0x2000000020L & l) != 0L) {
1413+ jjAddStates(48, 49);
1414+ }
1415+ break;
1416+ case 37:
1417+ if ((0x2000000020L & l) != 0L) {
1418+ jjAddStates(50, 51);
1419+ }
1420+ break;
1421+ case 41:
1422+ if ((0x2000000020L & l) != 0L) {
1423+ jjAddStates(52, 53);
1424+ }
1425+ break;
1426+ case 45:
1427+ if ((0x100000001000000L & l) != 0L) {
1428+ jjCheckNAdd(46);
1429+ }
1430+ break;
1431+ case 46:
1432+ if ((0x7e0000007eL & l) == 0L) {
1433+ break;
1434+ }
1435+ if (kind > 59) {
1436+ kind = 59;
1437+ }
1438+ jjCheckNAddTwoStates(46, 2);
1439+ break;
1440+ case 50:
1441+ jjAddStates(18, 20);
1442+ break;
1443+ case 55:
1444+ jjCheckNAddTwoStates(55, 56);
1445+ break;
1446+ case 57:
1447+ case 58:
1448+ jjCheckNAddTwoStates(58, 56);
1449+ break;
1450+ case 62:
1451+ jjCheckNAddTwoStates(62, 63);
1452+ break;
1453+ case 64:
1454+ case 65:
1455+ jjCheckNAddTwoStates(65, 63);
1456+ break;
1457+ default : break;
1458+ }
1459+ } while(i != startsAt);
1460+ }
1461+ else
1462+ {
1463+ int hiByte = (int)(curChar >> 8);
1464+ int i1 = hiByte >> 6;
1465+ long l1 = 1L << (hiByte & 077);
1466+ int i2 = (curChar & 0xff) >> 6;
1467+ long l2 = 1L << (curChar & 077);
1468+ //MatchLoop
1469+ do
1470+ {
1471+ switch(jjstateSet[--i])
1472+ {
1473+ case 0:
1474+ case 28:
1475+ if (!jjCanMove_1(hiByte, i1, i2, l1, l2)) {
1476+ break;
1477+ }
1478+ if (kind > 67) {
1479+ kind = 67;
1480+ }
1481+ jjCheckNAdd(28);
1482+ break;
1483+ case 10:
1484+ if (jjCanMove_0(hiByte, i1, i2, l1, l2)) {
1485+ jjstateSet[jjnewStateCnt++] = 11;
1486+ }
1487+ break;
1488+ case 19:
1489+ if (jjCanMove_0(hiByte, i1, i2, l1, l2)) {
1490+ jjAddStates(10, 12);
1491+ }
1492+ break;
1493+ case 50:
1494+ if (jjCanMove_0(hiByte, i1, i2, l1, l2)) {
1495+ jjAddStates(18, 20);
1496+ }
1497+ break;
1498+ case 55:
1499+ if (jjCanMove_0(hiByte, i1, i2, l1, l2)) {
1500+ jjCheckNAddTwoStates(55, 56);
1501+ }
1502+ break;
1503+ case 57:
1504+ case 58:
1505+ if (jjCanMove_0(hiByte, i1, i2, l1, l2)) {
1506+ jjCheckNAddTwoStates(58, 56);
1507+ }
1508+ break;
1509+ case 62:
1510+ if (jjCanMove_0(hiByte, i1, i2, l1, l2)) {
1511+ jjCheckNAddTwoStates(62, 63);
1512+ }
1513+ break;
1514+ case 64:
1515+ case 65:
1516+ if (jjCanMove_0(hiByte, i1, i2, l1, l2)) {
1517+ jjCheckNAddTwoStates(65, 63);
1518+ }
1519+ break;
1520+ default : break;
1521+ }
1522+ } while(i != startsAt);
1523+ }
1524+ if (kind != 0x7fffffff)
1525+ {
1526+ jjmatchedKind = kind;
1527+ jjmatchedPos = curPos;
1528+ kind = 0x7fffffff;
1529+ }
1530+ ++curPos;
1531+ if ((i = jjnewStateCnt) == (startsAt = 67 - (jjnewStateCnt = startsAt))) {
1532+ return curPos;
1533+ }
1534+ try { curChar = input_stream.readChar(); }
1535+ catch(java.io.IOException e) { return curPos; }
1536+ }
1537+}
1538+static final int[] jjnextStates = {
1539+ 30, 31, 36, 37, 40, 41, 8, 49, 60, 61, 19, 20, 22, 10, 12, 45,
1540+ 47, 2, 50, 51, 53, 4, 5, 8, 19, 20, 24, 22, 32, 33, 8, 40,
1541+ 41, 8, 56, 57, 59, 63, 64, 66, 6, 7, 13, 14, 16, 21, 23, 25,
1542+ 34, 35, 38, 39, 42, 43,
1543+};
1544+private static final boolean jjCanMove_0(int hiByte, int i1, int i2, long l1, long l2)
1545+{
1546+ switch(hiByte)
1547+ {
1548+ case 0:
1549+ return ((jjbitVec2[i2] & l2) != 0L);
1550+ default :
1551+ if ((jjbitVec0[i1] & l1) != 0L) {
1552+ return true;
1553+ }
1554+ return false;
1555+ }
1556+}
1557+private static final boolean jjCanMove_1(int hiByte, int i1, int i2, long l1, long l2)
1558+{
1559+ switch(hiByte)
1560+ {
1561+ case 0:
1562+ return ((jjbitVec4[i2] & l2) != 0L);
1563+ case 48:
1564+ return ((jjbitVec5[i2] & l2) != 0L);
1565+ case 49:
1566+ return ((jjbitVec6[i2] & l2) != 0L);
1567+ case 51:
1568+ return ((jjbitVec7[i2] & l2) != 0L);
1569+ case 61:
1570+ return ((jjbitVec8[i2] & l2) != 0L);
1571+ default :
1572+ if ((jjbitVec3[i1] & l1) != 0L) {
1573+ return true;
1574+ }
1575+ return false;
1576+ }
1577+}
1578+public static final String[] jjstrLiteralImages = {
1579+"", null, null, null, null, null, null, null, null,
1580+"\141\142\163\164\162\141\143\164", "\142\157\157\154\145\141\156", "\142\162\145\141\153", "\142\171\164\145",
1581+"\143\141\163\145", "\143\141\164\143\150", "\143\150\141\162", "\143\154\141\163\163",
1582+"\143\157\156\163\164", "\143\157\156\164\151\156\165\145", "\144\145\146\141\165\154\164",
1583+"\144\157", "\144\157\165\142\154\145", "\145\154\163\145",
1584+"\145\170\164\145\156\144\163", "\146\141\154\163\145", "\146\151\156\141\154",
1585+"\146\151\156\141\154\154\171", "\146\154\157\141\164", "\146\157\162", "\147\157\164\157", "\151\146",
1586+"\151\155\160\154\145\155\145\156\164\163", "\151\155\160\157\162\164", "\151\156\163\164\141\156\143\145\157\146",
1587+"\151\156\164", "\151\156\164\145\162\146\141\143\145", "\154\157\156\147",
1588+"\156\141\164\151\166\145", "\156\145\167", "\156\165\154\154", "\160\141\143\153\141\147\145",
1589+"\160\162\151\166\141\164\145", "\160\162\157\164\145\143\164\145\144", "\160\165\142\154\151\143",
1590+"\162\145\164\165\162\156", "\163\150\157\162\164", "\163\164\141\164\151\143", "\163\165\160\145\162",
1591+"\163\167\151\164\143\150", "\163\171\156\143\150\162\157\156\151\172\145\144", "\164\150\151\163",
1592+"\164\150\162\157\167", "\164\150\162\157\167\163", "\164\162\141\156\163\151\145\156\164",
1593+"\164\162\165\145", "\164\162\171", "\166\157\151\144", "\166\157\154\141\164\151\154\145",
1594+"\167\150\151\154\145", null, null, null, null, null, null, null, null, null, null, null, "\50",
1595+"\51", "\173", "\175", "\133", "\135", "\73", "\54", "\56", "\75", "\76", "\74",
1596+"\41", "\176", "\77", "\72", "\75\75", "\74\75", "\76\75", "\41\75", "\174\174",
1597+"\46\46", "\53\53", "\55\55", "\53", "\55", "\52", "\57", "\46", "\174", "\136", "\45",
1598+"\74\74", "\76\76", "\76\76\76", "\53\75", "\55\75", "\52\75", "\57\75", "\46\75",
1599+"\174\75", "\136\75", "\45\75", "\74\74\75", "\76\76\75", "\76\76\76\75", };
1600+public static final String[] lexStateNames = {
1601+ "DEFAULT",
1602+};
1603+static final long[] jjtoToken = {
1604+ 0x8ffffffffffffe01L, 0xfffffffffffceL,
1605+};
1606+static final long[] jjtoSkip = {
1607+ 0x1feL, 0x0L,
1608+};
1609+static final long[] jjtoSpecial = {
1610+ 0x1c0L, 0x0L,
1611+};
1612+private ASCII_UCodeESC_CharStream input_stream;
1613+private final int[] jjrounds = new int[67];
1614+private final int[] jjstateSet = new int[134];
1615+protected char curChar;
1616+public ExpressionParserTokenManager(ASCII_UCodeESC_CharStream stream)
1617+{
1618+ if (ASCII_UCodeESC_CharStream.staticFlag) {
1619+ throw new Error("ERROR: Cannot use a static CharStream class with a non-static lexical analyzer.");
1620+ }
1621+ input_stream = stream;
1622+}
1623+public ExpressionParserTokenManager(ASCII_UCodeESC_CharStream stream, int lexState)
1624+{
1625+ this(stream);
1626+ SwitchTo(lexState);
1627+}
1628+public void ReInit(ASCII_UCodeESC_CharStream stream)
1629+{
1630+ jjmatchedPos = jjnewStateCnt = 0;
1631+ curLexState = defaultLexState;
1632+ input_stream = stream;
1633+ ReInitRounds();
1634+}
1635+private final void ReInitRounds()
1636+{
1637+ int i;
1638+ jjround = 0x80000001;
1639+ for (i = 67; i-- > 0;) {
1640+ jjrounds[i] = 0x80000000;
1641+}
1642+}
1643+public void ReInit(ASCII_UCodeESC_CharStream stream, int lexState)
1644+{
1645+ ReInit(stream);
1646+ SwitchTo(lexState);
1647+}
1648+public void SwitchTo(int lexState)
1649+{
1650+ if (lexState >= 1 || lexState < 0) {
1651+ throw new TokenMgrError("Error: Ignoring invalid lexical state : " + lexState + ". State unchanged.", TokenMgrError.INVALID_LEXICAL_STATE);
1652+ } else {
1653+ curLexState = lexState;
1654+}
1655+}
1656+
1657+private final Token jjFillToken()
1658+{
1659+ Token t = Token.newToken(jjmatchedKind);
1660+ t.kind = jjmatchedKind;
1661+ String im = jjstrLiteralImages[jjmatchedKind];
1662+ t.image = (im == null) ? input_stream.GetImage() : im;
1663+ t.beginLine = input_stream.getBeginLine();
1664+ t.beginColumn = input_stream.getBeginColumn();
1665+ t.endLine = input_stream.getEndLine();
1666+ t.endColumn = input_stream.getEndColumn();
1667+ return t;
1668+}
1669+
1670+int curLexState = 0;
1671+int defaultLexState = 0;
1672+int jjnewStateCnt;
1673+int jjround;
1674+int jjmatchedPos;
1675+int jjmatchedKind;
1676+
1677+public final Token getNextToken()
1678+{
1679+ Token specialToken = null;
1680+ Token matchedToken;
1681+ int curPos = 0;
1682+
1683+ EOFLoop :
1684+ for (;;)
1685+ {
1686+ try
1687+ {
1688+ curChar = input_stream.BeginToken();
1689+ }
1690+ catch(java.io.IOException e)
1691+ {
1692+ jjmatchedKind = 0;
1693+ matchedToken = jjFillToken();
1694+ matchedToken.specialToken = specialToken;
1695+ return matchedToken;
1696+ }
1697+
1698+ try {
1699+ while (curChar <= 32 && (0x100003600L & (1L << curChar)) != 0L) {
1700+ curChar = input_stream.BeginToken();
1701+ }
1702+ }
1703+ catch (java.io.IOException e1) { continue EOFLoop; }
1704+ jjmatchedKind = 0x7fffffff;
1705+ jjmatchedPos = 0;
1706+ curPos = jjMoveStringLiteralDfa0_0();
1707+ if (jjmatchedKind != 0x7fffffff)
1708+ {
1709+ if (jjmatchedPos + 1 < curPos) {
1710+ input_stream.backup(curPos - jjmatchedPos - 1);
1711+ }
1712+ if ((jjtoToken[jjmatchedKind >> 6] & (1L << (jjmatchedKind & 077))) != 0L)
1713+ {
1714+ matchedToken = jjFillToken();
1715+ matchedToken.specialToken = specialToken;
1716+ return matchedToken;
1717+ }
1718+ else
1719+ {
1720+ if ((jjtoSpecial[jjmatchedKind >> 6] & (1L << (jjmatchedKind & 077))) != 0L)
1721+ {
1722+ matchedToken = jjFillToken();
1723+ if (specialToken == null) {
1724+ specialToken = matchedToken;
1725+ } else
1726+ {
1727+ matchedToken.specialToken = specialToken;
1728+ specialToken = (specialToken.next = matchedToken);
1729+ }
1730+ }
1731+ continue EOFLoop;
1732+ }
1733+ }
1734+ int error_line = input_stream.getEndLine();
1735+ int error_column = input_stream.getEndColumn();
1736+ String error_after = null;
1737+ boolean EOFSeen = false;
1738+ try { input_stream.readChar(); input_stream.backup(1); }
1739+ catch (java.io.IOException e1) {
1740+ EOFSeen = true;
1741+ error_after = curPos <= 1 ? "" : input_stream.GetImage();
1742+ if (curChar == '\n' || curChar == '\r') {
1743+ error_line++;
1744+ error_column = 0;
1745+ } else {
1746+ error_column++;
1747+ }
1748+ }
1749+ if (!EOFSeen) {
1750+ input_stream.backup(1);
1751+ error_after = curPos <= 1 ? "" : input_stream.GetImage();
1752+ }
1753+ throw new TokenMgrError(EOFSeen, curLexState, error_line, error_column, error_after, curChar, TokenMgrError.LEXICAL_ERROR);
1754+ }
1755+}
1756+
1757+}
java/pkg/com/sun/tools/example/debug/expr/LValue.java+1056−0
@@ -0,0 +1,1056 @@
1+/*
2+ * Copyright (c) 1998, 2008, Oracle and/or its affiliates. All rights reserved.
3+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+ *
5+ * This code is free software; you can redistribute it and/or modify it
6+ * under the terms of the GNU General Public License version 2 only, as
7+ * published by the Free Software Foundation. Oracle designates this
8+ * particular file as subject to the "Classpath" exception as provided
9+ * by Oracle in the LICENSE file that accompanied this code.
10+ *
11+ * This code is distributed in the hope that it will be useful, but WITHOUT
12+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+ * version 2 for more details (a copy is included in the LICENSE file that
15+ * accompanied this code).
16+ *
17+ * You should have received a copy of the GNU General Public License version
18+ * 2 along with this work; if not, write to the Free Software Foundation,
19+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+ *
21+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+ * or visit www.oracle.com if you need additional information or have any
23+ * questions.
24+ */
25+
26+package com.sun.tools.example.debug.expr;
27+
28+import com.sun.jdi.*;
29+import java.util.*;
30+
31+abstract class LValue {
32+
33+ // The JDI Value object for this LValue. Once we have this Value,
34+ // we have to remember it since after we return the LValue object
35+ // to the ExpressionParser, it might decide that it needs
36+ // the 'toString' value for the LValue in which case it will
37+ // call getMassagedValue to get this toString value. At that
38+ // point, we don't want to call JDI a 2nd time to get the Value
39+ // for the LValue. This is especially wrong when the LValue
40+ // represents a member function. We would end up calling it
41+ // a 2nd time.
42+ //
43+ // Unfortunately, there are several levels of calls to
44+ // get/set values in this file. To minimize confusion,
45+ // jdiValue is set/tested at the lowest level - right
46+ // next to the actual calls to JDI methods to get/set the
47+ // value in the debuggee.
48+ protected Value jdiValue;
49+
50+ abstract Value getValue() throws InvocationException,
51+ IncompatibleThreadStateException,
52+ InvalidTypeException,
53+ ClassNotLoadedException,
54+ ParseException;
55+
56+ abstract void setValue0(Value value)
57+ throws ParseException, InvalidTypeException,
58+ ClassNotLoadedException;
59+
60+ abstract void invokeWith(List<Value> arguments) throws ParseException;
61+
62+ void setValue(Value value) throws ParseException {
63+ try {
64+ setValue0(value);
65+ } catch (InvalidTypeException exc) {
66+ throw new ParseException(
67+ "Attempt to set value of incorrect type" +
68+ exc);
69+ } catch (ClassNotLoadedException exc) {
70+ throw new ParseException(
71+ "Attempt to set value before " + exc.className() + " was loaded" +
72+ exc);
73+ }
74+ }
75+
76+ void setValue(LValue lval) throws ParseException {
77+ setValue(lval.interiorGetValue());
78+ }
79+
80+ LValue memberLValue(ExpressionParser.GetFrame frameGetter,
81+ String fieldName) throws ParseException {
82+ try {
83+ return memberLValue(fieldName, frameGetter.get().thread());
84+ } catch (IncompatibleThreadStateException exc) {
85+ throw new ParseException("Thread not suspended");
86+ }
87+ }
88+
89+ LValue memberLValue(String fieldName, ThreadReference thread) throws ParseException {
90+
91+ Value val = interiorGetValue();
92+ if ((val instanceof ArrayReference) &&
93+ "length".equals(fieldName)){
94+ return new LValueArrayLength((ArrayReference)val);
95+ }
96+ return new LValueInstanceMember(val, fieldName, thread);
97+ }
98+
99+ // Return the Value for this LValue that would be used to concatenate
100+ // to a String. IE, if it is an Object, call toString in the debuggee.
101+ Value getMassagedValue(ExpressionParser.GetFrame frameGetter) throws ParseException {
102+ Value vv = interiorGetValue();
103+
104+ // If vv is an ObjectReference, then we have to
105+ // do the implicit call to toString().
106+ if (vv instanceof ObjectReference &&
107+ !(vv instanceof StringReference) &&
108+ !(vv instanceof ArrayReference)) {
109+ StackFrame frame;
110+ try {
111+ frame = frameGetter.get();
112+ } catch (IncompatibleThreadStateException exc) {
113+ throw new ParseException("Thread not suspended");
114+ }
115+
116+ ThreadReference thread = frame.thread();
117+ LValue toStringMember = memberLValue("toString", thread);
118+ toStringMember.invokeWith(new ArrayList<Value>());
119+ return toStringMember.interiorGetValue();
120+ }
121+ return vv;
122+ }
123+
124+ Value interiorGetValue() throws ParseException {
125+ Value value;
126+ try {
127+ value = getValue();
128+ } catch (InvocationException e) {
129+ throw new ParseException("Unable to complete expression. Exception " +
130+ e.exception() + " thrown");
131+ } catch (IncompatibleThreadStateException itse) {
132+ throw new ParseException("Unable to complete expression. Thread " +
133+ "not suspended for method invoke");
134+ } catch (InvalidTypeException ite) {
135+ throw new ParseException("Unable to complete expression. Method " +
136+ "argument type mismatch");
137+ } catch (ClassNotLoadedException tnle) {
138+ throw new ParseException("Unable to complete expression. Method " +
139+ "argument type " + tnle.className() +
140+ " not yet loaded");
141+ }
142+ return value;
143+ }
144+
145+ LValue arrayElementLValue(LValue lval) throws ParseException {
146+ Value indexValue = lval.interiorGetValue();
147+ int index;
148+ if ( (indexValue instanceof IntegerValue) ||
149+ (indexValue instanceof ShortValue) ||
150+ (indexValue instanceof ByteValue) ||
151+ (indexValue instanceof CharValue) ) {
152+ index = ((PrimitiveValue)indexValue).intValue();
153+ } else {
154+ throw new ParseException("Array index must be a integer type");
155+ }
156+ return new LValueArrayElement(interiorGetValue(), index);
157+ }
158+
159+ @Override
160+ public String toString() {
161+ try {
162+ return interiorGetValue().toString();
163+ } catch (ParseException e) {
164+ return "<Parse Exception>";
165+ }
166+ }
167+
168+ static final int STATIC = 0;
169+ static final int INSTANCE = 1;
170+
171+ static Field fieldByName(ReferenceType refType, String name, int kind) {
172+ /*
173+ * TO DO: Note that this currently fails to find superclass
174+ * or implemented interface fields. This is due to a temporary
175+ * limititation of RefType.fieldByName. Once that method is
176+ * fixed, superclass fields will be found.
177+ */
178+ Field field = refType.fieldByName(name);
179+ if (field != null) {
180+ boolean isStatic = field.isStatic();
181+ if (((kind == STATIC) && !isStatic) ||
182+ ((kind == INSTANCE) && isStatic)) {
183+ field = null;
184+ }
185+ }
186+/***
187+ System.err.println("fieldByName: " + refType.name() + " " +
188+ name + " " +
189+ kind + " " +
190+ (field != null));
191+***/
192+ return field;
193+ }
194+
195+ static List<Method> methodsByName(ReferenceType refType,
196+ String name, int kind) {
197+ List<Method> list = refType.methodsByName(name);
198+ Iterator<Method> iter = list.iterator();
199+ while (iter.hasNext()) {
200+ Method method = iter.next();
201+ boolean isStatic = method.isStatic();
202+ if (((kind == STATIC) && !isStatic) ||
203+ ((kind == INSTANCE) && isStatic)) {
204+ iter.remove();
205+ }
206+ }
207+ return list;
208+ }
209+
210+ static List<String> primitiveTypeNames = new ArrayList<String>();
211+ static {
212+ primitiveTypeNames.add("boolean");
213+ primitiveTypeNames.add("byte");
214+ primitiveTypeNames.add("char");
215+ primitiveTypeNames.add("short");
216+ primitiveTypeNames.add("int");
217+ primitiveTypeNames.add("long");
218+ primitiveTypeNames.add("float");
219+ primitiveTypeNames.add("double");
220+ }
221+
222+
223+ static final int SAME = 0;
224+ static final int ASSIGNABLE = 1;
225+ static final int DIFFERENT = 2;
226+ /*
227+ * Return SAME, DIFFERENT or ASSIGNABLE.
228+ * SAME means each arg type is the same as type of the corr. arg.
229+ * ASSIGNABLE means that not all the pairs are the same, but
230+ * for those that aren't, at least the argType is assignable
231+ * from the type of the argument value.
232+ * DIFFERENT means that in at least one pair, the
233+ * argType is not assignable from the type of the argument value.
234+ * IE, one is an Apple and the other is an Orange.
235+ */
236+ static int argumentsMatch(List<Type> argTypes, List<Value> arguments) {
237+ if (argTypes.size() != arguments.size()) {
238+ return DIFFERENT;
239+ }
240+
241+ Iterator<Type> typeIter = argTypes.iterator();
242+ Iterator<Value> valIter = arguments.iterator();
243+ int result = SAME;
244+
245+ // If any pair aren't the same, change the
246+ // result to ASSIGNABLE. If any pair aren't
247+ // assignable, return DIFFERENT
248+ while (typeIter.hasNext()) {
249+ Type argType = typeIter.next();
250+ Value value = valIter.next();
251+ if (value == null) {
252+ // Null values can be passed to any non-primitive argument
253+ if (primitiveTypeNames.contains(argType.name())) {
254+ return DIFFERENT;
255+ }
256+ // Else, we will assume that a null value
257+ // exactly matches an object type.
258+ }
259+ if (!value.type().equals(argType)) {
260+ if (isAssignableTo(value.type(), argType)) {
261+ result = ASSIGNABLE;
262+ } else {
263+ return DIFFERENT;
264+ }
265+ }
266+ }
267+ return result;
268+ }
269+
270+
271+ // These is...AssignableTo methods are based on similar code in the JDI
272+ // implementations of ClassType, ArrayType, and InterfaceType
273+
274+ static boolean isComponentAssignable(Type fromType, Type toType) {
275+ if (fromType instanceof PrimitiveType) {
276+ // Assignment of primitive arrays requires identical
277+ // component types.
278+ return fromType.equals(toType);
279+ }
280+ if (toType instanceof PrimitiveType) {
281+ return false;
282+ }
283+ // Assignment of object arrays requires availability
284+ // of widening conversion of component types
285+ return isAssignableTo(fromType, toType);
286+ }
287+
288+ static boolean isArrayAssignableTo(ArrayType fromType, Type toType) {
289+ if (toType instanceof ArrayType) {
290+ try {
291+ Type toComponentType = ((ArrayType)toType).componentType();
292+ return isComponentAssignable(fromType.componentType(), toComponentType);
293+ } catch (ClassNotLoadedException e) {
294+ // One or both component types has not yet been
295+ // loaded => can't assign
296+ return false;
297+ }
298+ }
299+ if (toType instanceof InterfaceType) {
300+ // Only valid InterfaceType assignee is Cloneable
301+ return toType.name().equals("java.lang.Cloneable");
302+ }
303+ // Only valid ClassType assignee is Object
304+ return toType.name().equals("java.lang.Object");
305+ }
306+
307+ static boolean isAssignableTo(Type fromType, Type toType) {
308+ if (fromType.equals(toType)) {
309+ return true;
310+ }
311+
312+ // If one is boolean, so must be the other.
313+ if (fromType instanceof BooleanType) {
314+ if (toType instanceof BooleanType) {
315+ return true;
316+ }
317+ return false;
318+ }
319+ if (toType instanceof BooleanType) {
320+ return false;
321+ }
322+
323+ // Other primitive types are intermixable only with each other.
324+ if (fromType instanceof PrimitiveType) {
325+ if (toType instanceof PrimitiveType) {
326+ return true;
327+ }
328+ return false;
329+ }
330+ if (toType instanceof PrimitiveType) {
331+ return false;
332+ }
333+
334+ // neither one is primitive.
335+ if (fromType instanceof ArrayType) {
336+ return isArrayAssignableTo((ArrayType)fromType, toType);
337+ }
338+ List<InterfaceType> interfaces;
339+ if (fromType instanceof ClassType) {
340+ ClassType superclazz = ((ClassType)fromType).superclass();
341+ if ((superclazz != null) && isAssignableTo(superclazz, toType)) {
342+ return true;
343+ }
344+ interfaces = ((ClassType)fromType).interfaces();
345+ } else {
346+ // fromType must be an InterfaceType
347+ interfaces = ((InterfaceType)fromType).superinterfaces();
348+ }
349+ for (InterfaceType interfaze : interfaces) {
350+ if (isAssignableTo(interfaze, toType)) {
351+ return true;
352+ }
353+ }
354+ return false;
355+ }
356+
357+ static Method resolveOverload(List<Method> overloads,
358+ List<Value> arguments)
359+ throws ParseException {
360+
361+ // If there is only one method to call, we'll just choose
362+ // that without looking at the args. If they aren't right
363+ // the invoke will return a better error message than we
364+ // could generate here.
365+ if (overloads.size() == 1) {
366+ return overloads.get(0);
367+ }
368+
369+ // Resolving overloads is beyond the scope of this exercise.
370+ // So, we will look for a method that matches exactly the
371+ // types of the arguments. If we can't find one, then
372+ // if there is exactly one method whose param types are assignable
373+ // from the arg types, we will use that. Otherwise,
374+ // it is an error. We won't guess which of multiple possible
375+ // methods to call. And, since casts aren't implemented,
376+ // the user can't use them to pick a particular overload to call.
377+ // IE, the user is out of luck in this case.
378+ Method retVal = null;
379+ int assignableCount = 0;
380+ for (Method mm : overloads) {
381+ List<Type> argTypes;
382+ try {
383+ argTypes = mm.argumentTypes();
384+ } catch (ClassNotLoadedException ee) {
385+ // This probably won't happen for the
386+ // method that we are really supposed to
387+ // call.
388+ continue;
389+ }
390+ int compare = argumentsMatch(argTypes, arguments);
391+ if (compare == SAME) {
392+ return mm;
393+ }
394+ if (compare == DIFFERENT) {
395+ continue;
396+ }
397+ // Else, it is assignable. Remember it.
398+ retVal = mm;
399+ assignableCount++;
400+ }
401+
402+ // At this point, we didn't find an exact match,
403+ // but we found one for which the args are assignable.
404+ //
405+ if (retVal != null) {
406+ if (assignableCount == 1) {
407+ return retVal;
408+ }
409+ throw new ParseException("Arguments match multiple methods");
410+ }
411+ throw new ParseException("Arguments match no method");
412+ }
413+
414+ private static class LValueLocal extends LValue {
415+ final StackFrame frame;
416+ final LocalVariable var;
417+
418+ LValueLocal(StackFrame frame, LocalVariable var) {
419+ this.frame = frame;
420+ this.var = var;
421+ }
422+
423+ @Override
424+ Value getValue() {
425+ if (jdiValue == null) {
426+ jdiValue = frame.getValue(var);
427+ }
428+ return jdiValue;
429+ }
430+
431+ @Override
432+ void setValue0(Value val) throws InvalidTypeException,
433+ ClassNotLoadedException {
434+ frame.setValue(var, val);
435+ jdiValue = val;
436+ }
437+
438+ @Override
439+ void invokeWith(List<Value> arguments) throws ParseException {
440+ throw new ParseException(var.name() + " is not a method");
441+ }
442+ }
443+
444+ private static class LValueInstanceMember extends LValue {
445+ final ObjectReference obj;
446+ final ThreadReference thread;
447+ final Field matchingField;
448+ final List<Method> overloads;
449+ Method matchingMethod = null;
450+ List<Value> methodArguments = null;
451+
452+ LValueInstanceMember(Value value,
453+ String memberName,
454+ ThreadReference thread) throws ParseException {
455+ if (!(value instanceof ObjectReference)) {
456+ throw new ParseException(
457+ "Cannot access field of primitive type: " + value);
458+ }
459+ this.obj = (ObjectReference)value;
460+ this.thread = thread;
461+ ReferenceType refType = obj.referenceType();
462+ /*
463+ * Can't tell yet whether this LValue will be accessed as a
464+ * field or method, so we keep track of all the possibilities
465+ */
466+ matchingField = LValue.fieldByName(refType, memberName,
467+ LValue.INSTANCE);
468+ overloads = LValue.methodsByName(refType, memberName,
469+ LValue.INSTANCE);
470+ if ((matchingField == null) && overloads.size() == 0) {
471+ throw new ParseException("No instance field or method with the name "
472+ + memberName + " in " + refType.name());
473+ }
474+ }
475+
476+ @Override
477+ Value getValue() throws InvocationException, InvalidTypeException,
478+ ClassNotLoadedException, IncompatibleThreadStateException,
479+ ParseException {
480+ if (jdiValue != null) {
481+ return jdiValue;
482+ }
483+ if (matchingMethod == null) {
484+ if (matchingField == null) {
485+ throw new ParseException("No such field in " + obj.referenceType().name());
486+ }
487+ return jdiValue = obj.getValue(matchingField);
488+ } else {
489+ return jdiValue = obj.invokeMethod(thread, matchingMethod, methodArguments, 0);
490+ }
491+ }
492+
493+ @Override
494+ void setValue0(Value val) throws ParseException,
495+ InvalidTypeException,
496+ ClassNotLoadedException {
497+ if (matchingMethod != null) {
498+ throw new ParseException("Cannot assign to a method invocation");
499+ }
500+ obj.setValue(matchingField, val);
501+ jdiValue = val;
502+ }
503+
504+ @Override
505+ void invokeWith(List<Value> arguments) throws ParseException {
506+ if (matchingMethod != null) {
507+ throw new ParseException("Invalid consecutive invocations");
508+ }
509+ methodArguments = arguments;
510+ matchingMethod = LValue.resolveOverload(overloads, arguments);
511+ }
512+ }
513+
514+ private static class LValueStaticMember extends LValue {
515+ final ReferenceType refType;
516+ final ThreadReference thread;
517+ final Field matchingField;
518+ final List<Method> overloads;
519+ Method matchingMethod = null;
520+ List<Value> methodArguments = null;
521+
522+ LValueStaticMember(ReferenceType refType,
523+ String memberName,
524+ ThreadReference thread) throws ParseException {
525+ this.refType = refType;
526+ this.thread = thread;
527+ /*
528+ * Can't tell yet whether this LValue will be accessed as a
529+ * field or method, so we keep track of all the possibilities
530+ */
531+ matchingField = LValue.fieldByName(refType, memberName,
532+ LValue.STATIC);
533+ overloads = LValue.methodsByName(refType, memberName,
534+ LValue.STATIC);
535+ if ((matchingField == null) && overloads.size() == 0) {
536+ throw new ParseException("No static field or method with the name "
537+ + memberName + " in " + refType.name());
538+ }
539+ }
540+
541+ @Override
542+ Value getValue() throws InvocationException, InvalidTypeException,
543+ ClassNotLoadedException, IncompatibleThreadStateException,
544+ ParseException {
545+ if (jdiValue != null) {
546+ return jdiValue;
547+ }
548+ if (matchingMethod == null) {
549+ return jdiValue = refType.getValue(matchingField);
550+ } else if (refType instanceof ClassType) {
551+ ClassType clazz = (ClassType)refType;
552+ return jdiValue = clazz.invokeMethod(thread, matchingMethod, methodArguments, 0);
553+ } else {
554+ throw new InvalidTypeException("Cannot invoke static method on " +
555+ refType.name());
556+ }
557+ }
558+
559+ @Override
560+ void setValue0(Value val)
561+ throws ParseException, InvalidTypeException,
562+ ClassNotLoadedException {
563+ if (matchingMethod != null) {
564+ throw new ParseException("Cannot assign to a method invocation");
565+ }
566+ if (!(refType instanceof ClassType)) {
567+ throw new ParseException(
568+ "Cannot set interface field: " + refType);
569+ }
570+ ((ClassType)refType).setValue(matchingField, val);
571+ jdiValue = val;
572+ }
573+
574+ @Override
575+ void invokeWith(List<Value> arguments) throws ParseException {
576+ if (matchingMethod != null) {
577+ throw new ParseException("Invalid consecutive invocations");
578+ }
579+ methodArguments = arguments;
580+ matchingMethod = LValue.resolveOverload(overloads, arguments);
581+ }
582+ }
583+
584+ private static class LValueArrayLength extends LValue {
585+ /*
586+ * Since one can code "int myLen = myArray.length;",
587+ * one might expect that these JDI calls would get a Value
588+ * object for the length of an array in the debugee:
589+ * Field xxx = ArrayType.fieldByName("length")
590+ * Value lenVal= ArrayReference.getValue(xxx)
591+ *
592+ * However, this doesn't work because the array length isn't
593+ * really stored as a field, and can't be accessed as such
594+ * via JDI. Instead, the arrayRef.length() method has to be
595+ * used.
596+ */
597+ final ArrayReference arrayRef;
598+ LValueArrayLength (ArrayReference value) {
599+ this.arrayRef = value;
600+ }
601+
602+ @Override
603+ Value getValue() {
604+ if (jdiValue == null) {
605+ jdiValue = arrayRef.virtualMachine().mirrorOf(arrayRef.length());
606+ }
607+ return jdiValue;
608+ }
609+
610+ @Override
611+ void setValue0(Value value) throws ParseException {
612+ throw new ParseException("Cannot set constant: " + value);
613+ }
614+
615+ @Override
616+ void invokeWith(List<Value> arguments) throws ParseException {
617+ throw new ParseException("Array element is not a method");
618+ }
619+ }
620+
621+ private static class LValueArrayElement extends LValue {
622+ final ArrayReference array;
623+ final int index;
624+
625+ LValueArrayElement(Value value, int index) throws ParseException {
626+ if (!(value instanceof ArrayReference)) {
627+ throw new ParseException(
628+ "Must be array type: " + value);
629+ }
630+ this.array = (ArrayReference)value;
631+ this.index = index;
632+ }
633+
634+ @Override
635+ Value getValue() {
636+ if (jdiValue == null) {
637+ jdiValue = array.getValue(index);
638+ }
639+ return jdiValue;
640+ }
641+
642+ @Override
643+ void setValue0(Value val) throws InvalidTypeException,
644+ ClassNotLoadedException {
645+ array.setValue(index, val);
646+ jdiValue = val;
647+ }
648+
649+ @Override
650+ void invokeWith(List<Value> arguments) throws ParseException {
651+ throw new ParseException("Array element is not a method");
652+ }
653+ }
654+
655+ private static class LValueConstant extends LValue {
656+ final Value value;
657+
658+ LValueConstant(Value value) {
659+ this.value = value;
660+ }
661+
662+ @Override
663+ Value getValue() {
664+ if (jdiValue == null) {
665+ jdiValue = value;
666+ }
667+ return jdiValue;
668+ }
669+
670+ @Override
671+ void setValue0(Value val) throws ParseException {
672+ throw new ParseException("Cannot set constant: " + value);
673+ }
674+
675+ @Override
676+ void invokeWith(List<Value> arguments) throws ParseException {
677+ throw new ParseException("Constant is not a method");
678+ }
679+ }
680+
681+ static LValue make(VirtualMachine vm, boolean val) {
682+ return new LValueConstant(vm.mirrorOf(val));
683+ }
684+
685+ static LValue make(VirtualMachine vm, byte val) {
686+ return new LValueConstant(vm.mirrorOf(val));
687+ }
688+
689+ static LValue make(VirtualMachine vm, char val) {
690+ return new LValueConstant(vm.mirrorOf(val));
691+ }
692+
693+ static LValue make(VirtualMachine vm, short val) {
694+ return new LValueConstant(vm.mirrorOf(val));
695+ }
696+
697+ static LValue make(VirtualMachine vm, int val) {
698+ return new LValueConstant(vm.mirrorOf(val));
699+ }
700+
701+ static LValue make(VirtualMachine vm, long val) {
702+ return new LValueConstant(vm.mirrorOf(val));
703+ }
704+
705+ static LValue make(VirtualMachine vm, float val) {
706+ return new LValueConstant(vm.mirrorOf(val));
707+ }
708+
709+ static LValue make(VirtualMachine vm, double val) {
710+ return new LValueConstant(vm.mirrorOf(val));
711+ }
712+
713+ static LValue make(VirtualMachine vm, String val) throws ParseException {
714+ return new LValueConstant(vm.mirrorOf(val));
715+ }
716+
717+ static LValue makeBoolean(VirtualMachine vm, Token token) {
718+ return make(vm, token.image.charAt(0) == 't');
719+ }
720+
721+ static LValue makeCharacter(VirtualMachine vm, Token token) {
722+ return make(vm, token.image.charAt(1));
723+ }
724+
725+ static LValue makeFloat(VirtualMachine vm, Token token) {
726+ return make(vm, Float.valueOf(token.image).floatValue());
727+ }
728+
729+ static LValue makeDouble(VirtualMachine vm, Token token) {
730+ return make(vm, Double.valueOf(token.image).doubleValue());
731+ }
732+
733+ static LValue makeInteger(VirtualMachine vm, Token token) {
734+ return make(vm, Integer.parseInt(token.image));
735+ }
736+
737+ static LValue makeShort(VirtualMachine vm, Token token) {
738+ return make(vm, Short.parseShort(token.image));
739+ }
740+
741+ static LValue makeLong(VirtualMachine vm, Token token) {
742+ return make(vm, Long.parseLong(token.image));
743+ }
744+
745+ static LValue makeByte(VirtualMachine vm, Token token) {
746+ return make(vm, Byte.parseByte(token.image));
747+ }
748+
749+ static LValue makeString(VirtualMachine vm,
750+ Token token) throws ParseException {
751+ int len = token.image.length();
752+ return make(vm, token.image.substring(1,len-1));
753+ }
754+
755+ static LValue makeNull(VirtualMachine vm,
756+ Token token) throws ParseException {
757+ return new LValueConstant(null);
758+ }
759+
760+ static LValue makeThisObject(VirtualMachine vm,
761+ ExpressionParser.GetFrame frameGetter,
762+ Token token) throws ParseException {
763+ if (frameGetter == null) {
764+ throw new ParseException("No current thread");
765+ } else {
766+ try {
767+ StackFrame frame = frameGetter.get();
768+ ObjectReference thisObject = frame.thisObject();
769+
770+ if (thisObject==null) {
771+ throw new ParseException(
772+ "No 'this'. In native or static method");
773+ } else {
774+ return new LValueConstant(thisObject);
775+ }
776+ } catch (IncompatibleThreadStateException exc) {
777+ throw new ParseException("Thread not suspended");
778+ }
779+ }
780+ }
781+
782+ static LValue makeNewObject(VirtualMachine vm,
783+ ExpressionParser.GetFrame frameGetter,
784+ String className, List<Value> arguments) throws ParseException {
785+ List<ReferenceType> classes = vm.classesByName(className);
786+ if (classes.size() == 0) {
787+ throw new ParseException("No class named: " + className);
788+ }
789+
790+ if (classes.size() > 1) {
791+ throw new ParseException("More than one class named: " +
792+ className);
793+ }
794+ ReferenceType refType = classes.get(0);
795+
796+
797+ if (!(refType instanceof ClassType)) {
798+ throw new ParseException("Cannot create instance of interface " +
799+ className);
800+ }
801+
802+ ClassType classType = (ClassType)refType;
803+ List<Method> methods = new ArrayList<Method>(classType.methods()); // writable
804+ Iterator<Method> iter = methods.iterator();
805+ while (iter.hasNext()) {
806+ Method method = iter.next();
807+ if (!method.isConstructor()) {
808+ iter.remove();
809+ }
810+ }
811+ Method constructor = LValue.resolveOverload(methods, arguments);
812+
813+ ObjectReference newObject;
814+ try {
815+ ThreadReference thread = frameGetter.get().thread();
816+ newObject = classType.newInstance(thread, constructor, arguments, 0);
817+ } catch (InvocationException ie) {
818+ throw new ParseException("Exception in " + className + " constructor: " +
819+ ie.exception().referenceType().name());
820+ } catch (IncompatibleThreadStateException exc) {
821+ throw new ParseException("Thread not suspended");
822+ } catch (Exception e) {
823+ /*
824+ * TO DO: Better error handling
825+ */
826+ throw new ParseException("Unable to create " + className + " instance");
827+ }
828+ return new LValueConstant(newObject);
829+ }
830+
831+ private static LValue nFields(LValue lval,
832+ StringTokenizer izer,
833+ ThreadReference thread)
834+ throws ParseException {
835+ if (!izer.hasMoreTokens()) {
836+ return lval;
837+ } else {
838+ return nFields(lval.memberLValue(izer.nextToken(), thread), izer, thread);
839+ }
840+ }
841+
842+ static LValue makeName(VirtualMachine vm,
843+ ExpressionParser.GetFrame frameGetter,
844+ String name) throws ParseException {
845+ StringTokenizer izer = new StringTokenizer(name, ".");
846+ String first = izer.nextToken();
847+ // check local variables
848+ if (frameGetter != null) {
849+ try {
850+ StackFrame frame = frameGetter.get();
851+ ThreadReference thread = frame.thread();
852+ LocalVariable var;
853+ try {
854+ var = frame.visibleVariableByName(first);
855+ } catch (AbsentInformationException e) {
856+ var = null;
857+ }
858+ if (var != null) {
859+ return nFields(new LValueLocal(frame, var), izer, thread);
860+ } else {
861+ ObjectReference thisObject = frame.thisObject();
862+ if (thisObject != null) {
863+ // check if it is a field of 'this'
864+ LValue thisLValue = new LValueConstant(thisObject);
865+ LValue fv;
866+ try {
867+ fv = thisLValue.memberLValue(first, thread);
868+ } catch (ParseException exc) {
869+ fv = null;
870+ }
871+ if (fv != null) {
872+ return nFields(fv, izer, thread);
873+ }
874+ }
875+ }
876+ // check for class name
877+ while (izer.hasMoreTokens()) {
878+ List<ReferenceType> classes = vm.classesByName(first);
879+ if (classes.size() > 0) {
880+ if (classes.size() > 1) {
881+ throw new ParseException("More than one class named: " +
882+ first);
883+ } else {
884+ ReferenceType refType = classes.get(0);
885+ LValue lval = new LValueStaticMember(refType,
886+ izer.nextToken(), thread);
887+ return nFields(lval, izer, thread);
888+ }
889+ }
890+ first = first + '.' + izer.nextToken();
891+ }
892+ } catch (IncompatibleThreadStateException exc) {
893+ throw new ParseException("Thread not suspended");
894+ }
895+ }
896+ throw new ParseException("Name unknown: " + name);
897+ }
898+
899+ static String stringValue(LValue lval, ExpressionParser.GetFrame frameGetter
900+ ) throws ParseException {
901+ Value val = lval.getMassagedValue(frameGetter);
902+ if (val == null) {
903+ return "null";
904+ }
905+ if (val instanceof StringReference) {
906+ return ((StringReference)val).value();
907+ }
908+ return val.toString(); // is this correct in all cases?
909+ }
910+
911+ static LValue booleanOperation(VirtualMachine vm, Token token,
912+ LValue rightL,
913+ LValue leftL) throws ParseException {
914+ String op = token.image;
915+ Value right = rightL.interiorGetValue();
916+ Value left = leftL.interiorGetValue();
917+ if ( !(right instanceof PrimitiveValue) ||
918+ !(left instanceof PrimitiveValue) ) {
919+ if (op.equals("==")) {
920+ return make(vm, right.equals(left));
921+ } else if (op.equals("!=")) {
922+ return make(vm, !right.equals(left));
923+ } else {
924+ throw new ParseException("Operands or '" + op +
925+ "' must be primitive");
926+ }
927+ }
928+ // can compare any numeric doubles
929+ double rr = ((PrimitiveValue)right).doubleValue();
930+ double ll = ((PrimitiveValue)left).doubleValue();
931+ boolean res;
932+ if (op.equals("<")) {
933+ res = rr < ll;
934+ } else if (op.equals(">")) {
935+ res = rr > ll;
936+ } else if (op.equals("<=")) {
937+ res = rr <= ll;
938+ } else if (op.equals(">=")) {
939+ res = rr >= ll;
940+ } else if (op.equals("==")) {
941+ res = rr == ll;
942+ } else if (op.equals("!=")) {
943+ res = rr != ll;
944+ } else {
945+ throw new ParseException("Unknown operation: " + op);
946+ }
947+ return make(vm, res);
948+ }
949+
950+ static LValue operation(VirtualMachine vm, Token token,
951+ LValue rightL, LValue leftL,
952+ ExpressionParser.GetFrame frameGetter
953+ ) throws ParseException {
954+ String op = token.image;
955+ Value right = rightL.interiorGetValue();
956+ Value left = leftL.interiorGetValue();
957+ if ((right instanceof StringReference) ||
958+ (left instanceof StringReference)) {
959+ if (op.equals("+")) {
960+ // If one is an ObjectRef, we will need to invoke
961+ // toString on it, so we need the thread.
962+ return make(vm, stringValue(rightL, frameGetter) +
963+ stringValue(leftL, frameGetter));
964+ }
965+ }
966+ if ((right instanceof ObjectReference) ||
967+ (left instanceof ObjectReference)) {
968+ if (op.equals("==")) {
969+ return make(vm, right.equals(left));
970+ } else if (op.equals("!=")) {
971+ return make(vm, !right.equals(left));
972+ } else {
973+ throw new ParseException("Invalid operation '" +
974+ op + "' on an Object");
975+ }
976+ }
977+ if ((right instanceof BooleanValue) ||
978+ (left instanceof BooleanValue)) {
979+ throw new ParseException("Invalid operation '" +
980+ op + "' on a Boolean");
981+ }
982+ // from here on, we know it is a integer kind of type
983+ PrimitiveValue primRight = (PrimitiveValue)right;
984+ PrimitiveValue primLeft = (PrimitiveValue)left;
985+ if ((primRight instanceof DoubleValue) ||
986+ (primLeft instanceof DoubleValue)) {
987+ double rr = primRight.doubleValue();
988+ double ll = primLeft.doubleValue();
989+ double res;
990+ if (op.equals("+")) {
991+ res = rr + ll;
992+ } else if (op.equals("-")) {
993+ res = rr - ll;
994+ } else if (op.equals("*")) {
995+ res = rr * ll;
996+ } else if (op.equals("/")) {
997+ res = rr / ll;
998+ } else {
999+ throw new ParseException("Unknown operation: " + op);
1000+ }
1001+ return make(vm, res);
1002+ }
1003+ if ((primRight instanceof FloatValue) ||
1004+ (primLeft instanceof FloatValue)) {
1005+ float rr = primRight.floatValue();
1006+ float ll = primLeft.floatValue();
1007+ float res;
1008+ if (op.equals("+")) {
1009+ res = rr + ll;
1010+ } else if (op.equals("-")) {
1011+ res = rr - ll;
1012+ } else if (op.equals("*")) {
1013+ res = rr * ll;
1014+ } else if (op.equals("/")) {
1015+ res = rr / ll;
1016+ } else {
1017+ throw new ParseException("Unknown operation: " + op);
1018+ }
1019+ return make(vm, res);
1020+ }
1021+ if ((primRight instanceof LongValue) ||
1022+ (primLeft instanceof LongValue)) {
1023+ long rr = primRight.longValue();
1024+ long ll = primLeft.longValue();
1025+ long res;
1026+ if (op.equals("+")) {
1027+ res = rr + ll;
1028+ } else if (op.equals("-")) {
1029+ res = rr - ll;
1030+ } else if (op.equals("*")) {
1031+ res = rr * ll;
1032+ } else if (op.equals("/")) {
1033+ res = rr / ll;
1034+ } else {
1035+ throw new ParseException("Unknown operation: " + op);
1036+ }
1037+ return make(vm, res);
1038+ } else {
1039+ int rr = primRight.intValue();
1040+ int ll = primLeft.intValue();
1041+ int res;
1042+ if (op.equals("+")) {
1043+ res = rr + ll;
1044+ } else if (op.equals("-")) {
1045+ res = rr - ll;
1046+ } else if (op.equals("*")) {
1047+ res = rr * ll;
1048+ } else if (op.equals("/")) {
1049+ res = rr / ll;
1050+ } else {
1051+ throw new ParseException("Unknown operation: " + op);
1052+ }
1053+ return make(vm, res);
1054+ }
1055+ }
1056+}
java/pkg/com/sun/tools/example/debug/expr/ParseException.java+221−0
@@ -0,0 +1,221 @@
1+/*
2+ * Copyright (c) 1999, 2001, Oracle and/or its affiliates. All rights reserved.
3+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+ *
5+ * This code is free software; you can redistribute it and/or modify it
6+ * under the terms of the GNU General Public License version 2 only, as
7+ * published by the Free Software Foundation. Oracle designates this
8+ * particular file as subject to the "Classpath" exception as provided
9+ * by Oracle in the LICENSE file that accompanied this code.
10+ *
11+ * This code is distributed in the hope that it will be useful, but WITHOUT
12+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+ * version 2 for more details (a copy is included in the LICENSE file that
15+ * accompanied this code).
16+ *
17+ * You should have received a copy of the GNU General Public License version
18+ * 2 along with this work; if not, write to the Free Software Foundation,
19+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+ *
21+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+ * or visit www.oracle.com if you need additional information or have any
23+ * questions.
24+ */
25+
26+/* Generated By:JavaCC: Do not edit this line. ParseException.java Version 0.7pre6 */
27+package com.sun.tools.example.debug.expr;
28+
29+/**
30+ * This exception is thrown when parse errors are encountered.
31+ * You can explicitly create objects of this exception type by
32+ * calling the method generateParseException in the generated
33+ * parser.
34+ *
35+ * You can modify this class to customize your error reporting
36+ * mechanisms so long as you retain the public fields.
37+ */
38+public class ParseException extends Exception {
39+
40+ private static final long serialVersionUID = 7978489144303647901L;
41+
42+ /**
43+ * This constructor is used by the method "generateParseException"
44+ * in the generated parser. Calling this constructor generates
45+ * a new object of this type with the fields "currentToken",
46+ * "expectedTokenSequences", and "tokenImage" set. The boolean
47+ * flag "specialConstructor" is also set to true to indicate that
48+ * this constructor was used to create this object.
49+ * This constructor calls its super class with the empty string
50+ * to force the "toString" method of parent class "Throwable" to
51+ * print the error message in the form:
52+ * ParseException: <result of getMessage>
53+ */
54+ public ParseException(Token currentTokenVal,
55+ int[][] expectedTokenSequencesVal,
56+ String[] tokenImageVal
57+ )
58+ {
59+ super("");
60+ specialConstructor = true;
61+ currentToken = currentTokenVal;
62+ expectedTokenSequences = expectedTokenSequencesVal;
63+ tokenImage = tokenImageVal;
64+ }
65+
66+ /**
67+ * The following constructors are for use by you for whatever
68+ * purpose you can think of. Constructing the exception in this
69+ * manner makes the exception behave in the normal way - i.e., as
70+ * documented in the class "Throwable". The fields "errorToken",
71+ * "expectedTokenSequences", and "tokenImage" do not contain
72+ * relevant information. The JavaCC generated code does not use
73+ * these constructors.
74+ */
75+
76+ public ParseException() {
77+ super();
78+ specialConstructor = false;
79+ }
80+
81+ public ParseException(String message) {
82+ super(message);
83+ specialConstructor = false;
84+ }
85+
86+ /**
87+ * This variable determines which constructor was used to create
88+ * this object and thereby affects the semantics of the
89+ * "getMessage" method (see below).
90+ */
91+ protected boolean specialConstructor;
92+
93+ /**
94+ * This is the last token that has been consumed successfully. If
95+ * this object has been created due to a parse error, the token
96+ * followng this token will (therefore) be the first error token.
97+ */
98+ public Token currentToken;
99+
100+ /**
101+ * Each entry in this array is an array of integers. Each array
102+ * of integers represents a sequence of tokens (by their ordinal
103+ * values) that is expected at this point of the parse.
104+ */
105+ public int[][] expectedTokenSequences;
106+
107+ /**
108+ * This is a reference to the "tokenImage" array of the generated
109+ * parser within which the parse error occurred. This array is
110+ * defined in the generated ...Constants interface.
111+ */
112+ public String[] tokenImage;
113+
114+ /**
115+ * This method has the standard behavior when this object has been
116+ * created using the standard constructors. Otherwise, it uses
117+ * "currentToken" and "expectedTokenSequences" to generate a parse
118+ * error message and returns it. If this object has been created
119+ * due to a parse error, and you do not catch it (it gets thrown
120+ * from the parser), then this method is called during the printing
121+ * of the final stack trace, and hence the correct error message
122+ * gets displayed.
123+ */
124+ @Override
125+ public String getMessage() {
126+ if (!specialConstructor) {
127+ return super.getMessage();
128+ }
129+ String expected = "";
130+ int maxSize = 0;
131+ for (int[] expectedTokenSequence : expectedTokenSequences) {
132+ if (maxSize < expectedTokenSequence.length) {
133+ maxSize = expectedTokenSequence.length;
134+ }
135+ for (int j = 0; j < expectedTokenSequence.length; j++) {
136+ expected += tokenImage[expectedTokenSequence[j]] + " ";
137+ }
138+ if (expectedTokenSequence[expectedTokenSequence.length - 1] != 0) {
139+ expected += "...";
140+ }
141+ expected += eol + " ";
142+ }
143+ String retval = "Encountered \"";
144+ Token tok = currentToken.next;
145+ for (int i = 0; i < maxSize; i++) {
146+ if (i != 0) {
147+ retval += " ";
148+ }
149+ if (tok.kind == 0) {
150+ retval += tokenImage[0];
151+ break;
152+ }
153+ retval += add_escapes(tok.image);
154+ tok = tok.next;
155+ }
156+ retval += "\" at line " + currentToken.next.beginLine + ", column " + currentToken.next.beginColumn + "." + eol;
157+ if (expectedTokenSequences.length == 1) {
158+ retval += "Was expecting:" + eol + " ";
159+ } else {
160+ retval += "Was expecting one of:" + eol + " ";
161+ }
162+ retval += expected;
163+ return retval;
164+ }
165+
166+ /**
167+ * The end of line string for this machine.
168+ */
169+ protected String eol = System.getProperty("line.separator", "\n");
170+
171+ /**
172+ * Used to convert raw characters to their escaped version
173+ * when these raw version cannot be used as part of an ASCII
174+ * string literal.
175+ */
176+ protected String add_escapes(String str) {
177+ StringBuffer retval = new StringBuffer();
178+ char ch;
179+ for (int i = 0; i < str.length(); i++) {
180+ switch (str.charAt(i))
181+ {
182+ case 0 :
183+ continue;
184+ case '\b':
185+ retval.append("\\b");
186+ continue;
187+ case '\t':
188+ retval.append("\\t");
189+ continue;
190+ case '\n':
191+ retval.append("\\n");
192+ continue;
193+ case '\f':
194+ retval.append("\\f");
195+ continue;
196+ case '\r':
197+ retval.append("\\r");
198+ continue;
199+ case '\"':
200+ retval.append("\\\"");
201+ continue;
202+ case '\'':
203+ retval.append("\\\'");
204+ continue;
205+ case '\\':
206+ retval.append("\\\\");
207+ continue;
208+ default:
209+ if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) {
210+ String s = "0000" + Integer.toString(ch, 16);
211+ retval.append("\\u" + s.substring(s.length() - 4, s.length()));
212+ } else {
213+ retval.append(ch);
214+ }
215+ continue;
216+ }
217+ }
218+ return retval.toString();
219+ }
220+
221+}
java/pkg/com/sun/tools/example/debug/expr/Token.java+107−0
@@ -0,0 +1,107 @@
1+/*
2+ * Copyright (c) 1999, 2001, Oracle and/or its affiliates. All rights reserved.
3+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+ *
5+ * This code is free software; you can redistribute it and/or modify it
6+ * under the terms of the GNU General Public License version 2 only, as
7+ * published by the Free Software Foundation. Oracle designates this
8+ * particular file as subject to the "Classpath" exception as provided
9+ * by Oracle in the LICENSE file that accompanied this code.
10+ *
11+ * This code is distributed in the hope that it will be useful, but WITHOUT
12+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+ * version 2 for more details (a copy is included in the LICENSE file that
15+ * accompanied this code).
16+ *
17+ * You should have received a copy of the GNU General Public License version
18+ * 2 along with this work; if not, write to the Free Software Foundation,
19+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+ *
21+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+ * or visit www.oracle.com if you need additional information or have any
23+ * questions.
24+ */
25+
26+/* Generated By:JavaCC: Do not edit this line. Token.java Version 0.7pre3 */
27+package com.sun.tools.example.debug.expr;
28+
29+/**
30+ * Describes the input token stream.
31+ */
32+
33+public class Token {
34+
35+ /**
36+ * An integer that describes the kind of this token. This numbering
37+ * system is determined by JavaCCParser, and a table of these numbers is
38+ * stored in the file ...Constants.java.
39+ */
40+ public int kind;
41+
42+ /**
43+ * beginLine and beginColumn describe the position of the first character
44+ * of this token; endLine and endColumn describe the position of the
45+ * last character of this token.
46+ */
47+ public int beginLine, beginColumn, endLine, endColumn;
48+
49+ /**
50+ * The string image of the token.
51+ */
52+ public String image;
53+
54+ /**
55+ * A reference to the next regular (non-special) token from the input
56+ * stream. If this is the last token from the input stream, or if the
57+ * token manager has not read tokens beyond this one, this field is
58+ * set to null. This is true only if this token is also a regular
59+ * token. Otherwise, see below for a description of the contents of
60+ * this field.
61+ */
62+ public Token next;
63+
64+ /**
65+ * This field is used to access special tokens that occur prior to this
66+ * token, but after the immediately preceding regular (non-special) token.
67+ * If there are no such special tokens, this field is set to null.
68+ * When there are more than one such special token, this field refers
69+ * to the last of these special tokens, which in turn refers to the next
70+ * previous special token through its specialToken field, and so on
71+ * until the first special token (whose specialToken field is null).
72+ * The next fields of special tokens refer to other special tokens that
73+ * immediately follow it (without an intervening regular token). If there
74+ * is no such token, this field is null.
75+ */
76+ public Token specialToken;
77+
78+ /**
79+ * Returns the image.
80+ */
81+ @Override
82+ public final String toString()
83+ {
84+ return image;
85+ }
86+
87+ /**
88+ * Returns a new Token object, by default. However, if you want, you
89+ * can create and return subclass objects based on the value of ofKind.
90+ * Simply add the cases to the switch for all those special cases.
91+ * For example, if you have a subclass of Token called IDToken that
92+ * you want to create if ofKind is ID, simlpy add something like :
93+ *
94+ * case MyParserConstants.ID : return new IDToken();
95+ *
96+ * to the following switch statement. Then you can cast matchedToken
97+ * variable to the appropriate type and use it in your lexical actions.
98+ */
99+ public static final Token newToken(int ofKind)
100+ {
101+ switch(ofKind)
102+ {
103+ default : return new Token();
104+ }
105+ }
106+
107+}
java/pkg/com/sun/tools/example/debug/expr/TokenMgrError.java+161−0
@@ -0,0 +1,161 @@
1+/*
2+ * Copyright (c) 1999, 2001, Oracle and/or its affiliates. All rights reserved.
3+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+ *
5+ * This code is free software; you can redistribute it and/or modify it
6+ * under the terms of the GNU General Public License version 2 only, as
7+ * published by the Free Software Foundation. Oracle designates this
8+ * particular file as subject to the "Classpath" exception as provided
9+ * by Oracle in the LICENSE file that accompanied this code.
10+ *
11+ * This code is distributed in the hope that it will be useful, but WITHOUT
12+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+ * version 2 for more details (a copy is included in the LICENSE file that
15+ * accompanied this code).
16+ *
17+ * You should have received a copy of the GNU General Public License version
18+ * 2 along with this work; if not, write to the Free Software Foundation,
19+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+ *
21+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+ * or visit www.oracle.com if you need additional information or have any
23+ * questions.
24+ */
25+
26+/* Generated By:JavaCC: Do not edit this line. TokenMgrError.java Version 0.7pre2 */
27+package com.sun.tools.example.debug.expr;
28+
29+public class TokenMgrError extends Error
30+{
31+ /*
32+ * Ordinals for various reasons why an Error of this type can be thrown.
33+ */
34+
35+ private static final long serialVersionUID = -6236440836177601522L;
36+
37+ /**
38+ * Lexical error occured.
39+ */
40+ static final int LEXICAL_ERROR = 0;
41+
42+ /**
43+ * An attempt wass made to create a second instance of a static token manager.
44+ */
45+ static final int STATIC_LEXER_ERROR = 1;
46+
47+ /**
48+ * Tried to change to an invalid lexical state.
49+ */
50+ static final int INVALID_LEXICAL_STATE = 2;
51+
52+ /**
53+ * Detected (and bailed out of) an infinite loop in the token manager.
54+ */
55+ static final int LOOP_DETECTED = 3;
56+
57+ /**
58+ * Indicates the reason why the exception is thrown. It will have
59+ * one of the above 4 values.
60+ */
61+ int errorCode;
62+
63+ /**
64+ * Replaces unprintable characters by their espaced (or unicode escaped)
65+ * equivalents in the given string
66+ */
67+ protected static final String addEscapes(String str) {
68+ StringBuffer retval = new StringBuffer();
69+ char ch;
70+ for (int i = 0; i < str.length(); i++) {
71+ switch (str.charAt(i))
72+ {
73+ case 0 :
74+ continue;
75+ case '\b':
76+ retval.append("\\b");
77+ continue;
78+ case '\t':
79+ retval.append("\\t");
80+ continue;
81+ case '\n':
82+ retval.append("\\n");
83+ continue;
84+ case '\f':
85+ retval.append("\\f");
86+ continue;
87+ case '\r':
88+ retval.append("\\r");
89+ continue;
90+ case '\"':
91+ retval.append("\\\"");
92+ continue;
93+ case '\'':
94+ retval.append("\\\'");
95+ continue;
96+ case '\\':
97+ retval.append("\\\\");
98+ continue;
99+ default:
100+ if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) {
101+ String s = "0000" + Integer.toString(ch, 16);
102+ retval.append("\\u" + s.substring(s.length() - 4, s.length()));
103+ } else {
104+ retval.append(ch);
105+ }
106+ continue;
107+ }
108+ }
109+ return retval.toString();
110+ }
111+
112+ /**
113+ * Returns a detailed message for the Error when it is thrown by the
114+ * token manager to indicate a lexical error.
115+ * Parameters :
116+ * EOFSeen : indicates if EOF caused the lexicl error
117+ * curLexState : lexical state in which this error occured
118+ * errorLine : line number when the error occured
119+ * errorColumn : column number when the error occured
120+ * errorAfter : prefix that was seen before this error occured
121+ * curchar : the offending character
122+ * Note: You can customize the lexical error message by modifying this method.
123+ */
124+ private static final String LexicalError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar) {
125+ return("Lexical error at line " +
126+ errorLine + ", column " +
127+ errorColumn + ". Encountered: " +
128+ (EOFSeen ? "<EOF> " : ("\"" + addEscapes(String.valueOf(curChar)) + "\"") + " (" + (int)curChar + "), ") +
129+ "after : \"" + addEscapes(errorAfter) + "\"");
130+ }
131+
132+ /**
133+ * You can also modify the body of this method to customize your error messages.
134+ * For example, cases like LOOP_DETECTED and INVALID_LEXICAL_STATE are not
135+ * of end-users concern, so you can return something like :
136+ *
137+ * "Internal Error : Please file a bug report .... "
138+ *
139+ * from this method for such cases in the release version of your parser.
140+ */
141+ @Override
142+ public String getMessage() {
143+ return super.getMessage();
144+ }
145+
146+ /*
147+ * Constructors of various flavors follow.
148+ */
149+
150+ public TokenMgrError() {
151+ }
152+
153+ public TokenMgrError(String message, int reason) {
154+ super(message);
155+ errorCode = reason;
156+ }
157+
158+ public TokenMgrError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar, int reason) {
159+ this(LexicalError(EOFSeen, lexState, errorLine, errorColumn, errorAfter, curChar), reason);
160+ }
161+}
java/pkg/com/sun/tools/example/debug/expr/mkfile+15−0
@@ -0,0 +1,15 @@
1+<../../../../../../../../mkconfig
2+
3+TARG=\
4+ ASCII_UCodeESC_CharStream.dis\
5+ ExpressionParser.dis\
6+ ExpressionParserConstants.dis\
7+ ExpressionParserTokenManager.dis\
8+ LValue.dis\
9+ ParseException.dis\
10+ Token.dis\
11+ TokenMgrError.dis\
12+
13+DISBIN=$ROOT/java/dis/java/java/com/sun/tools/example/debug/expr
14+
15+<$ROOT/mkfiles/mkjava
java/pkg/com/sun/tools/example/debug/gui/ApplicationTool.java+74−0
@@ -0,0 +1,74 @@
1+/*
2+ * Copyright (c) 1998, 1999, Oracle and/or its affiliates. All rights reserved.
3+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+ *
5+ * This code is free software; you can redistribute it and/or modify it
6+ * under the terms of the GNU General Public License version 2 only, as
7+ * published by the Free Software Foundation. Oracle designates this
8+ * particular file as subject to the "Classpath" exception as provided
9+ * by Oracle in the LICENSE file that accompanied this code.
10+ *
11+ * This code is distributed in the hope that it will be useful, but WITHOUT
12+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+ * version 2 for more details (a copy is included in the LICENSE file that
15+ * accompanied this code).
16+ *
17+ * You should have received a copy of the GNU General Public License version
18+ * 2 along with this work; if not, write to the Free Software Foundation,
19+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+ *
21+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+ * or visit www.oracle.com if you need additional information or have any
23+ * questions.
24+ */
25+
26+package com.sun.tools.example.debug.gui;
27+
28+import javax.swing.*;
29+import java.awt.*;
30+import java.awt.event.*;
31+
32+import com.sun.tools.example.debug.bdi.*;
33+
34+public class ApplicationTool extends JPanel {
35+
36+ private static final long serialVersionUID = 310966063293205714L;
37+
38+ private ExecutionManager runtime;
39+
40+ private TypeScript script;
41+
42+ private static final String PROMPT = "Input:";
43+
44+ public ApplicationTool(Environment env) {
45+
46+ super(new BorderLayout());
47+
48+ this.runtime = env.getExecutionManager();
49+
50+ this.script = new TypeScript(PROMPT, false); // No implicit echo.
51+ this.add(script);
52+
53+ script.addActionListener(new ActionListener() {
54+ @Override
55+ public void actionPerformed(ActionEvent e) {
56+ runtime.sendLineToApplication(script.readln());
57+ }
58+ });
59+
60+ runtime.addApplicationEchoListener(new TypeScriptOutputListener(script));
61+ runtime.addApplicationOutputListener(new TypeScriptOutputListener(script));
62+ runtime.addApplicationErrorListener(new TypeScriptOutputListener(script));
63+
64+ //### should clean up on exit!
65+
66+ }
67+
68+ /******
69+ public void setFont(Font f) {
70+ script.setFont(f);
71+ }
72+ ******/
73+
74+}
java/pkg/com/sun/tools/example/debug/gui/ClassManager.java+64−0
@@ -0,0 +1,64 @@
1+/*
2+ * Copyright (c) 1998, 1999, Oracle and/or its affiliates. All rights reserved.
3+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+ *
5+ * This code is free software; you can redistribute it and/or modify it
6+ * under the terms of the GNU General Public License version 2 only, as
7+ * published by the Free Software Foundation. Oracle designates this
8+ * particular file as subject to the "Classpath" exception as provided
9+ * by Oracle in the LICENSE file that accompanied this code.
10+ *
11+ * This code is distributed in the hope that it will be useful, but WITHOUT
12+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+ * version 2 for more details (a copy is included in the LICENSE file that
15+ * accompanied this code).
16+ *
17+ * You should have received a copy of the GNU General Public License version
18+ * 2 along with this work; if not, write to the Free Software Foundation,
19+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+ *
21+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+ * or visit www.oracle.com if you need additional information or have any
23+ * questions.
24+ */
25+
26+package com.sun.tools.example.debug.gui;
27+
28+public class ClassManager {
29+
30+ // This class is provided primarily for symmetry with
31+ // SourceManager. Currently, it does very little.
32+ // If we add facilities in the future that require that
33+ // class files be read outside of the VM, for example, to
34+ // provide a disassembled view of a class for bytecode-level
35+ // debugging, the required class file management will be done
36+ // here.
37+
38+ private SearchPath classPath;
39+
40+ public ClassManager(Environment env) {
41+ this.classPath = new SearchPath("");
42+ }
43+
44+ public ClassManager(SearchPath classPath) {
45+ this.classPath = classPath;
46+ }
47+
48+ /*
49+ * Set path for access to class files.
50+ */
51+
52+ public void setClassPath(SearchPath sp) {
53+ classPath = sp;
54+ }
55+
56+ /*
57+ * Get path for access to class files.
58+ */
59+
60+ public SearchPath getClassPath() {
61+ return classPath;
62+ }
63+
64+}
java/pkg/com/sun/tools/example/debug/gui/ClassTreeTool.java+278−0
@@ -0,0 +1,278 @@
1+/*
2+ * Copyright (c) 1998, 2008, Oracle and/or its affiliates. All rights reserved.
3+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+ *
5+ * This code is free software; you can redistribute it and/or modify it
6+ * under the terms of the GNU General Public License version 2 only, as
7+ * published by the Free Software Foundation. Oracle designates this
8+ * particular file as subject to the "Classpath" exception as provided
9+ * by Oracle in the LICENSE file that accompanied this code.
10+ *
11+ * This code is distributed in the hope that it will be useful, but WITHOUT
12+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+ * version 2 for more details (a copy is included in the LICENSE file that
15+ * accompanied this code).
16+ *
17+ * You should have received a copy of the GNU General Public License version
18+ * 2 along with this work; if not, write to the Free Software Foundation,
19+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+ *
21+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+ * or visit www.oracle.com if you need additional information or have any
23+ * questions.
24+ */
25+
26+package com.sun.tools.example.debug.gui;
27+
28+import java.util.*;
29+
30+import javax.swing.*;
31+import javax.swing.tree.*;
32+import java.awt.*;
33+import java.awt.event.*;
34+
35+import com.sun.jdi.*;
36+import com.sun.tools.example.debug.event.*;
37+import com.sun.tools.example.debug.bdi.*;
38+
39+public class ClassTreeTool extends JPanel {
40+
41+ private static final long serialVersionUID = 526178912591739259L;
42+
43+ private Environment env;
44+
45+ private ExecutionManager runtime;
46+ private SourceManager sourceManager;
47+ private ClassManager classManager;
48+
49+ private JTree tree;
50+ private DefaultTreeModel treeModel;
51+ private ClassTreeNode root;
52+// private SearchPath sourcePath;
53+
54+ private CommandInterpreter interpreter;
55+
56+ private static String HEADING = "CLASSES";
57+
58+ public ClassTreeTool(Environment env) {
59+
60+ super(new BorderLayout());
61+
62+ this.env = env;
63+ this.runtime = env.getExecutionManager();
64+ this.sourceManager = env.getSourceManager();
65+
66+ this.interpreter = new CommandInterpreter(env);
67+
68+ root = createClassTree(HEADING);
69+ treeModel = new DefaultTreeModel(root);
70+
71+ // Create a tree that allows one selection at a time.
72+
73+ tree = new JTree(treeModel);
74+ tree.setSelectionModel(new SingleLeafTreeSelectionModel());
75+
76+ /******
77+ // Listen for when the selection changes.
78+ tree.addTreeSelectionListener(new TreeSelectionListener() {
79+ public void valueChanged(TreeSelectionEvent e) {
80+ ClassTreeNode node = (ClassTreeNode)
81+ (e.getPath().getLastPathComponent());
82+ if (node != null) {
83+ interpreter.executeCommand("view " + node.getReferenceTypeName());
84+ }
85+ }
86+ });
87+ ******/
88+
89+ MouseListener ml = new MouseAdapter() {
90+ @Override
91+ public void mouseClicked(MouseEvent e) {
92+ int selRow = tree.getRowForLocation(e.getX(), e.getY());
93+ TreePath selPath = tree.getPathForLocation(e.getX(), e.getY());
94+ if(selRow != -1) {
95+ if(e.getClickCount() == 1) {
96+ ClassTreeNode node =
97+ (ClassTreeNode)selPath.getLastPathComponent();
98+ // If user clicks on leaf, select it, and issue 'view' command.
99+ if (node.isLeaf()) {
100+ tree.setSelectionPath(selPath);
101+ interpreter.executeCommand("view " + node.getReferenceTypeName());
102+ }
103+ }
104+ }
105+ }
106+ };
107+ tree.addMouseListener(ml);
108+
109+ JScrollPane treeView = new JScrollPane(tree);
110+ add(treeView);
111+
112+ // Create listener.
113+ ClassTreeToolListener listener = new ClassTreeToolListener();
114+ runtime.addJDIListener(listener);
115+ runtime.addSessionListener(listener);
116+
117+ //### remove listeners on exit!
118+ }
119+
120+ private class ClassTreeToolListener extends JDIAdapter
121+ implements JDIListener, SessionListener {
122+
123+ // SessionListener
124+
125+ @Override
126+ public void sessionStart(EventObject e) {
127+ // Get system classes and any others loaded before attaching.
128+ try {
129+ for (ReferenceType type : runtime.allClasses()) {
130+ root.addClass(type);
131+ }
132+ } catch (VMDisconnectedException ee) {
133+ // VM terminated unexpectedly.
134+ } catch (NoSessionException ee) {
135+ // Ignore. Should not happen.
136+ }
137+ }
138+
139+ @Override
140+ public void sessionInterrupt(EventObject e) {}
141+ @Override
142+ public void sessionContinue(EventObject e) {}
143+
144+ // JDIListener
145+
146+ @Override
147+ public void classPrepare(ClassPrepareEventSet e) {
148+ root.addClass(e.getReferenceType());
149+ }
150+
151+ @Override
152+ public void classUnload(ClassUnloadEventSet e) {
153+ root.removeClass(e.getClassName());
154+ }
155+
156+ @Override
157+ public void vmDisconnect(VMDisconnectEventSet e) {
158+ // Clear contents of this view.
159+ root = createClassTree(HEADING);
160+ treeModel = new DefaultTreeModel(root);
161+ tree.setModel(treeModel);
162+ }
163+ }
164+
165+ ClassTreeNode createClassTree(String label) {
166+ return new ClassTreeNode(label, null);
167+ }
168+
169+ class ClassTreeNode extends DefaultMutableTreeNode {
170+
171+ private String name;
172+ private ReferenceType refTy; // null for package
173+
174+ ClassTreeNode(String name, ReferenceType refTy) {
175+ this.name = name;
176+ this.refTy = refTy;
177+ }
178+
179+ @Override
180+ public String toString() {
181+ return name;
182+ }
183+
184+ public ReferenceType getReferenceType() {
185+ return refTy;
186+ }
187+
188+ public String getReferenceTypeName() {
189+ return refTy.name();
190+ }
191+
192+ private boolean isPackage() {
193+ return (refTy == null);
194+ }
195+
196+ @Override
197+ public boolean isLeaf() {
198+ return !isPackage();
199+ }
200+
201+ public void addClass(ReferenceType refTy) {
202+ addClass(refTy.name(), refTy);
203+ }
204+
205+ private void addClass(String className, ReferenceType refTy) {
206+ if (className.equals("")) {
207+ return;
208+ }
209+ int pos = className.indexOf('.');
210+ if (pos < 0) {
211+ insertNode(className, refTy);
212+ } else {
213+ String head = className.substring(0, pos);
214+ String tail = className.substring(pos + 1);
215+ ClassTreeNode child = insertNode(head, null);
216+ child.addClass(tail, refTy);
217+ }
218+ }
219+
220+ private ClassTreeNode insertNode(String name, ReferenceType refTy) {
221+ for (int i = 0; i < getChildCount(); i++) {
222+ ClassTreeNode child = (ClassTreeNode)getChildAt(i);
223+ int cmp = name.compareTo(child.toString());
224+ if (cmp == 0) {
225+ // like-named node already exists
226+ return child;
227+ } else if (cmp < 0) {
228+ // insert new node before the child
229+ ClassTreeNode newChild = new ClassTreeNode(name, refTy);
230+ treeModel.insertNodeInto(newChild, this, i);
231+ return newChild;
232+ }
233+ }
234+ // insert new node after last child
235+ ClassTreeNode newChild = new ClassTreeNode(name, refTy);
236+ treeModel.insertNodeInto(newChild, this, getChildCount());
237+ return newChild;
238+ }
239+
240+ public void removeClass(String className) {
241+ if (className.equals("")) {
242+ return;
243+ }
244+ int pos = className.indexOf('.');
245+ if (pos < 0) {
246+ ClassTreeNode child = findNode(className);
247+ if (!isPackage()) {
248+ treeModel.removeNodeFromParent(child);
249+ }
250+ } else {
251+ String head = className.substring(0, pos);
252+ String tail = className.substring(pos + 1);
253+ ClassTreeNode child = findNode(head);
254+ child.removeClass(tail);
255+ if (isPackage() && child.getChildCount() < 1) {
256+ // Prune non-leaf nodes with no children.
257+ treeModel.removeNodeFromParent(child);
258+ }
259+ }
260+ }
261+
262+ private ClassTreeNode findNode(String name) {
263+ for (int i = 0; i < getChildCount(); i++) {
264+ ClassTreeNode child = (ClassTreeNode)getChildAt(i);
265+ int cmp = name.compareTo(child.toString());
266+ if (cmp == 0) {
267+ return child;
268+ } else if (cmp > 0) {
269+ // not found, since children are sorted
270+ return null;
271+ }
272+ }
273+ return null;
274+ }
275+
276+ }
277+
278+}
java/pkg/com/sun/tools/example/debug/gui/CommandInterpreter.java+1459−0
@@ -0,0 +1,1459 @@
1+/*
2+ * Copyright (c) 1998, 2008, Oracle and/or its affiliates. All rights reserved.
3+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+ *
5+ * This code is free software; you can redistribute it and/or modify it
6+ * under the terms of the GNU General Public License version 2 only, as
7+ * published by the Free Software Foundation. Oracle designates this
8+ * particular file as subject to the "Classpath" exception as provided
9+ * by Oracle in the LICENSE file that accompanied this code.
10+ *
11+ * This code is distributed in the hope that it will be useful, but WITHOUT
12+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+ * version 2 for more details (a copy is included in the LICENSE file that
15+ * accompanied this code).
16+ *
17+ * You should have received a copy of the GNU General Public License version
18+ * 2 along with this work; if not, write to the Free Software Foundation,
19+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+ *
21+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+ * or visit www.oracle.com if you need additional information or have any
23+ * questions.
24+ */
25+
26+package com.sun.tools.example.debug.gui;
27+
28+import java.io.*;
29+import java.util.*;
30+
31+import com.sun.jdi.*;
32+import com.sun.tools.example.debug.bdi.*;
33+
34+public class CommandInterpreter {
35+
36+ boolean echo;
37+
38+ Environment env;
39+
40+ private ContextManager context;
41+ private ExecutionManager runtime;
42+ private ClassManager classManager;
43+ private SourceManager sourceManager;
44+
45+ private OutputSink out; //### Hack! Should be local in each method used.
46+ private String lastCommand = "help";
47+
48+ public CommandInterpreter(Environment env) {
49+ this(env, true);
50+ }
51+
52+ public CommandInterpreter(Environment env, boolean echo) {
53+ this.env = env;
54+ this.echo = echo;
55+ this.runtime = env.getExecutionManager();
56+ this.context = env.getContextManager();
57+ this.classManager = env.getClassManager();
58+ this.sourceManager = env.getSourceManager();
59+ }
60+
61+ private ThreadReference[] threads = null;
62+
63+ /*
64+ * The numbering of threads is relative to the current set of threads,
65+ * and may be affected by the creation and termination of new threads.
66+ * Commands issued using such thread ids will only give reliable behavior
67+ * relative to what was shown earlier in 'list' commands if the VM is interrupted.
68+ * We need a better scheme.
69+ */
70+
71+ private ThreadReference[] threads() throws NoSessionException {
72+ if (threads == null) {
73+ ThreadIterator ti = new ThreadIterator(getDefaultThreadGroup());
74+ List<ThreadReference> tlist = new ArrayList<ThreadReference>();
75+ while (ti.hasNext()) {
76+ tlist.add(ti.nextThread());
77+ }
78+ threads = tlist.toArray(new ThreadReference[tlist.size()]);
79+ }
80+ return threads;
81+ }
82+
83+ private ThreadReference findThread(String idToken) throws NoSessionException {
84+ String id;
85+ ThreadReference thread = null;
86+ if (idToken.startsWith("t@")) {
87+ id = idToken.substring(2);
88+ } else {
89+ id = idToken;
90+ }
91+ try {
92+ ThreadReference[] threads = threads();
93+ long threadID = Long.parseLong(id, 16);
94+ for (ThreadReference thread2 : threads) {
95+ if (thread2.uniqueID() == threadID) {
96+ thread = thread2;
97+ break;
98+ }
99+ }
100+ if (thread == null) {
101+ //env.failure("No thread for id \"" + idToken + "\"");
102+ env.failure("\"" + idToken + "\" is not a valid thread id.");
103+ }
104+ } catch (NumberFormatException e) {
105+ env.error("Thread id \"" + idToken + "\" is ill-formed.");
106+ thread = null;
107+ }
108+ return thread;
109+ }
110+
111+ private ThreadIterator allThreads() throws NoSessionException {
112+ threads = null;
113+ //### Why not use runtime.allThreads().iterator() ?
114+ return new ThreadIterator(runtime.topLevelThreadGroups());
115+ }
116+
117+ private ThreadIterator currentThreadGroupThreads() throws NoSessionException {
118+ threads = null;
119+ return new ThreadIterator(getDefaultThreadGroup());
120+ }
121+
122+ private ThreadGroupIterator allThreadGroups() throws NoSessionException {
123+ threads = null;
124+ return new ThreadGroupIterator(runtime.topLevelThreadGroups());
125+ }
126+
127+ private ThreadGroupReference defaultThreadGroup;
128+
129+ private ThreadGroupReference getDefaultThreadGroup() throws NoSessionException {
130+ if (defaultThreadGroup == null) {
131+ defaultThreadGroup = runtime.systemThreadGroup();
132+ }
133+ return defaultThreadGroup;
134+ }
135+
136+ private void setDefaultThreadGroup(ThreadGroupReference tg) {
137+ defaultThreadGroup = tg;
138+ }
139+
140+ /*
141+ * Command handlers.
142+ */
143+
144+ // Command: classes
145+
146+ private void commandClasses() throws NoSessionException {
147+ OutputSink out = env.getOutputSink();
148+ //out.println("** classes list **");
149+ for (ReferenceType refType : runtime.allClasses()) {
150+ out.println(refType.name());
151+ }
152+ out.show();
153+ }
154+
155+
156+ // Command: methods
157+
158+ private void commandMethods(StringTokenizer t) throws NoSessionException {
159+ if (!t.hasMoreTokens()) {
160+ env.error("No class specified.");
161+ return;
162+ }
163+ String idClass = t.nextToken();
164+ ReferenceType cls = findClass(idClass);
165+ if (cls != null) {
166+ List<Method> methods = cls.allMethods();
167+ OutputSink out = env.getOutputSink();
168+ for (int i = 0; i < methods.size(); i++) {
169+ Method method = methods.get(i);
170+ out.print(method.declaringType().name() + " " +
171+ method.name() + "(");
172+ Iterator<String> it = method.argumentTypeNames().iterator();
173+ if (it.hasNext()) {
174+ while (true) {
175+ out.print(it.next());
176+ if (!it.hasNext()) {
177+ break;
178+ }
179+ out.print(", ");
180+ }
181+ }
182+ out.println(")");
183+ }
184+ out.show();
185+ } else {
186+ //### Should validate class name syntax.
187+ env.failure("\"" + idClass + "\" is not a valid id or class name.");
188+ }
189+ }
190+
191+ private ReferenceType findClass(String pattern) throws NoSessionException {
192+ List<ReferenceType> results = runtime.findClassesMatchingPattern(pattern);
193+ if (results.size() > 0) {
194+ //### Should handle multiple results sensibly.
195+ return results.get(0);
196+ }
197+ return null;
198+ }
199+
200+ // Command: threads
201+
202+ private void commandThreads(StringTokenizer t) throws NoSessionException {
203+ if (!t.hasMoreTokens()) {
204+ OutputSink out = env.getOutputSink();
205+ printThreadGroup(out, getDefaultThreadGroup(), 0);
206+ out.show();
207+ return;
208+ }
209+ String name = t.nextToken();
210+ ThreadGroupReference tg = findThreadGroup(name);
211+ if (tg == null) {
212+ env.failure(name + " is not a valid threadgroup name.");
213+ } else {
214+ OutputSink out = env.getOutputSink();
215+ printThreadGroup(out, tg, 0);
216+ out.show();
217+ }
218+ }
219+
220+ private ThreadGroupReference findThreadGroup(String name) throws NoSessionException {
221+ //### Issue: Uniqueness of thread group names is not enforced.
222+ ThreadGroupIterator tgi = allThreadGroups();
223+ while (tgi.hasNext()) {
224+ ThreadGroupReference tg = tgi.nextThreadGroup();
225+ if (tg.name().equals(name)) {
226+ return tg;
227+ }
228+ }
229+ return null;
230+ }
231+
232+ private int printThreadGroup(OutputSink out, ThreadGroupReference tg, int iThread) {
233+ out.println("Group " + tg.name() + ":");
234+ List<ThreadReference> tlist = tg.threads();
235+ int maxId = 0;
236+ int maxName = 0;
237+ for (int i = 0 ; i < tlist.size() ; i++) {
238+ ThreadReference thr = tlist.get(i);
239+ int len = Utils.description(thr).length();
240+ if (len > maxId) {
241+ maxId = len;
242+ }
243+ String name = thr.name();
244+ int iDot = name.lastIndexOf('.');
245+ if (iDot >= 0 && name.length() > iDot) {
246+ name = name.substring(iDot + 1);
247+ }
248+ if (name.length() > maxName) {
249+ maxName = name.length();
250+ }
251+ }
252+ String maxNumString = String.valueOf(iThread + tlist.size());
253+ int maxNumDigits = maxNumString.length();
254+ for (int i = 0 ; i < tlist.size() ; i++) {
255+ ThreadReference thr = tlist.get(i);
256+ char buf[] = new char[80];
257+ for (int j = 0; j < 79; j++) {
258+ buf[j] = ' ';
259+ }
260+ buf[79] = '\0';
261+ StringBuffer sbOut = new StringBuffer();
262+ sbOut.append(buf);
263+
264+ // Right-justify the thread number at start of output string
265+ String numString = String.valueOf(iThread + i + 1);
266+ sbOut.insert(maxNumDigits - numString.length(),
267+ numString);
268+ sbOut.insert(maxNumDigits, ".");
269+
270+ int iBuf = maxNumDigits + 2;
271+ sbOut.insert(iBuf, Utils.description(thr));
272+ iBuf += maxId + 1;
273+ String name = thr.name();
274+ int iDot = name.lastIndexOf('.');
275+ if (iDot >= 0 && name.length() > iDot) {
276+ name = name.substring(iDot + 1);
277+ }
278+ sbOut.insert(iBuf, name);
279+ iBuf += maxName + 1;
280+ sbOut.insert(iBuf, Utils.getStatus(thr));
281+ sbOut.setLength(79);
282+ out.println(sbOut.toString());
283+ }
284+ for (ThreadGroupReference tg0 : tg.threadGroups()) {
285+ if (!tg.equals(tg0)) { // TODO ref mgt
286+ iThread += printThreadGroup(out, tg0, iThread + tlist.size());
287+ }
288+ }
289+ return tlist.size();
290+ }
291+
292+ // Command: threadgroups
293+
294+ private void commandThreadGroups() throws NoSessionException {
295+ ThreadGroupIterator it = allThreadGroups();
296+ int cnt = 0;
297+ OutputSink out = env.getOutputSink();
298+ while (it.hasNext()) {
299+ ThreadGroupReference tg = it.nextThreadGroup();
300+ ++cnt;
301+ out.println("" + cnt + ". " + Utils.description(tg) + " " + tg.name());
302+ }
303+ out.show();
304+ }
305+
306+ // Command: thread
307+
308+ private void commandThread(StringTokenizer t) throws NoSessionException {
309+ if (!t.hasMoreTokens()) {
310+ env.error("Thread number not specified.");
311+ return;
312+ }
313+ ThreadReference thread = findThread(t.nextToken());
314+ if (thread != null) {
315+ //### Should notify user.
316+ context.setCurrentThread(thread);
317+ }
318+ }
319+
320+ // Command: threadgroup
321+
322+ private void commandThreadGroup(StringTokenizer t) throws NoSessionException {
323+ if (!t.hasMoreTokens()) {
324+ env.error("Threadgroup name not specified.");
325+ return;
326+ }
327+ String name = t.nextToken();
328+ ThreadGroupReference tg = findThreadGroup(name);
329+ if (tg == null) {
330+ env.failure(name + " is not a valid threadgroup name.");
331+ } else {
332+ //### Should notify user.
333+ setDefaultThreadGroup(tg);
334+ }
335+ }
336+
337+ // Command: run
338+
339+ private void commandRun(StringTokenizer t) throws NoSessionException {
340+ if (doLoad(false, t)) {
341+ env.notice("Running ...");
342+ }
343+ }
344+
345+ // Command: load
346+
347+ private void commandLoad(StringTokenizer t) throws NoSessionException {
348+ if (doLoad(true, t)) {}
349+ }
350+
351+ private boolean doLoad(boolean suspended,
352+ StringTokenizer t) throws NoSessionException {
353+
354+ String clname;
355+
356+ if (!t.hasMoreTokens()) {
357+ clname = context.getMainClassName();
358+ if (!clname.equals("")) {
359+ // Run from prevously-set class name.
360+ try {
361+ String vmArgs = context.getVmArguments();
362+ runtime.run(suspended,
363+ vmArgs,
364+ clname,
365+ context.getProgramArguments());
366+ return true;
367+ } catch (VMLaunchFailureException e) {
368+ env.failure("Attempt to launch main class \"" + clname + "\" failed.");
369+ }
370+ } else {
371+ env.failure("No main class specifed and no current default defined.");
372+ }
373+ } else {
374+ clname = t.nextToken();
375+ StringBuffer sbuf = new StringBuffer();
376+ // Allow VM arguments to be specified here?
377+ while (t.hasMoreTokens()) {
378+ String tok = t.nextToken();
379+ sbuf.append(tok);
380+ if (t.hasMoreTokens()) {
381+ sbuf.append(' ');
382+ }
383+ }
384+ String args = sbuf.toString();
385+ try {
386+ String vmArgs = context.getVmArguments();
387+ runtime.run(suspended, vmArgs, clname, args);
388+ context.setMainClassName(clname);
389+ //context.setVmArguments(vmArgs);
390+ context.setProgramArguments(args);
391+ return true;
392+ } catch (VMLaunchFailureException e) {
393+ env.failure("Attempt to launch main class \"" + clname + "\" failed.");
394+ }
395+ }
396+ return false;
397+ }
398+
399+ // Command: connect
400+
401+ private void commandConnect(StringTokenizer t) {
402+ try {
403+ LaunchTool.queryAndLaunchVM(runtime);
404+ } catch (VMLaunchFailureException e) {
405+ env.failure("Attempt to connect failed.");
406+ }
407+ }
408+
409+ // Command: attach
410+
411+ private void commandAttach(StringTokenizer t) {
412+ String portName;
413+ if (!t.hasMoreTokens()) {
414+ portName = context.getRemotePort();
415+ if (!portName.equals("")) {
416+ try {
417+ runtime.attach(portName);
418+ } catch (VMLaunchFailureException e) {
419+ env.failure("Attempt to attach to port \"" + portName + "\" failed.");
420+ }
421+ } else {
422+ env.failure("No port specifed and no current default defined.");
423+ }
424+ } else {
425+ portName = t.nextToken();
426+ try {
427+ runtime.attach(portName);
428+ } catch (VMLaunchFailureException e) {
429+ env.failure("Attempt to attach to port \"" + portName + "\" failed.");
430+ }
431+ context.setRemotePort(portName);
432+ }
433+ }
434+
435+ // Command: detach
436+
437+ private void commandDetach(StringTokenizer t) throws NoSessionException {
438+ runtime.detach();
439+ }
440+
441+ // Command: interrupt
442+
443+ private void commandInterrupt(StringTokenizer t) throws NoSessionException {
444+ runtime.interrupt();
445+ }
446+
447+ // Command: suspend
448+
449+ private void commandSuspend(StringTokenizer t) throws NoSessionException {
450+ if (!t.hasMoreTokens()) {
451+ // Suspend all threads in the current thread group.
452+ //### Issue: help message says default is all threads.
453+ //### Behavior here agrees with 'jdb', however.
454+ ThreadIterator ti = currentThreadGroupThreads();
455+ while (ti.hasNext()) {
456+ // TODO - don't suspend debugger threads
457+ ti.nextThread().suspend();
458+ }
459+ env.notice("All (non-system) threads suspended.");
460+ } else {
461+ while (t.hasMoreTokens()) {
462+ ThreadReference thread = findThread(t.nextToken());
463+ if (thread != null) {
464+ //thread.suspend();
465+ runtime.suspendThread(thread);
466+ }
467+ }
468+ }
469+ }
470+
471+ // Command: resume
472+
473+ private void commandResume(StringTokenizer t) throws NoSessionException {
474+ if (!t.hasMoreTokens()) {
475+ // Suspend all threads in the current thread group.
476+ //### Issue: help message says default is all threads.
477+ //### Behavior here agrees with 'jdb', however.
478+ ThreadIterator ti = currentThreadGroupThreads();
479+ while (ti.hasNext()) {
480+ // TODO - don't suspend debugger threads
481+ ti.nextThread().resume();
482+ }
483+ env.notice("All threads resumed.");
484+ } else {
485+ while (t.hasMoreTokens()) {
486+ ThreadReference thread = findThread(t.nextToken());
487+ if (thread != null) {
488+ //thread.resume();
489+ runtime.resumeThread(thread);
490+ }
491+ }
492+ }
493+ }
494+
495+ // Command: cont
496+
497+ private void commandCont() throws NoSessionException {
498+ try {
499+ runtime.go();
500+ } catch (VMNotInterruptedException e) {
501+ //### failure?
502+ env.notice("Target VM is already running.");
503+ }
504+ }
505+
506+ // Command: step
507+
508+ private void commandStep(StringTokenizer t) throws NoSessionException{
509+ ThreadReference current = context.getCurrentThread();
510+ if (current == null) {
511+ env.failure("No current thread.");
512+ return;
513+ }
514+ try {
515+ if (t.hasMoreTokens() &&
516+ t.nextToken().toLowerCase().equals("up")) {
517+ runtime.stepOut(current);
518+ } else {
519+ runtime.stepIntoLine(current);
520+ }
521+ } catch (AbsentInformationException e) {
522+ env.failure("No linenumber information available -- " +
523+ "Try \"stepi\" to step by instructions.");
524+ }
525+ }
526+
527+ // Command: stepi
528+
529+ private void commandStepi() throws NoSessionException {
530+ ThreadReference current = context.getCurrentThread();
531+ if (current == null) {
532+ env.failure("No current thread.");
533+ return;
534+ }
535+ runtime.stepIntoInstruction(current);
536+ }
537+
538+ // Command: next
539+
540+ private void commandNext() throws NoSessionException {
541+ ThreadReference current = context.getCurrentThread();
542+ if (current == null) {
543+ env.failure("No current thread.");
544+ return;
545+ }
546+ try {
547+ runtime.stepOverLine(current);
548+ } catch (AbsentInformationException e) {
549+ env.failure("No linenumber information available -- " +
550+ "Try \"nexti\" to step by instructions.");
551+ }
552+ }
553+
554+ // Command: nexti (NEW)
555+
556+ private void commandNexti() throws NoSessionException {
557+ ThreadReference current = context.getCurrentThread();
558+ if (current == null) {
559+ env.failure("No current thread.");
560+ return;
561+ }
562+ runtime.stepOverInstruction(current);
563+ }
564+
565+ // Command: kill
566+
567+ private void commandKill(StringTokenizer t) throws NoSessionException {
568+ //### Should change the way in which thread ids and threadgroup names
569+ //### are distinguished.
570+ if (!t.hasMoreTokens()) {
571+ env.error("Usage: kill <threadgroup name> or <thread id>");
572+ return;
573+ }
574+ while (t.hasMoreTokens()) {
575+ String idToken = t.nextToken();
576+ ThreadReference thread = findThread(idToken);
577+ if (thread != null) {
578+ runtime.stopThread(thread);
579+ env.notice("Thread " + thread.name() + " killed.");
580+ return;
581+ } else {
582+ /* Check for threadgroup name, NOT skipping "system". */
583+ //### Should skip "system"? Classic 'jdb' does this.
584+ //### Should deal with possible non-uniqueness of threadgroup names.
585+ ThreadGroupIterator itg = allThreadGroups();
586+ while (itg.hasNext()) {
587+ ThreadGroupReference tg = itg.nextThreadGroup();
588+ if (tg.name().equals(idToken)) {
589+ ThreadIterator it = new ThreadIterator(tg);
590+ while (it.hasNext()) {
591+ runtime.stopThread(it.nextThread());
592+ }
593+ env.notice("Threadgroup " + tg.name() + "killed.");
594+ return;
595+ }
596+ }
597+ env.failure("\"" + idToken +
598+ "\" is not a valid threadgroup or id.");
599+ }
600+ }
601+ }
602+
603+
604+ /*************
605+ // TODO
606+ private void commandCatchException(StringTokenizer t) throws NoSessionException {}
607+ // TODO
608+ private void commandIgnoreException(StringTokenizer t) throws NoSessionException {}
609+ *************/
610+
611+ // Command: up
612+
613+ //### Print current frame after command?
614+
615+ int readCount(StringTokenizer t) {
616+ int cnt = 1;
617+ if (t.hasMoreTokens()) {
618+ String idToken = t.nextToken();
619+ try {
620+ cnt = Integer.valueOf(idToken).intValue();
621+ } catch (NumberFormatException e) {
622+ cnt = -1;
623+ }
624+ }
625+ return cnt;
626+ }
627+
628+ void commandUp(StringTokenizer t) throws NoSessionException {
629+ ThreadReference current = context.getCurrentThread();
630+ if (current == null) {
631+ env.failure("No current thread.");
632+ return;
633+ }
634+ int nLevels = readCount(t);
635+ if (nLevels <= 0) {
636+ env.error("usage: up [n frames]");
637+ return;
638+ }
639+ try {
640+ int delta = context.moveCurrentFrameIndex(current, -nLevels);
641+ if (delta == 0) {
642+ env.notice("Already at top of stack.");
643+ } else if (-delta < nLevels) {
644+ env.notice("Moved up " + delta + " frames to top of stack.");
645+ }
646+ } catch (VMNotInterruptedException e) {
647+ env.failure("Target VM must be in interrupted state.");
648+ }
649+ }
650+
651+ private void commandDown(StringTokenizer t) throws NoSessionException {
652+ ThreadReference current = context.getCurrentThread();
653+ if (current == null) {
654+ env.failure("No current thread.");
655+ return;
656+ }
657+ int nLevels = readCount(t);
658+ if (nLevels <= 0) {
659+ env.error("usage: down [n frames]");
660+ return;
661+ }
662+ try {
663+ int delta = context.moveCurrentFrameIndex(current, nLevels);
664+ if (delta == 0) {
665+ env.notice("Already at bottom of stack.");
666+ } else if (delta < nLevels) {
667+ env.notice("Moved down " + delta + " frames to bottom of stack.");
668+ }
669+ } catch (VMNotInterruptedException e) {
670+ env.failure("Target VM must be in interrupted state.");
671+ }
672+ }
673+
674+ // Command: frame
675+
676+ private void commandFrame(StringTokenizer t) throws NoSessionException {
677+ ThreadReference current = context.getCurrentThread();
678+ if (current == null) {
679+ env.failure("No current thread.");
680+ return;
681+ }
682+ if (!t.hasMoreTokens()) {
683+ env.error("usage: frame <frame-index>");
684+ return;
685+ }
686+ String idToken = t.nextToken();
687+ int n;
688+ try {
689+ n = Integer.valueOf(idToken).intValue();
690+ } catch (NumberFormatException e) {
691+ n = 0;
692+ }
693+ if (n <= 0) {
694+ env.error("use positive frame index");
695+ return;
696+ }
697+ try {
698+ int delta = context.setCurrentFrameIndex(current, n);
699+ if (delta == 0) {
700+ env.notice("Frame unchanged.");
701+ } else if (delta < 0) {
702+ env.notice("Moved up " + -delta + " frames.");
703+ } else {
704+ env.notice("Moved down " + delta + " frames.");
705+ }
706+ } catch (VMNotInterruptedException e) {
707+ env.failure("Target VM must be in interrupted state.");
708+ }
709+ }
710+
711+ // Command: where
712+
713+ //### Should we insist that VM be interrupted here?
714+ //### There is an inconsistency between the 'where' command
715+ //### and 'up' and 'down' in this respect.
716+
717+ private void commandWhere(StringTokenizer t, boolean showPC)
718+ throws NoSessionException {
719+ ThreadReference current = context.getCurrentThread();
720+ if (!t.hasMoreTokens()) {
721+ if (current == null) {
722+ env.error("No thread specified.");
723+ return;
724+ }
725+ dumpStack(current, showPC);
726+ } else {
727+ String token = t.nextToken();
728+ if (token.toLowerCase().equals("all")) {
729+ ThreadIterator it = allThreads();
730+ while (it.hasNext()) {
731+ ThreadReference thread = it.next();
732+ out.println(thread.name() + ": ");
733+ dumpStack(thread, showPC);
734+ }
735+ } else {
736+ ThreadReference thread = findThread(t.nextToken());
737+ //### Do we want to set current thread here?
738+ //### Should notify user of change.
739+ if (thread != null) {
740+ context.setCurrentThread(thread);
741+ }
742+ dumpStack(thread, showPC);
743+ }
744+ }
745+ }
746+
747+ private void dumpStack(ThreadReference thread, boolean showPC) {
748+ //### Check for these.
749+ //env.failure("Thread no longer exists.");
750+ //env.failure("Target VM must be in interrupted state.");
751+ //env.failure("Current thread isn't suspended.");
752+ //### Should handle extremely long stack traces sensibly for user.
753+ List<StackFrame> stack = null;
754+ try {
755+ stack = thread.frames();
756+ } catch (IncompatibleThreadStateException e) {
757+ env.failure("Thread is not suspended.");
758+ }
759+ //### Fix this!
760+ //### Previously mishandled cases where thread was not current.
761+ //### Now, prints all of the stack regardless of current frame.
762+ int frameIndex = 0;
763+ //int frameIndex = context.getCurrentFrameIndex();
764+ if (stack == null) {
765+ env.failure("Thread is not running (no stack).");
766+ } else {
767+ OutputSink out = env.getOutputSink();
768+ int nFrames = stack.size();
769+ for (int i = frameIndex; i < nFrames; i++) {
770+ StackFrame frame = stack.get(i);
771+ Location loc = frame.location();
772+ Method meth = loc.method();
773+ out.print(" [" + (i + 1) + "] ");
774+ out.print(meth.declaringType().name());
775+ out.print('.');
776+ out.print(meth.name());
777+ out.print(" (");
778+ if (meth.isNative()) {
779+ out.print("native method");
780+ } else if (loc.lineNumber() != -1) {
781+ try {
782+ out.print(loc.sourceName());
783+ } catch (AbsentInformationException e) {
784+ out.print("<unknown>");
785+ }
786+ out.print(':');
787+ out.print(loc.lineNumber());
788+ }
789+ out.print(')');
790+ if (showPC) {
791+ long pc = loc.codeIndex();
792+ if (pc != -1) {
793+ out.print(", pc = " + pc);
794+ }
795+ }
796+ out.println();
797+ }
798+ out.show();
799+ }
800+ }
801+
802+ private void listEventRequests() throws NoSessionException {
803+ // Print set breakpoints
804+ List<EventRequestSpec> specs = runtime.eventRequestSpecs();
805+ if (specs.isEmpty()) {
806+ env.notice("No breakpoints/watchpoints/exceptions set.");
807+ } else {
808+ OutputSink out = env.getOutputSink();
809+ out.println("Current breakpoints/watchpoints/exceptions set:");
810+ for (EventRequestSpec bp : specs) {
811+ out.println("\t" + bp);
812+ }
813+ out.show();
814+ }
815+ }
816+
817+ private BreakpointSpec parseBreakpointSpec(String bptSpec) {
818+ StringTokenizer t = new StringTokenizer(bptSpec);
819+ BreakpointSpec bpSpec = null;
820+// try {
821+ String token = t.nextToken("@:( \t\n\r");
822+ // We can't use hasMoreTokens here because it will cause any leading
823+ // paren to be lost.
824+ String rest;
825+ try {
826+ rest = t.nextToken("").trim();
827+ } catch (NoSuchElementException e) {
828+ rest = null;
829+ }
830+ if ((rest != null) && rest.startsWith("@")) {
831+ t = new StringTokenizer(rest.substring(1));
832+ String sourceName = token;
833+ String lineToken = t.nextToken();
834+ int lineNumber = Integer.valueOf(lineToken).intValue();
835+ if (t.hasMoreTokens()) {
836+ return null;
837+ }
838+ bpSpec = runtime.createSourceLineBreakpoint(sourceName,
839+ lineNumber);
840+ } else if ((rest != null) && rest.startsWith(":")) {
841+ t = new StringTokenizer(rest.substring(1));
842+ String classId = token;
843+ String lineToken = t.nextToken();
844+ int lineNumber = Integer.valueOf(lineToken).intValue();
845+ if (t.hasMoreTokens()) {
846+ return null;
847+ }
848+ bpSpec = runtime.createClassLineBreakpoint(classId, lineNumber);
849+ } else {
850+ // Try stripping method from class.method token.
851+ int idot = token.lastIndexOf(".");
852+ if ( (idot <= 0) || /* No dot or dot in first char */
853+ (idot >= token.length() - 1) ) { /* dot in last char */
854+ return null;
855+ }
856+ String methodName = token.substring(idot + 1);
857+ String classId = token.substring(0, idot);
858+ List<String> argumentList = null;
859+ if (rest != null) {
860+ if (!rest.startsWith("(") || !rest.endsWith(")")) {
861+ //### Should throw exception with error message
862+ //out.println("Invalid method specification: "
863+ // + methodName + rest);
864+ return null;
865+ }
866+ // Trim the parens
867+ //### What about spaces in arglist?
868+ rest = rest.substring(1, rest.length() - 1);
869+ argumentList = new ArrayList<String>();
870+ t = new StringTokenizer(rest, ",");
871+ while (t.hasMoreTokens()) {
872+ argumentList.add(t.nextToken());
873+ }
874+ }
875+ bpSpec = runtime.createMethodBreakpoint(classId,
876+ methodName,
877+ argumentList);
878+ }
879+// } catch (Exception e) {
880+// env.error("Exception attempting to create breakpoint: " + e);
881+// return null;
882+// }
883+ return bpSpec;
884+ }
885+
886+ private void commandStop(StringTokenizer t) throws NoSessionException {
887+ String token;
888+
889+ if (!t.hasMoreTokens()) {
890+ listEventRequests();
891+ } else {
892+ token = t.nextToken();
893+ // Ignore optional "at" or "in" token.
894+ // Allowed for backward compatibility.
895+ if (token.equals("at") || token.equals("in")) {
896+ if (t.hasMoreTokens()) {
897+ token = t.nextToken();
898+ } else {
899+ env.error("Missing breakpoint specification.");
900+ return;
901+ }
902+ }
903+ BreakpointSpec bpSpec = parseBreakpointSpec(token);
904+ if (bpSpec != null) {
905+ //### Add sanity-checks for deferred breakpoint.
906+ runtime.install(bpSpec);
907+ } else {
908+ env.error("Ill-formed breakpoint specification.");
909+ }
910+ }
911+ }
912+
913+ private void commandClear(StringTokenizer t) throws NoSessionException {
914+ if (!t.hasMoreTokens()) {
915+ // Print set breakpoints
916+ listEventRequests();
917+ return;
918+ }
919+ //### need 'clear all'
920+ BreakpointSpec bpSpec = parseBreakpointSpec(t.nextToken());
921+ if (bpSpec != null) {
922+ List<EventRequestSpec> specs = runtime.eventRequestSpecs();
923+
924+ if (specs.isEmpty()) {
925+ env.notice("No breakpoints set.");
926+ } else {
927+ List<EventRequestSpec> toDelete = new ArrayList<EventRequestSpec>();
928+ for (EventRequestSpec spec : specs) {
929+ if (spec.equals(bpSpec)) {
930+ toDelete.add(spec);
931+ }
932+ }
933+ // The request used for matching should be found
934+ if (toDelete.size() <= 1) {
935+ env.notice("No matching breakpoint set.");
936+ }
937+ for (EventRequestSpec spec : toDelete) {
938+ runtime.delete(spec);
939+ }
940+ }
941+ } else {
942+ env.error("Ill-formed breakpoint specification.");
943+ }
944+ }
945+
946+ // Command: list
947+
948+ private void commandList(StringTokenizer t) throws NoSessionException {
949+ ThreadReference current = context.getCurrentThread();
950+ if (current == null) {
951+ env.error("No thread specified.");
952+ return;
953+ }
954+ Location loc;
955+ try {
956+ StackFrame frame = context.getCurrentFrame(current);
957+ if (frame == null) {
958+ env.failure("Thread has not yet begun execution.");
959+ return;
960+ }
961+ loc = frame.location();
962+ } catch (VMNotInterruptedException e) {
963+ env.failure("Target VM must be in interrupted state.");
964+ return;
965+ }
966+ SourceModel source = sourceManager.sourceForLocation(loc);
967+ if (source == null) {
968+ if (loc.method().isNative()) {
969+ env.failure("Current method is native.");
970+ return;
971+ }
972+ env.failure("No source available for " + Utils.locationString(loc) + ".");
973+ return;
974+ }
975+ ReferenceType refType = loc.declaringType();
976+ int lineno = loc.lineNumber();
977+ if (t.hasMoreTokens()) {
978+ String id = t.nextToken();
979+ // See if token is a line number.
980+ try {
981+ lineno = Integer.valueOf(id).intValue();
982+ } catch (NumberFormatException nfe) {
983+ // It isn't -- see if it's a method name.
984+ List<Method> meths = refType.methodsByName(id);
985+ if (meths == null || meths.size() == 0) {
986+ env.failure(id +
987+ " is not a valid line number or " +
988+ "method name for class " +
989+ refType.name());
990+ return;
991+ } else if (meths.size() > 1) {
992+ env.failure(id +
993+ " is an ambiguous method name in" +
994+ refType.name());
995+ return;
996+ }
997+ loc = meths.get(0).location();
998+ lineno = loc.lineNumber();
999+ }
1000+ }
1001+ int startLine = (lineno > 4) ? lineno - 4 : 1;
1002+ int endLine = startLine + 9;
1003+ String sourceLine = source.sourceLine(lineno);
1004+ if (sourceLine == null) {
1005+ env.failure("" +
1006+ lineno +
1007+ " is an invalid line number for " +
1008+ refType.name());
1009+ } else {
1010+ OutputSink out = env.getOutputSink();
1011+ for (int i = startLine; i <= endLine; i++) {
1012+ sourceLine = source.sourceLine(i);
1013+ if (sourceLine == null) {
1014+ break;
1015+ }
1016+ out.print(i);
1017+ out.print("\t");
1018+ if (i == lineno) {
1019+ out.print("=> ");
1020+ } else {
1021+ out.print(" ");
1022+ }
1023+ out.println(sourceLine);
1024+ }
1025+ out.show();
1026+ }
1027+ }
1028+
1029+ // Command: use
1030+ // Get or set the source file path list.
1031+
1032+ private void commandUse(StringTokenizer t) {
1033+ if (!t.hasMoreTokens()) {
1034+ out.println(sourceManager.getSourcePath().asString());
1035+ } else {
1036+ //### Should throw exception for invalid path.
1037+ //### E.g., vetoable property change.
1038+ sourceManager.setSourcePath(new SearchPath(t.nextToken()));
1039+ }
1040+ }
1041+
1042+ // Command: sourcepath
1043+ // Get or set the source file path list. (Alternate to 'use'.)
1044+
1045+ private void commandSourcepath(StringTokenizer t) {
1046+ if (!t.hasMoreTokens()) {
1047+ out.println(sourceManager.getSourcePath().asString());
1048+ } else {
1049+ //### Should throw exception for invalid path.
1050+ //### E.g., vetoable property change.
1051+ sourceManager.setSourcePath(new SearchPath(t.nextToken()));
1052+ }
1053+ }
1054+
1055+ // Command: classpath
1056+ // Get or set the class file path list.
1057+
1058+ private void commandClasspath(StringTokenizer t) {
1059+ if (!t.hasMoreTokens()) {
1060+ out.println(classManager.getClassPath().asString());
1061+ } else {
1062+ //### Should throw exception for invalid path.
1063+ //### E.g., vetoable property change.
1064+ classManager.setClassPath(new SearchPath(t.nextToken()));
1065+ }
1066+ }
1067+
1068+ // Command: view
1069+ // Display source for source file or class.
1070+
1071+ private void commandView(StringTokenizer t) throws NoSessionException {
1072+ if (!t.hasMoreTokens()) {
1073+ env.error("Argument required");
1074+ } else {
1075+ String name = t.nextToken();
1076+ if (name.endsWith(".java") ||
1077+ name.indexOf(File.separatorChar) >= 0) {
1078+ env.viewSource(name);
1079+ } else {
1080+ //### JDI crashes taking line number for class.
1081+ /*****
1082+ ReferenceType cls = findClass(name);
1083+ if (cls != null) {
1084+ env.viewLocation(cls.location());
1085+ } else {
1086+ env.failure("No such class");
1087+ }
1088+ *****/
1089+ String fileName = name.replace('.', File.separatorChar) + ".java";
1090+ env.viewSource(fileName);
1091+ }
1092+ }
1093+ }
1094+
1095+ // Command: locals
1096+ // Print all local variables in current stack frame.
1097+
1098+ private void commandLocals() throws NoSessionException {
1099+ ThreadReference current = context.getCurrentThread();
1100+ if (current == null) {
1101+ env.failure("No default thread specified: " +
1102+ "use the \"thread\" command first.");
1103+ return;
1104+ }
1105+ StackFrame frame;
1106+ try {
1107+ frame = context.getCurrentFrame(current);
1108+ if (frame == null) {
1109+ env.failure("Thread has not yet created any stack frames.");
1110+ return;
1111+ }
1112+ } catch (VMNotInterruptedException e) {
1113+ env.failure("Target VM must be in interrupted state.");
1114+ return;
1115+ }
1116+
1117+ List<LocalVariable> vars;
1118+ try {
1119+ vars = frame.visibleVariables();
1120+ if (vars == null || vars.size() == 0) {
1121+ env.failure("No local variables");
1122+ return;
1123+ }
1124+ } catch (AbsentInformationException e) {
1125+ env.failure("Local variable information not available." +
1126+ " Compile with -g to generate variable information");
1127+ return;
1128+ }
1129+
1130+ OutputSink out = env.getOutputSink();
1131+ out.println("Method arguments:");
1132+ for (LocalVariable var : vars) {
1133+ if (var.isArgument()) {
1134+ printVar(out, var, frame);
1135+ }
1136+ }
1137+ out.println("Local variables:");
1138+ for (LocalVariable var : vars) {
1139+ if (!var.isArgument()) {
1140+ printVar(out, var, frame);
1141+ }
1142+ }
1143+ out.show();
1144+ return;
1145+ }
1146+
1147+ /**
1148+ * Command: monitor
1149+ * Monitor an expression
1150+ */
1151+ private void commandMonitor(StringTokenizer t) throws NoSessionException {
1152+ if (!t.hasMoreTokens()) {
1153+ env.error("Argument required");
1154+ } else {
1155+ env.getMonitorListModel().add(t.nextToken(""));
1156+ }
1157+ }
1158+
1159+ /**
1160+ * Command: unmonitor
1161+ * Unmonitor an expression
1162+ */
1163+ private void commandUnmonitor(StringTokenizer t) throws NoSessionException {
1164+ if (!t.hasMoreTokens()) {
1165+ env.error("Argument required");
1166+ } else {
1167+ env.getMonitorListModel().remove(t.nextToken(""));
1168+ }
1169+ }
1170+
1171+ // Print a stack variable.
1172+
1173+ private void printVar(OutputSink out, LocalVariable var, StackFrame frame) {
1174+ out.print(" " + var.name());
1175+ if (var.isVisible(frame)) {
1176+ Value val = frame.getValue(var);
1177+ out.println(" = " + val.toString());
1178+ } else {
1179+ out.println(" is not in scope");
1180+ }
1181+ }
1182+
1183+ // Command: print
1184+ // Evaluate an expression.
1185+
1186+ private void commandPrint(StringTokenizer t, boolean dumpObject) throws NoSessionException {
1187+ if (!t.hasMoreTokens()) {
1188+ //### Probably confused if expresion contains whitespace.
1189+ env.error("No expression specified.");
1190+ return;
1191+ }
1192+ ThreadReference current = context.getCurrentThread();
1193+ if (current == null) {
1194+ env.failure("No default thread specified: " +
1195+ "use the \"thread\" command first.");
1196+ return;
1197+ }
1198+ StackFrame frame;
1199+ try {
1200+ frame = context.getCurrentFrame(current);
1201+ if (frame == null) {
1202+ env.failure("Thread has not yet created any stack frames.");
1203+ return;
1204+ }
1205+ } catch (VMNotInterruptedException e) {
1206+ env.failure("Target VM must be in interrupted state.");
1207+ return;
1208+ }
1209+ while (t.hasMoreTokens()) {
1210+ String expr = t.nextToken("");
1211+ Value val = null;
1212+ try {
1213+ val = runtime.evaluate(frame, expr);
1214+ } catch(Exception e) {
1215+ env.error("Exception: " + e);
1216+ //### Fix this!
1217+ }
1218+ if (val == null) {
1219+ return; // Error message already printed
1220+ }
1221+ OutputSink out = env.getOutputSink();
1222+ if (dumpObject && (val instanceof ObjectReference) &&
1223+ !(val instanceof StringReference)) {
1224+ ObjectReference obj = (ObjectReference)val;
1225+ ReferenceType refType = obj.referenceType();
1226+ out.println(expr + " = " + val.toString() + " {");
1227+ dump(out, obj, refType, refType);
1228+ out.println("}");
1229+ } else {
1230+ out.println(expr + " = " + val.toString());
1231+ }
1232+ out.show();
1233+ }
1234+ }
1235+
1236+ private void dump(OutputSink out,
1237+ ObjectReference obj, ReferenceType refType,
1238+ ReferenceType refTypeBase) {
1239+ for (Field field : refType.fields()) {
1240+ out.print(" ");
1241+ if (!refType.equals(refTypeBase)) {
1242+ out.print(refType.name() + ".");
1243+ }
1244+ out.print(field.name() + ": ");
1245+ Object o = obj.getValue(field);
1246+ out.println((o == null) ? "null" : o.toString()); // Bug ID 4374471
1247+ }
1248+ if (refType instanceof ClassType) {
1249+ ClassType sup = ((ClassType)refType).superclass();
1250+ if (sup != null) {
1251+ dump(out, obj, sup, refTypeBase);
1252+ }
1253+ } else if (refType instanceof InterfaceType) {
1254+ for (InterfaceType sup : ((InterfaceType)refType).superinterfaces()) {
1255+ dump(out, obj, sup, refTypeBase);
1256+ }
1257+ }
1258+ }
1259+
1260+ /*
1261+ * Display help message.
1262+ */
1263+
1264+ private void help() {
1265+ out.println("** command list **");
1266+ out.println("threads [threadgroup] -- list threads");
1267+ out.println("thread <thread id> -- set default thread");
1268+ out.println("suspend [thread id(s)] -- suspend threads (default: all)");
1269+ out.println("resume [thread id(s)] -- resume threads (default: all)");
1270+ out.println("where [thread id] | all -- dump a thread's stack");
1271+ out.println("wherei [thread id] | all -- dump a thread's stack, with pc info");
1272+ out.println("threadgroups -- list threadgroups");
1273+ out.println("threadgroup <name> -- set current threadgroup\n");
1274+// out.println("print <expression> -- print value of expression");
1275+ out.println("dump <expression> -- print all object information\n");
1276+// out.println("eval <expression> -- evaluate expression (same as print)");
1277+ out.println("locals -- print all local variables in current stack frame\n");
1278+ out.println("classes -- list currently known classes");
1279+ out.println("methods <class id> -- list a class's methods\n");
1280+ out.println("stop [in] <class id>.<method>[(argument_type,...)] -- set a breakpoint in a method");
1281+ out.println("stop [at] <class id>:<line> -- set a breakpoint at a line");
1282+ out.println("up [n frames] -- move up a thread's stack");
1283+ out.println("down [n frames] -- move down a thread's stack");
1284+ out.println("frame <frame-id> -- to a frame");
1285+ out.println("clear <class id>.<method>[(argument_type,...)] -- clear a breakpoint in a method");
1286+ out.println("clear <class id>:<line> -- clear a breakpoint at a line");
1287+ out.println("clear -- list breakpoints");
1288+ out.println("step -- execute current line");
1289+ out.println("step up -- execute until the current method returns to its caller");
1290+ out.println("stepi -- execute current instruction");
1291+ out.println("next -- step one line (step OVER calls)");
1292+ out.println("nexti -- step one instruction (step OVER calls)");
1293+ out.println("cont -- continue execution from breakpoint\n");
1294+// out.println("catch <class id> -- break for the specified exception");
1295+// out.println("ignore <class id> -- ignore when the specified exception\n");
1296+ out.println("view classname|filename -- display source file");
1297+ out.println("list [line number|method] -- print source code context at line or method");
1298+ out.println("use <source file path> -- display or change the source path\n");
1299+//### new
1300+ out.println("sourcepath <source file path> -- display or change the source path\n");
1301+//### new
1302+ out.println("classpath <class file path> -- display or change the class path\n");
1303+ out.println("monitor <expression> -- evaluate an expression each time the program stops\n");
1304+ out.println("unmonitor <monitor#> -- delete a monitor\n");
1305+ out.println("read <filename> -- read and execute a command file\n");
1306+// out.println("memory -- report memory usage");
1307+// out.println("gc -- free unused objects\n");
1308+ out.println("run <class> [args] -- start execution of a Java class");
1309+ out.println("run -- re-execute last class run");
1310+ out.println("load <class> [args] -- start execution of a Java class, initially suspended");
1311+ out.println("load -- re-execute last class run, initially suspended");
1312+ out.println("attach <portname> -- debug existing process\n");
1313+ out.println("detach -- detach from debuggee process\n");
1314+ out.println("kill <thread(group)> -- kill a thread or threadgroup\n");
1315+ out.println("!! -- repeat last command");
1316+ out.println("help (or ?) -- list commands");
1317+ out.println("exit (or quit) -- exit debugger");
1318+ }
1319+
1320+ /*
1321+ * Execute a command.
1322+ */
1323+
1324+ public void executeCommand(String command) {
1325+ //### Treatment of 'out' here is dirty...
1326+ out = env.getOutputSink();
1327+ if (echo) {
1328+ out.println(">>> " + command);
1329+ }
1330+ StringTokenizer t = new StringTokenizer(command);
1331+ try {
1332+ String cmd;
1333+ if (t.hasMoreTokens()) {
1334+ cmd = t.nextToken().toLowerCase();
1335+ lastCommand = cmd;
1336+ } else {
1337+ cmd = lastCommand;
1338+ }
1339+ if (cmd.equals("print")) {
1340+ commandPrint(t, false);
1341+ } else if (cmd.equals("eval")) {
1342+ commandPrint(t, false);
1343+ } else if (cmd.equals("dump")) {
1344+ commandPrint(t, true);
1345+ } else if (cmd.equals("locals")) {
1346+ commandLocals();
1347+ } else if (cmd.equals("classes")) {
1348+ commandClasses();
1349+ } else if (cmd.equals("methods")) {
1350+ commandMethods(t);
1351+ } else if (cmd.equals("threads")) {
1352+ commandThreads(t);
1353+ } else if (cmd.equals("thread")) {
1354+ commandThread(t);
1355+ } else if (cmd.equals("suspend")) {
1356+ commandSuspend(t);
1357+ } else if (cmd.equals("resume")) {
1358+ commandResume(t);
1359+ } else if (cmd.equals("cont")) {
1360+ commandCont();
1361+ } else if (cmd.equals("threadgroups")) {
1362+ commandThreadGroups();
1363+ } else if (cmd.equals("threadgroup")) {
1364+ commandThreadGroup(t);
1365+ } else if (cmd.equals("run")) {
1366+ commandRun(t);
1367+ } else if (cmd.equals("load")) {
1368+ commandLoad(t);
1369+ } else if (cmd.equals("connect")) {
1370+ commandConnect(t);
1371+ } else if (cmd.equals("attach")) {
1372+ commandAttach(t);
1373+ } else if (cmd.equals("detach")) {
1374+ commandDetach(t);
1375+ } else if (cmd.equals("interrupt")) {
1376+ commandInterrupt(t);
1377+//### Not implemented.
1378+// } else if (cmd.equals("catch")) {
1379+// commandCatchException(t);
1380+//### Not implemented.
1381+// } else if (cmd.equals("ignore")) {
1382+// commandIgnoreException(t);
1383+ } else if (cmd.equals("step")) {
1384+ commandStep(t);
1385+ } else if (cmd.equals("stepi")) {
1386+ commandStepi();
1387+ } else if (cmd.equals("next")) {
1388+ commandNext();
1389+ } else if (cmd.equals("nexti")) {
1390+ commandNexti();
1391+ } else if (cmd.equals("kill")) {
1392+ commandKill(t);
1393+ } else if (cmd.equals("where")) {
1394+ commandWhere(t, false);
1395+ } else if (cmd.equals("wherei")) {
1396+ commandWhere(t, true);
1397+ } else if (cmd.equals("up")) {
1398+ commandUp(t);
1399+ } else if (cmd.equals("down")) {
1400+ commandDown(t);
1401+ } else if (cmd.equals("frame")) {
1402+ commandFrame(t);
1403+ } else if (cmd.equals("stop")) {
1404+ commandStop(t);
1405+ } else if (cmd.equals("clear")) {
1406+ commandClear(t);
1407+ } else if (cmd.equals("list")) {
1408+ commandList(t);
1409+ } else if (cmd.equals("use")) {
1410+ commandUse(t);
1411+ } else if (cmd.equals("sourcepath")) {
1412+ commandSourcepath(t);
1413+ } else if (cmd.equals("classpath")) {
1414+ commandClasspath(t);
1415+ } else if (cmd.equals("monitor")) {
1416+ commandMonitor(t);
1417+ } else if (cmd.equals("unmonitor")) {
1418+ commandUnmonitor(t);
1419+ } else if (cmd.equals("view")) {
1420+ commandView(t);
1421+// } else if (cmd.equals("read")) {
1422+// readCommand(t);
1423+ } else if (cmd.equals("help") || cmd.equals("?")) {
1424+ help();
1425+ } else if (cmd.equals("quit") || cmd.equals("exit")) {
1426+ try {
1427+ runtime.detach();
1428+ } catch (NoSessionException e) {
1429+ // ignore
1430+ }
1431+ env.terminate();
1432+ } else {
1433+ //### Dubious repeat-count feature inherited from 'jdb'
1434+ if (t.hasMoreTokens()) {
1435+ try {
1436+ int repeat = Integer.parseInt(cmd);
1437+ String subcom = t.nextToken("");
1438+ while (repeat-- > 0) {
1439+ executeCommand(subcom);
1440+ }
1441+ return;
1442+ } catch (NumberFormatException exc) {
1443+ }
1444+ }
1445+ out.println("huh? Try help...");
1446+ out.flush();
1447+ }
1448+ } catch (NoSessionException e) {
1449+ out.println("There is no currently attached VM session.");
1450+ out.flush();
1451+ } catch (Exception e) {
1452+ out.println("Internal exception: " + e.toString());
1453+ out.flush();
1454+ System.out.println("JDB internal exception: " + e.toString());
1455+ e.printStackTrace();
1456+ }
1457+ out.show();
1458+ }
1459+}
java/pkg/com/sun/tools/example/debug/gui/CommandTool.java+333−0
@@ -0,0 +1,333 @@
1+/*
2+ * Copyright (c) 1998, 1999, Oracle and/or its affiliates. All rights reserved.
3+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+ *
5+ * This code is free software; you can redistribute it and/or modify it
6+ * under the terms of the GNU General Public License version 2 only, as
7+ * published by the Free Software Foundation. Oracle designates this
8+ * particular file as subject to the "Classpath" exception as provided
9+ * by Oracle in the LICENSE file that accompanied this code.
10+ *
11+ * This code is distributed in the hope that it will be useful, but WITHOUT
12+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+ * version 2 for more details (a copy is included in the LICENSE file that
15+ * accompanied this code).
16+ *
17+ * You should have received a copy of the GNU General Public License version
18+ * 2 along with this work; if not, write to the Free Software Foundation,
19+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+ *
21+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+ * or visit www.oracle.com if you need additional information or have any
23+ * questions.
24+ */
25+
26+package com.sun.tools.example.debug.gui;
27+
28+import java.io.*;
29+import java.util.*;
30+
31+import javax.swing.*;
32+import java.awt.BorderLayout;
33+import java.awt.event.*;
34+
35+import com.sun.jdi.*;
36+import com.sun.jdi.event.*;
37+
38+import com.sun.tools.example.debug.bdi.*;
39+import com.sun.tools.example.debug.event.*;
40+
41+public class CommandTool extends JPanel {
42+
43+ private static final long serialVersionUID = 8613516856378346415L;
44+
45+ private Environment env;
46+
47+ private ContextManager context;
48+ private ExecutionManager runtime;
49+ private SourceManager sourceManager;
50+
51+ private TypeScript script;
52+
53+ private static final String DEFAULT_CMD_PROMPT = "Command:";
54+
55+ public CommandTool(Environment env) {
56+
57+ super(new BorderLayout());
58+
59+ this.env = env;
60+ this.context = env.getContextManager();
61+ this.runtime = env.getExecutionManager();
62+ this.sourceManager = env.getSourceManager();
63+
64+ script = new TypeScript(DEFAULT_CMD_PROMPT, false); //no echo
65+ this.add(script);
66+
67+ final CommandInterpreter interpreter =
68+ new CommandInterpreter(env);
69+
70+ // Establish handler for incoming commands.
71+
72+ script.addActionListener(new ActionListener() {
73+ @Override
74+ public void actionPerformed(ActionEvent e) {
75+ interpreter.executeCommand(script.readln());
76+ }
77+ });
78+
79+ // Establish ourselves as the listener for VM diagnostics.
80+
81+ OutputListener diagnosticsListener =
82+ new TypeScriptOutputListener(script, true);
83+ runtime.addDiagnosticsListener(diagnosticsListener);
84+
85+ // Establish ourselves as the shared debugger typescript.
86+
87+ env.setTypeScript(new PrintWriter(new TypeScriptWriter(script)));
88+
89+ // Handle VM events.
90+
91+ TTYDebugListener listener = new TTYDebugListener(diagnosticsListener);
92+
93+ runtime.addJDIListener(listener);
94+ runtime.addSessionListener(listener);
95+ runtime.addSpecListener(listener);
96+ context.addContextListener(listener);
97+
98+ //### remove listeners on exit!
99+
100+ }
101+
102+ private class TTYDebugListener implements
103+ JDIListener, SessionListener, SpecListener, ContextListener {
104+
105+ private OutputListener diagnostics;
106+
107+ TTYDebugListener(OutputListener diagnostics) {
108+ this.diagnostics = diagnostics;
109+ }
110+
111+ // JDIListener
112+
113+ @Override
114+ public void accessWatchpoint(AccessWatchpointEventSet e) {
115+ setThread(e);
116+ for (EventIterator it = e.eventIterator(); it.hasNext(); ) {
117+ it.nextEvent();
118+ diagnostics.putString("Watchpoint hit: " +
119+ locationString(e));
120+ }
121+ }
122+
123+ @Override
124+ public void classPrepare(ClassPrepareEventSet e) {
125+ if (context.getVerboseFlag()) {
126+ String name = e.getReferenceType().name();
127+ diagnostics.putString("Class " + name + " loaded");
128+ }
129+ }
130+
131+ @Override
132+ public void classUnload(ClassUnloadEventSet e) {
133+ if (context.getVerboseFlag()) {
134+ diagnostics.putString("Class " + e.getClassName() +
135+ " unloaded.");
136+ }
137+ }
138+
139+ @Override
140+ public void exception(ExceptionEventSet e) {
141+ setThread(e);
142+ String name = e.getException().referenceType().name();
143+ diagnostics.putString("Exception: " + name);
144+ }
145+
146+ @Override
147+ public void locationTrigger(LocationTriggerEventSet e) {
148+ String locString = locationString(e);
149+ setThread(e);
150+ for (EventIterator it = e.eventIterator(); it.hasNext(); ) {
151+ Event evt = it.nextEvent();
152+ if (evt instanceof BreakpointEvent) {
153+ diagnostics.putString("Breakpoint hit: " + locString);
154+ } else if (evt instanceof StepEvent) {
155+ diagnostics.putString("Step completed: " + locString);
156+ } else if (evt instanceof MethodEntryEvent) {
157+ diagnostics.putString("Method entered: " + locString);
158+ } else if (evt instanceof MethodExitEvent) {
159+ diagnostics.putString("Method exited: " + locString);
160+ } else {
161+ diagnostics.putString("UNKNOWN event: " + e);
162+ }
163+ }
164+ }
165+
166+ @Override
167+ public void modificationWatchpoint(ModificationWatchpointEventSet e) {
168+ setThread(e);
169+ for (EventIterator it = e.eventIterator(); it.hasNext(); ) {
170+ it.nextEvent();
171+ diagnostics.putString("Watchpoint hit: " +
172+ locationString(e));
173+ }
174+ }
175+
176+ @Override
177+ public void threadDeath(ThreadDeathEventSet e) {
178+ if (context.getVerboseFlag()) {
179+ diagnostics.putString("Thread " + e.getThread() +
180+ " ended.");
181+ }
182+ }
183+
184+ @Override
185+ public void threadStart(ThreadStartEventSet e) {
186+ if (context.getVerboseFlag()) {
187+ diagnostics.putString("Thread " + e.getThread() +
188+ " started.");
189+ }
190+ }
191+
192+ @Override
193+ public void vmDeath(VMDeathEventSet e) {
194+ script.setPrompt(DEFAULT_CMD_PROMPT);
195+ diagnostics.putString("VM exited");
196+ }
197+
198+ @Override
199+ public void vmDisconnect(VMDisconnectEventSet e) {
200+ script.setPrompt(DEFAULT_CMD_PROMPT);
201+ diagnostics.putString("Disconnected from VM");
202+ }
203+
204+ @Override
205+ public void vmStart(VMStartEventSet e) {
206+ script.setPrompt(DEFAULT_CMD_PROMPT);
207+ diagnostics.putString("VM started");
208+ }
209+
210+ // SessionListener
211+
212+ @Override
213+ public void sessionStart(EventObject e) {}
214+
215+ @Override
216+ public void sessionInterrupt(EventObject e) {
217+ Thread.yield(); // fetch output
218+ diagnostics.putString("VM interrupted by user.");
219+ script.setPrompt(DEFAULT_CMD_PROMPT);
220+ }
221+
222+ @Override
223+ public void sessionContinue(EventObject e) {
224+ diagnostics.putString("Execution resumed.");
225+ script.setPrompt(DEFAULT_CMD_PROMPT);
226+ }
227+
228+ // SpecListener
229+
230+ @Override
231+ public void breakpointSet(SpecEvent e) {
232+ EventRequestSpec spec = e.getEventRequestSpec();
233+ diagnostics.putString("Breakpoint set at " + spec + ".");
234+ }
235+ @Override
236+ public void breakpointDeferred(SpecEvent e) {
237+ EventRequestSpec spec = e.getEventRequestSpec();
238+ diagnostics.putString("Breakpoint will be set at " +
239+ spec + " when its class is loaded.");
240+ }
241+ @Override
242+ public void breakpointDeleted(SpecEvent e) {
243+ EventRequestSpec spec = e.getEventRequestSpec();
244+ diagnostics.putString("Breakpoint at " + spec.toString() + " deleted.");
245+ }
246+ @Override
247+ public void breakpointResolved(SpecEvent e) {
248+ EventRequestSpec spec = e.getEventRequestSpec();
249+ diagnostics.putString("Breakpoint resolved to " + spec.toString() + ".");
250+ }
251+ @Override
252+ public void breakpointError(SpecErrorEvent e) {
253+ EventRequestSpec spec = e.getEventRequestSpec();
254+ diagnostics.putString("Deferred breakpoint at " +
255+ spec + " could not be resolved:" +
256+ e.getReason());
257+ }
258+
259+//### Add info for watchpoints and exceptions
260+
261+ @Override
262+ public void watchpointSet(SpecEvent e) {
263+ }
264+ @Override
265+ public void watchpointDeferred(SpecEvent e) {
266+ }
267+ @Override
268+ public void watchpointDeleted(SpecEvent e) {
269+ }
270+ @Override
271+ public void watchpointResolved(SpecEvent e) {
272+ }
273+ @Override
274+ public void watchpointError(SpecErrorEvent e) {
275+ }
276+
277+ @Override
278+ public void exceptionInterceptSet(SpecEvent e) {
279+ }
280+ @Override
281+ public void exceptionInterceptDeferred(SpecEvent e) {
282+ }
283+ @Override
284+ public void exceptionInterceptDeleted(SpecEvent e) {
285+ }
286+ @Override
287+ public void exceptionInterceptResolved(SpecEvent e) {
288+ }
289+ @Override
290+ public void exceptionInterceptError(SpecErrorEvent e) {
291+ }
292+
293+
294+ // ContextListener.
295+
296+ // If the user selects a new current thread or frame, update prompt.
297+
298+ @Override
299+ public void currentFrameChanged(CurrentFrameChangedEvent e) {
300+ // Update prompt only if affect thread is current.
301+ ThreadReference thread = e.getThread();
302+ if (thread == context.getCurrentThread()) {
303+ script.setPrompt(promptString(thread, e.getIndex()));
304+ }
305+ }
306+
307+ }
308+
309+ private String locationString(LocatableEventSet e) {
310+ Location loc = e.getLocation();
311+ return "thread=\"" + e.getThread().name() +
312+ "\", " + Utils.locationString(loc);
313+ }
314+
315+ private void setThread(LocatableEventSet e) {
316+ if (!e.suspendedNone()) {
317+ Thread.yield(); // fetch output
318+ script.setPrompt(promptString(e.getThread(), 0));
319+ //### Current thread should be set elsewhere, e.g.,
320+ //### in ContextManager
321+ //### context.setCurrentThread(thread);
322+ }
323+ }
324+
325+ private String promptString(ThreadReference thread, int frameIndex) {
326+ if (thread == null) {
327+ return DEFAULT_CMD_PROMPT;
328+ } else {
329+ // Frame indices are presented to user as indexed from 1.
330+ return (thread.name() + "[" + (frameIndex + 1) + "]:");
331+ }
332+ }
333+}
java/pkg/com/sun/tools/example/debug/gui/ContextListener.java+30−0
@@ -0,0 +1,30 @@
1+/*
2+ * Copyright (c) 1998, 1999, Oracle and/or its affiliates. All rights reserved.
3+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+ *
5+ * This code is free software; you can redistribute it and/or modify it
6+ * under the terms of the GNU General Public License version 2 only, as
7+ * published by the Free Software Foundation. Oracle designates this
8+ * particular file as subject to the "Classpath" exception as provided
9+ * by Oracle in the LICENSE file that accompanied this code.
10+ *
11+ * This code is distributed in the hope that it will be useful, but WITHOUT
12+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+ * version 2 for more details (a copy is included in the LICENSE file that
15+ * accompanied this code).
16+ *
17+ * You should have received a copy of the GNU General Public License version
18+ * 2 along with this work; if not, write to the Free Software Foundation,
19+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+ *
21+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+ * or visit www.oracle.com if you need additional information or have any
23+ * questions.
24+ */
25+
26+package com.sun.tools.example.debug.gui;
27+
28+public interface ContextListener {
29+ void currentFrameChanged(CurrentFrameChangedEvent e);
30+}
java/pkg/com/sun/tools/example/debug/gui/ContextManager.java+353−0
@@ -0,0 +1,353 @@
1+/*
2+ * Copyright (c) 1998, 1999, Oracle and/or its affiliates. All rights reserved.
3+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+ *
5+ * This code is free software; you can redistribute it and/or modify it
6+ * under the terms of the GNU General Public License version 2 only, as
7+ * published by the Free Software Foundation. Oracle designates this
8+ * particular file as subject to the "Classpath" exception as provided
9+ * by Oracle in the LICENSE file that accompanied this code.
10+ *
11+ * This code is distributed in the hope that it will be useful, but WITHOUT
12+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+ * version 2 for more details (a copy is included in the LICENSE file that
15+ * accompanied this code).
16+ *
17+ * You should have received a copy of the GNU General Public License version
18+ * 2 along with this work; if not, write to the Free Software Foundation,
19+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+ *
21+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+ * or visit www.oracle.com if you need additional information or have any
23+ * questions.
24+ */
25+
26+package com.sun.tools.example.debug.gui;
27+
28+import java.io.*;
29+import java.util.*;
30+
31+import com.sun.jdi.*;
32+import com.sun.tools.example.debug.event.*;
33+import com.sun.tools.example.debug.bdi.*;
34+
35+public class ContextManager {
36+
37+ private ClassManager classManager;
38+ private ExecutionManager runtime;
39+
40+ private String mainClassName;
41+ private String vmArguments;
42+ private String commandArguments;
43+ private String remotePort;
44+
45+ private ThreadReference currentThread;
46+
47+ private boolean verbose;
48+
49+ private ArrayList<ContextListener> contextListeners = new ArrayList<ContextListener>();
50+
51+ public ContextManager(Environment env) {
52+ classManager = env.getClassManager();
53+ runtime = env.getExecutionManager();
54+ mainClassName = "";
55+ vmArguments = "";
56+ commandArguments = "";
57+ currentThread = null;
58+
59+ ContextManagerListener listener = new ContextManagerListener();
60+ runtime.addJDIListener(listener);
61+ runtime.addSessionListener(listener);
62+ }
63+
64+ // Program execution defaults.
65+
66+ //### Should there be change listeners for these?
67+ //### They would be needed if we expected a dialog to be
68+ //### synchronized with command input while it was open.
69+
70+ public String getMainClassName() {
71+ return mainClassName;
72+ }
73+
74+ public void setMainClassName(String mainClassName) {
75+ this.mainClassName = mainClassName;
76+ }
77+
78+ public String getVmArguments() {
79+ return processClasspathDefaults(vmArguments);
80+ }
81+
82+ public void setVmArguments(String vmArguments) {
83+ this.vmArguments = vmArguments;
84+ }
85+
86+ public String getProgramArguments() {
87+ return commandArguments;
88+ }
89+
90+ public void setProgramArguments(String commandArguments) {
91+ this.commandArguments = commandArguments;
92+ }
93+
94+ public String getRemotePort() {
95+ return remotePort;
96+ }
97+
98+ public void setRemotePort(String remotePort) {
99+ this.remotePort = remotePort;
100+
101+ }
102+
103+
104+ // Miscellaneous debugger session preferences.
105+
106+ public boolean getVerboseFlag() {
107+ return verbose;
108+ }
109+
110+ public void setVerboseFlag(boolean verbose) {
111+ this.verbose = verbose;
112+ }
113+
114+
115+ // Thread focus.
116+
117+ public ThreadReference getCurrentThread() {
118+ return currentThread;
119+ }
120+
121+ public void setCurrentThread(ThreadReference t) {
122+ if (t != currentThread) {
123+ currentThread = t;
124+ notifyCurrentThreadChanged(t);
125+ }
126+ }
127+
128+ public void setCurrentThreadInvalidate(ThreadReference t) {
129+ currentThread = t;
130+ notifyCurrentFrameChanged(runtime.threadInfo(t),
131+ 0, true);
132+ }
133+
134+ public void invalidateCurrentThread() {
135+ notifyCurrentFrameChanged(null, 0, true);
136+ }
137+
138+
139+ // If a view is displaying the current thread, it may
140+ // choose to indicate which frame is current in the
141+ // sense of the command-line UI. It may also "warp" the
142+ // selection to that frame when changed by an 'up' or 'down'
143+ // command. Hence, a notifier is provided.
144+
145+ /******
146+ public int getCurrentFrameIndex() {
147+ return getCurrentFrameIndex(currentThreadInfo);
148+ }
149+ ******/
150+
151+ public int getCurrentFrameIndex(ThreadReference t) {
152+ return getCurrentFrameIndex(runtime.threadInfo(t));
153+ }
154+
155+ //### Used in StackTraceTool.
156+ public int getCurrentFrameIndex(ThreadInfo tinfo) {
157+ if (tinfo == null) {
158+ return 0;
159+ }
160+ Integer currentFrame = (Integer)tinfo.getUserObject();
161+ if (currentFrame == null) {
162+ return 0;
163+ } else {
164+ return currentFrame.intValue();
165+ }
166+ }
167+
168+ public int moveCurrentFrameIndex(ThreadReference t, int count) throws VMNotInterruptedException {
169+ return setCurrentFrameIndex(t,count, true);
170+ }
171+
172+ public int setCurrentFrameIndex(ThreadReference t, int newIndex) throws VMNotInterruptedException {
173+ return setCurrentFrameIndex(t, newIndex, false);
174+ }
175+
176+ public int setCurrentFrameIndex(int newIndex) throws VMNotInterruptedException {
177+ if (currentThread == null) {
178+ return 0;
179+ } else {
180+ return setCurrentFrameIndex(currentThread, newIndex, false);
181+ }
182+ }
183+
184+ private int setCurrentFrameIndex(ThreadReference t, int x, boolean relative) throws VMNotInterruptedException {
185+ boolean sameThread = t.equals(currentThread);
186+ ThreadInfo tinfo = runtime.threadInfo(t);
187+ if (tinfo == null) {
188+ return 0;
189+ }
190+ int maxIndex = tinfo.getFrameCount()-1;
191+ int oldIndex = getCurrentFrameIndex(tinfo);
192+ int newIndex = relative? oldIndex + x : x;
193+ if (newIndex > maxIndex) {
194+ newIndex = maxIndex;
195+ } else if (newIndex < 0) {
196+ newIndex = 0;
197+ }
198+ if (!sameThread || newIndex != oldIndex) { // don't recurse
199+ setCurrentFrameIndex(tinfo, newIndex);
200+ }
201+ return newIndex - oldIndex;
202+ }
203+
204+ private void setCurrentFrameIndex(ThreadInfo tinfo, int index) {
205+ tinfo.setUserObject(new Integer(index));
206+ //### In fact, the value may not have changed at this point.
207+ //### We need to signal that the user attempted to change it,
208+ //### however, so that the selection can be "warped" to the
209+ //### current location.
210+ notifyCurrentFrameChanged(tinfo.thread(), index);
211+ }
212+
213+ public StackFrame getCurrentFrame() throws VMNotInterruptedException {
214+ return getCurrentFrame(runtime.threadInfo(currentThread));
215+ }
216+
217+ public StackFrame getCurrentFrame(ThreadReference t) throws VMNotInterruptedException {
218+ return getCurrentFrame(runtime.threadInfo(t));
219+ }
220+
221+ public StackFrame getCurrentFrame(ThreadInfo tinfo) throws VMNotInterruptedException {
222+ int index = getCurrentFrameIndex(tinfo);
223+ try {
224+ // It is possible, though unlikely, that the VM was interrupted
225+ // before the thread created its Java stack.
226+ return tinfo.getFrame(index);
227+ } catch (FrameIndexOutOfBoundsException e) {
228+ return null;
229+ }
230+ }
231+
232+ public void addContextListener(ContextListener cl) {
233+ contextListeners.add(cl);
234+ }
235+
236+ public void removeContextListener(ContextListener cl) {
237+ contextListeners.remove(cl);
238+ }
239+
240+ //### These notifiers are fired only in response to USER-INITIATED changes
241+ //### to the current thread and current frame. When the current thread is set automatically
242+ //### after a breakpoint hit or step completion, no event is generated. Instead,
243+ //### interested parties are expected to listen for the BreakpointHit and StepCompleted
244+ //### events. This convention is unclean, and I believe that it reflects a defect in
245+ //### in the current architecture. Unfortunately, however, we cannot guarantee the
246+ //### order in which various listeners receive a given event, and the handlers for
247+ //### the very same events that cause automatic changes to the current thread may also
248+ //### need to know the current thread.
249+
250+ private void notifyCurrentThreadChanged(ThreadReference t) {
251+ ThreadInfo tinfo = null;
252+ int index = 0;
253+ if (t != null) {
254+ tinfo = runtime.threadInfo(t);
255+ index = getCurrentFrameIndex(tinfo);
256+ }
257+ notifyCurrentFrameChanged(tinfo, index, false);
258+ }
259+
260+ private void notifyCurrentFrameChanged(ThreadReference t, int index) {
261+ notifyCurrentFrameChanged(runtime.threadInfo(t),
262+ index, false);
263+ }
264+
265+ private void notifyCurrentFrameChanged(ThreadInfo tinfo, int index,
266+ boolean invalidate) {
267+ ArrayList<ContextListener> l = new ArrayList<ContextListener>(contextListeners);
268+ CurrentFrameChangedEvent evt =
269+ new CurrentFrameChangedEvent(this, tinfo, index, invalidate);
270+ for (int i = 0; i < l.size(); i++) {
271+ l.get(i).currentFrameChanged(evt);
272+ }
273+ }
274+
275+ private class ContextManagerListener extends JDIAdapter
276+ implements SessionListener, JDIListener {
277+
278+ // SessionListener
279+
280+ @Override
281+ public void sessionStart(EventObject e) {
282+ invalidateCurrentThread();
283+ }
284+
285+ @Override
286+ public void sessionInterrupt(EventObject e) {
287+ setCurrentThreadInvalidate(currentThread);
288+ }
289+
290+ @Override
291+ public void sessionContinue(EventObject e) {
292+ invalidateCurrentThread();
293+ }
294+
295+ // JDIListener
296+
297+ @Override
298+ public void locationTrigger(LocationTriggerEventSet e) {
299+ setCurrentThreadInvalidate(e.getThread());
300+ }
301+
302+ @Override
303+ public void exception(ExceptionEventSet e) {
304+ setCurrentThreadInvalidate(e.getThread());
305+ }
306+
307+ @Override
308+ public void vmDisconnect(VMDisconnectEventSet e) {
309+ invalidateCurrentThread();
310+ }
311+
312+ }
313+
314+
315+ /**
316+ * Add a -classpath argument to the arguments passed to the exec'ed
317+ * VM with the contents of CLASSPATH environment variable,
318+ * if -classpath was not already specified.
319+ *
320+ * @param javaArgs the arguments to the VM being exec'd that
321+ * potentially has a user specified -classpath argument.
322+ * @return a javaArgs whose -classpath option has been added
323+ */
324+
325+ private String processClasspathDefaults(String javaArgs) {
326+ if (javaArgs.indexOf("-classpath ") == -1) {
327+ StringBuffer munged = new StringBuffer(javaArgs);
328+ SearchPath classpath = classManager.getClassPath();
329+ if (classpath.isEmpty()) {
330+ String envcp = System.getProperty("env.class.path");
331+ if ((envcp != null) && (envcp.length() > 0)) {
332+ munged.append(" -classpath " + envcp);
333+ }
334+ } else {
335+ munged.append(" -classpath " + classpath.asString());
336+ }
337+ return munged.toString();
338+ } else {
339+ return javaArgs;
340+ }
341+ }
342+
343+ private String appendPath(String path1, String path2) {
344+ if (path1 == null || path1.length() == 0) {
345+ return path2 == null ? "." : path2;
346+ } else if (path2 == null || path2.length() == 0) {
347+ return path1;
348+ } else {
349+ return path1 + File.pathSeparator + path2;
350+ }
351+ }
352+
353+}
java/pkg/com/sun/tools/example/debug/gui/CurrentFrameChangedEvent.java+62−0
@@ -0,0 +1,62 @@
1+/*
2+ * Copyright (c) 1998, 1999, Oracle and/or its affiliates. All rights reserved.
3+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+ *
5+ * This code is free software; you can redistribute it and/or modify it
6+ * under the terms of the GNU General Public License version 2 only, as
7+ * published by the Free Software Foundation. Oracle designates this
8+ * particular file as subject to the "Classpath" exception as provided
9+ * by Oracle in the LICENSE file that accompanied this code.
10+ *
11+ * This code is distributed in the hope that it will be useful, but WITHOUT
12+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+ * version 2 for more details (a copy is included in the LICENSE file that
15+ * accompanied this code).
16+ *
17+ * You should have received a copy of the GNU General Public License version
18+ * 2 along with this work; if not, write to the Free Software Foundation,
19+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+ *
21+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+ * or visit www.oracle.com if you need additional information or have any
23+ * questions.
24+ */
25+
26+package com.sun.tools.example.debug.gui;
27+
28+import com.sun.jdi.*;
29+import com.sun.tools.example.debug.bdi.*;
30+import java.util.EventObject;
31+
32+public class CurrentFrameChangedEvent extends EventObject {
33+
34+ private static final long serialVersionUID = 4214479486546762179L;
35+ private ThreadInfo tinfo;
36+ private int index;
37+ private boolean invalidate;
38+
39+ public CurrentFrameChangedEvent(Object source, ThreadInfo tinfo,
40+ int index, boolean invalidate) {
41+ super(source);
42+ this.tinfo = tinfo;
43+ this.index = index;
44+ this.invalidate = invalidate;
45+ }
46+
47+ public ThreadReference getThread() {
48+ return tinfo == null? null : tinfo.thread();
49+ }
50+
51+ public ThreadInfo getThreadInfo() {
52+ return tinfo;
53+ }
54+
55+ public int getIndex() {
56+ return index;
57+ }
58+
59+ public boolean getInvalidate() {
60+ return invalidate;
61+ }
62+}
java/pkg/com/sun/tools/example/debug/gui/Environment.java+156−0
@@ -0,0 +1,156 @@
1+/*
2+ * Copyright (c) 1998, 1999, Oracle and/or its affiliates. All rights reserved.
3+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+ *
5+ * This code is free software; you can redistribute it and/or modify it
6+ * under the terms of the GNU General Public License version 2 only, as
7+ * published by the Free Software Foundation. Oracle designates this
8+ * particular file as subject to the "Classpath" exception as provided
9+ * by Oracle in the LICENSE file that accompanied this code.
10+ *
11+ * This code is distributed in the hope that it will be useful, but WITHOUT
12+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+ * version 2 for more details (a copy is included in the LICENSE file that
15+ * accompanied this code).
16+ *
17+ * You should have received a copy of the GNU General Public License version
18+ * 2 along with this work; if not, write to the Free Software Foundation,
19+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+ *
21+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+ * or visit www.oracle.com if you need additional information or have any
23+ * questions.
24+ */
25+
26+package com.sun.tools.example.debug.gui;
27+
28+import java.io.*;
29+import com.sun.jdi.*;
30+import com.sun.tools.example.debug.bdi.*;
31+
32+public class Environment {
33+
34+ private SourceManager sourceManager;
35+ private ClassManager classManager;
36+ private ContextManager contextManager;
37+ private MonitorListModel monitorListModel;
38+ private ExecutionManager runtime;
39+
40+ private PrintWriter typeScript;
41+
42+ private boolean verbose;
43+
44+ public Environment() {
45+ this.classManager = new ClassManager(this);
46+ //### Order of the next three lines is important! (FIX THIS)
47+ this.runtime = new ExecutionManager();
48+ this.sourceManager = new SourceManager(this);
49+ this.contextManager = new ContextManager(this);
50+ this.monitorListModel = new MonitorListModel(this);
51+ }
52+
53+ // Services used by debugging tools.
54+
55+ public SourceManager getSourceManager() {
56+ return sourceManager;
57+ }
58+
59+ public ClassManager getClassManager() {
60+ return classManager;
61+ }
62+
63+ public ContextManager getContextManager() {
64+ return contextManager;
65+ }
66+
67+ public MonitorListModel getMonitorListModel() {
68+ return monitorListModel;
69+ }
70+
71+ public ExecutionManager getExecutionManager() {
72+ return runtime;
73+ }
74+
75+ //### TODO:
76+ //### Tools should attach/detach from environment
77+ //### via a property, which should call an 'addTool'
78+ //### method when set to maintain a registry of
79+ //### tools for exit-time cleanup, etc. Tool
80+ //### class constructors should be argument-free, so
81+ //### that they may be instantiated by bean builders.
82+ //### Will also need 'removeTool' in case property
83+ //### value is changed.
84+ //
85+ // public void addTool(Tool t);
86+ // public void removeTool(Tool t);
87+
88+ public void terminate() {
89+ System.exit(0);
90+ }
91+
92+ // public void refresh(); // notify all tools to refresh their views
93+
94+
95+ // public void addStatusListener(StatusListener l);
96+ // public void removeStatusListener(StatusListener l);
97+
98+ // public void addOutputListener(OutputListener l);
99+ // public void removeOutputListener(OutputListener l);
100+
101+ public void setTypeScript(PrintWriter writer) {
102+ typeScript = writer;
103+ }
104+
105+ public void error(String message) {
106+ if (typeScript != null) {
107+ typeScript.println(message);
108+ } else {
109+ System.out.println(message);
110+ }
111+ }
112+
113+ public void failure(String message) {
114+ if (typeScript != null) {
115+ typeScript.println(message);
116+ } else {
117+ System.out.println(message);
118+ }
119+ }
120+
121+ public void notice(String message) {
122+ if (typeScript != null) {
123+ typeScript.println(message);
124+ } else {
125+ System.out.println(message);
126+ }
127+ }
128+
129+ public OutputSink getOutputSink() {
130+ return new OutputSink(typeScript);
131+ }
132+
133+ public void viewSource(String fileName) {
134+ //### HACK ###
135+ //### Should use listener here.
136+ com.sun.tools.example.debug.gui.GUI.srcTool.showSourceFile(fileName);
137+ }
138+
139+ public void viewLocation(Location locn) {
140+ //### HACK ###
141+ //### Should use listener here.
142+ //### Should we use sourceForLocation here?
143+ com.sun.tools.example.debug.gui.GUI.srcTool.showSourceForLocation(locn);
144+ }
145+
146+ //### Also in 'ContextManager'. Do we need both?
147+
148+ public boolean getVerboseFlag() {
149+ return verbose;
150+ }
151+
152+ public void setVerboseFlag(boolean verbose) {
153+ this.verbose = verbose;
154+ }
155+
156+}
java/pkg/com/sun/tools/example/debug/gui/GUI.java+256−0
@@ -0,0 +1,256 @@
1+/*
2+ * Copyright (c) 1998, 1999, Oracle and/or its affiliates. All rights reserved.
3+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+ *
5+ * This code is free software; you can redistribute it and/or modify it
6+ * under the terms of the GNU General Public License version 2 only, as
7+ * published by the Free Software Foundation. Oracle designates this
8+ * particular file as subject to the "Classpath" exception as provided
9+ * by Oracle in the LICENSE file that accompanied this code.
10+ *
11+ * This code is distributed in the hope that it will be useful, but WITHOUT
12+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+ * version 2 for more details (a copy is included in the LICENSE file that
15+ * accompanied this code).
16+ *
17+ * You should have received a copy of the GNU General Public License version
18+ * 2 along with this work; if not, write to the Free Software Foundation,
19+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+ *
21+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+ * or visit www.oracle.com if you need additional information or have any
23+ * questions.
24+ */
25+
26+package com.sun.tools.example.debug.gui;
27+
28+import java.io.*;
29+import javax.swing.*;
30+import javax.swing.border.*;
31+import java.awt.*;
32+import java.awt.event.*;
33+
34+import com.sun.jdi.*;
35+import com.sun.tools.example.debug.bdi.*;
36+
37+public class GUI extends JPanel {
38+
39+ private static final long serialVersionUID = 3292463234530679091L;
40+ private CommandTool cmdTool;
41+ private ApplicationTool appTool;
42+ //###HACK##
43+ //### There is currently dirty code in Environment that
44+ //### accesses this directly.
45+ //private SourceTool srcTool;
46+ public static SourceTool srcTool;
47+
48+ private SourceTreeTool sourceTreeTool;
49+ private ClassTreeTool classTreeTool;
50+ private ThreadTreeTool threadTreeTool;
51+ private StackTraceTool stackTool;
52+ private MonitorTool monitorTool;
53+
54+ public static final String progname = "javadt";
55+ public static final String version = "1.0Beta"; //### FIX ME.
56+ public static final String windowBanner = "Java(tm) platform Debug Tool";
57+
58+ private Font fixedFont = new Font("monospaced", Font.PLAIN, 10);
59+
60+ private GUI(Environment env) {
61+ setLayout(new BorderLayout());
62+
63+ setBorder(new EmptyBorder(5, 5, 5, 5));
64+
65+ add(new JDBToolBar(env), BorderLayout.NORTH);
66+
67+ srcTool = new SourceTool(env);
68+ srcTool.setPreferredSize(new java.awt.Dimension(500, 300));
69+ srcTool.setTextFont(fixedFont);
70+
71+ stackTool = new StackTraceTool(env);
72+ stackTool.setPreferredSize(new java.awt.Dimension(500, 100));
73+
74+ monitorTool = new MonitorTool(env);
75+ monitorTool.setPreferredSize(new java.awt.Dimension(500, 50));
76+
77+ JSplitPane right = new JSplitPane(JSplitPane.VERTICAL_SPLIT, srcTool,
78+ new JSplitPane(JSplitPane.VERTICAL_SPLIT, stackTool, monitorTool));
79+
80+ sourceTreeTool = new SourceTreeTool(env);
81+ sourceTreeTool.setPreferredSize(new java.awt.Dimension(200, 450));
82+
83+ classTreeTool = new ClassTreeTool(env);
84+ classTreeTool.setPreferredSize(new java.awt.Dimension(200, 450));
85+
86+ threadTreeTool = new ThreadTreeTool(env);
87+ threadTreeTool.setPreferredSize(new java.awt.Dimension(200, 450));
88+
89+ JTabbedPane treePane = new JTabbedPane(SwingConstants.BOTTOM);
90+ treePane.addTab("Source", null, sourceTreeTool);
91+ treePane.addTab("Classes", null, classTreeTool);
92+ treePane.addTab("Threads", null, threadTreeTool);
93+
94+ JSplitPane centerTop = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, treePane, right);
95+
96+ cmdTool = new CommandTool(env);
97+ cmdTool.setPreferredSize(new java.awt.Dimension(700, 150));
98+
99+ appTool = new ApplicationTool(env);
100+ appTool.setPreferredSize(new java.awt.Dimension(700, 200));
101+
102+ JSplitPane centerBottom = new JSplitPane(JSplitPane.VERTICAL_SPLIT, cmdTool, appTool);
103+ // centerBottom.setPreferredSize(new java.awt.Dimension(700, 350));
104+
105+ JSplitPane center = new JSplitPane(JSplitPane.VERTICAL_SPLIT, centerTop, centerBottom);
106+
107+ add(center, BorderLayout.CENTER);
108+
109+
110+ }
111+
112+ private static void usage() {
113+ String separator = File.pathSeparator;
114+ System.out.println("Usage: " + progname + " <options> <class> <arguments>");
115+ System.out.println();
116+ System.out.println("where options include:");
117+ System.out.println(" -help print out this message and exit");
118+ System.out.println(" -sourcepath <directories separated by \"" +
119+ separator + "\">");
120+ System.out.println(" list directories in which to look for source files");
121+ System.out.println(" -remote <hostname>:<port-number>");
122+ System.out.println(" host machine and port number of interpreter to attach to");
123+ System.out.println(" -dbgtrace [flags] print info for debugging " + progname);
124+ System.out.println();
125+ System.out.println("options forwarded to debuggee process:");
126+ System.out.println(" -v -verbose[:class|gc|jni]");
127+ System.out.println(" turn on verbose mode");
128+ System.out.println(" -D<name>=<value> set a system property");
129+ System.out.println(" -classpath <directories separated by \"" +
130+ separator + "\">");
131+ System.out.println(" list directories in which to look for classes");
132+ System.out.println(" -X<option> non-standard debuggee VM option");
133+ System.out.println();
134+ System.out.println("<class> is the name of the class to begin debugging");
135+ System.out.println("<arguments> are the arguments passed to the main() method of <class>");
136+ System.out.println();
137+ System.out.println("For command help type 'help' at " + progname + " prompt");
138+ }
139+
140+ public static void main(String argv[]) {
141+ String clsName = "";
142+ String progArgs = "";
143+ String javaArgs = "";
144+ final Environment env = new Environment();
145+
146+ JPanel mainPanel = new GUI(env);
147+
148+ ContextManager context = env.getContextManager();
149+ ExecutionManager runtime = env.getExecutionManager();
150+
151+ for (int i = 0; i < argv.length; i++) {
152+ String token = argv[i];
153+ if (token.equals("-dbgtrace")) {
154+ if ((i == argv.length - 1) ||
155+ ! Character.isDigit(argv[i+1].charAt(0))) {
156+ runtime.setTraceMode(VirtualMachine.TRACE_ALL);
157+ } else {
158+ String flagStr = argv[++i];
159+ runtime.setTraceMode(Integer.decode(flagStr).intValue());
160+ }
161+ } else if (token.equals("-X")) {
162+ System.out.println(
163+ "Use 'java -X' to see the available non-standard options");
164+ System.out.println();
165+ usage();
166+ System.exit(1);
167+ } else if (
168+ // Standard VM options passed on
169+ token.equals("-v") || token.startsWith("-v:") || // -v[:...]
170+ token.startsWith("-verbose") || // -verbose[:...]
171+ token.startsWith("-D") ||
172+ // NonStandard options passed on
173+ token.startsWith("-X") ||
174+ // Old-style options
175+ // (These should remain in place as long as the standard VM accepts them)
176+ token.equals("-noasyncgc") || token.equals("-prof") ||
177+ token.equals("-verify") || token.equals("-noverify") ||
178+ token.equals("-verifyremote") ||
179+ token.equals("-verbosegc") ||
180+ token.startsWith("-ms") || token.startsWith("-mx") ||
181+ token.startsWith("-ss") || token.startsWith("-oss") ) {
182+ javaArgs += token + " ";
183+ } else if (token.equals("-sourcepath")) {
184+ if (i == (argv.length - 1)) {
185+ System.out.println("No sourcepath specified.");
186+ usage();
187+ System.exit(1);
188+ }
189+ env.getSourceManager().setSourcePath(new SearchPath(argv[++i]));
190+ } else if (token.equals("-classpath")) {
191+ if (i == (argv.length - 1)) {
192+ System.out.println("No classpath specified.");
193+ usage();
194+ System.exit(1);
195+ }
196+ env.getClassManager().setClassPath(new SearchPath(argv[++i]));
197+ } else if (token.equals("-remote")) {
198+ if (i == (argv.length - 1)) {
199+ System.out.println("No remote specified.");
200+ usage();
201+ System.exit(1);
202+ }
203+ env.getContextManager().setRemotePort(argv[++i]);
204+ } else if (token.equals("-help")) {
205+ usage();
206+ System.exit(0);
207+ } else if (token.equals("-version")) {
208+ System.out.println(progname + " version " + version);
209+ System.exit(0);
210+ } else if (token.startsWith("-")) {
211+ System.out.println("invalid option: " + token);
212+ usage();
213+ System.exit(1);
214+ } else {
215+ // Everything from here is part of the command line
216+ clsName = token;
217+ for (i++; i < argv.length; i++) {
218+ progArgs += argv[i] + " ";
219+ }
220+ break;
221+ }
222+ }
223+
224+ context.setMainClassName(clsName);
225+ context.setProgramArguments(progArgs);
226+ context.setVmArguments(javaArgs);
227+
228+ // Force Cross Platform L&F
229+ try {
230+ UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
231+ // If you want the System L&F instead, comment out the above line and
232+ // uncomment the following:
233+ // UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
234+ } catch (Exception exc) {
235+ System.err.println("Error loading L&F: " + exc);
236+ }
237+
238+ JFrame frame = new JFrame();
239+ frame.setBackground(Color.lightGray);
240+ frame.setTitle(windowBanner);
241+ frame.setJMenuBar(new JDBMenuBar(env));
242+ frame.setContentPane(mainPanel);
243+
244+ frame.addWindowListener(new WindowAdapter() {
245+ @Override
246+ public void windowClosing(WindowEvent e) {
247+ env.terminate();
248+ }
249+ });
250+
251+ frame.pack();
252+ frame.setVisible(true);
253+
254+ }
255+
256+}
java/pkg/com/sun/tools/example/debug/gui/Icons.java+209−0
@@ -0,0 +1,209 @@
1+/*
2+ * Copyright (c) 1999, Oracle and/or its affiliates. All rights reserved.
3+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+ *
5+ * This code is free software; you can redistribute it and/or modify it
6+ * under the terms of the GNU General Public License version 2 only, as
7+ * published by the Free Software Foundation. Oracle designates this
8+ * particular file as subject to the "Classpath" exception as provided
9+ * by Oracle in the LICENSE file that accompanied this code.
10+ *
11+ * This code is distributed in the hope that it will be useful, but WITHOUT
12+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+ * version 2 for more details (a copy is included in the LICENSE file that
15+ * accompanied this code).
16+ *
17+ * You should have received a copy of the GNU General Public License version
18+ * 2 along with this work; if not, write to the Free Software Foundation,
19+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+ *
21+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+ * or visit www.oracle.com if you need additional information or have any
23+ * questions.
24+ */
25+
26+package com.sun.tools.example.debug.gui;
27+
28+import javax.swing.Icon;
29+import javax.swing.ImageIcon;
30+
31+class Icons {
32+
33+ private static int[] exec = {
34+ 0xffd8ffe0, 0x00104a46, 0x49460001, 0x01020000
35+, 0x00000000, 0xffdb0043, 0x00020101, 0x01010102
36+, 0x01010102, 0x02020202, 0x04030202, 0x02020504
37+, 0x04030406, 0x05060606, 0x05060606, 0x07090806
38+, 0x07090706, 0x06080b08, 0x090a0a0a, 0x0a0a0608
39+, 0x0b0c0b0a, 0x0c090a0a, 0x0affdb00, 0x43010202
40+, 0x02020202, 0x05030305, 0x0a070607, 0x0a0a0a0a
41+, 0x0a0a0a0a, 0x0a0a0a0a, 0x0a0a0a0a, 0x0a0a0a0a
42+, 0x0a0a0a0a, 0x0a0a0a0a, 0x0a0a0a0a, 0x0a0a0a0a
43+, 0x0a0a0a0a, 0x0a0a0a0a, 0x0a0a0a0a, 0x0a0affc0
44+, 0x00110800, 0x0c000c03, 0x01220002, 0x11010311
45+, 0x01ffc400, 0x1f000001, 0x05010101, 0x01010100
46+, 0x00000000, 0x00000001, 0x02030405, 0x06070809
47+, 0x0a0bffc4, 0x00b51000, 0x02010303, 0x02040305
48+, 0x05040400, 0x00017d01, 0x02030004, 0x11051221
49+, 0x31410613, 0x51610722, 0x71143281, 0x91a10823
50+, 0x42b1c115, 0x52d1f024, 0x33627282, 0x090a1617
51+, 0x18191a25, 0x26272829, 0x2a343536, 0x3738393a
52+, 0x43444546, 0x4748494a, 0x53545556, 0x5758595a
53+, 0x63646566, 0x6768696a, 0x73747576, 0x7778797a
54+, 0x83848586, 0x8788898a, 0x92939495, 0x96979899
55+, 0x9aa2a3a4, 0xa5a6a7a8, 0xa9aab2b3, 0xb4b5b6b7
56+, 0xb8b9bac2, 0xc3c4c5c6, 0xc7c8c9ca, 0xd2d3d4d5
57+, 0xd6d7d8d9, 0xdae1e2e3, 0xe4e5e6e7, 0xe8e9eaf1
58+, 0xf2f3f4f5, 0xf6f7f8f9, 0xfaffc400, 0x1f010003
59+, 0x01010101, 0x01010101, 0x01000000, 0x00000001
60+, 0x02030405, 0x06070809, 0x0a0bffc4, 0x00b51100
61+, 0x02010204, 0x04030407, 0x05040400, 0x01027700
62+, 0x01020311, 0x04052131, 0x06124151, 0x07617113
63+, 0x22328108, 0x144291a1, 0xb1c10923, 0x3352f015
64+, 0x6272d10a, 0x162434e1, 0x25f11718, 0x191a2627
65+, 0x28292a35, 0x36373839, 0x3a434445, 0x46474849
66+, 0x4a535455, 0x56575859, 0x5a636465, 0x66676869
67+, 0x6a737475, 0x76777879, 0x7a828384, 0x85868788
68+, 0x898a9293, 0x94959697, 0x98999aa2, 0xa3a4a5a6
69+, 0xa7a8a9aa, 0xb2b3b4b5, 0xb6b7b8b9, 0xbac2c3c4
70+, 0xc5c6c7c8, 0xc9cad2d3, 0xd4d5d6d7, 0xd8d9dae2
71+, 0xe3e4e5e6, 0xe7e8e9ea, 0xf2f3f4f5, 0xf6f7f8f9
72+, 0xfaffda00, 0x0c030100, 0x02110311, 0x003f00fd
73+, 0xbafda27e, 0x35ea1f03, 0x346f0ef8, 0x86cfc2d3
74+, 0x6b31ea9e, 0x2ab7d2ee, 0xf4fb38cb, 0x5cc91cb0
75+, 0xce4790a0, 0xfcd2ef44, 0xc29e1f95, 0xf94b065f
76+, 0x42a86eb4, 0xed3ef67b, 0x7b9bcb18, 0x6692ce63
77+, 0x35a492c4, 0x19a090a3, 0x465d09fb, 0xadb1dd72
78+, 0x39daec3a, 0x13535706, 0x1f0f8ca7, 0x8dad56a5
79+, 0x5e6a72e5, 0xe485be0b, 0x2b49df77, 0xcceda6ca
80+, 0xda6ece3a, 0x147150c5, 0xd5a93a97, 0x84b97963
81+, 0x6f86cbde, 0x77ddf33b, 0x69b2b69b, 0xb3ffd900
82+
83+ };
84+ private static int[] blank = {
85+ 0xffd8ffe0, 0x00104a46, 0x49460001, 0x01020000
86+, 0x00000000, 0xffdb0043, 0x00020101, 0x01010102
87+, 0x01010102, 0x02020202, 0x04030202, 0x02020504
88+, 0x04030406, 0x05060606, 0x05060606, 0x07090806
89+, 0x07090706, 0x06080b08, 0x090a0a0a, 0x0a0a0608
90+, 0x0b0c0b0a, 0x0c090a0a, 0x0affdb00, 0x43010202
91+, 0x02020202, 0x05030305, 0x0a070607, 0x0a0a0a0a
92+, 0x0a0a0a0a, 0x0a0a0a0a, 0x0a0a0a0a, 0x0a0a0a0a
93+, 0x0a0a0a0a, 0x0a0a0a0a, 0x0a0a0a0a, 0x0a0a0a0a
94+, 0x0a0a0a0a, 0x0a0a0a0a, 0x0a0a0a0a, 0x0a0affc0
95+, 0x00110800, 0x0c000c03, 0x01220002, 0x11010311
96+, 0x01ffc400, 0x1f000001, 0x05010101, 0x01010100
97+, 0x00000000, 0x00000001, 0x02030405, 0x06070809
98+, 0x0a0bffc4, 0x00b51000, 0x02010303, 0x02040305
99+, 0x05040400, 0x00017d01, 0x02030004, 0x11051221
100+, 0x31410613, 0x51610722, 0x71143281, 0x91a10823
101+, 0x42b1c115, 0x52d1f024, 0x33627282, 0x090a1617
102+, 0x18191a25, 0x26272829, 0x2a343536, 0x3738393a
103+, 0x43444546, 0x4748494a, 0x53545556, 0x5758595a
104+, 0x63646566, 0x6768696a, 0x73747576, 0x7778797a
105+, 0x83848586, 0x8788898a, 0x92939495, 0x96979899
106+, 0x9aa2a3a4, 0xa5a6a7a8, 0xa9aab2b3, 0xb4b5b6b7
107+, 0xb8b9bac2, 0xc3c4c5c6, 0xc7c8c9ca, 0xd2d3d4d5
108+, 0xd6d7d8d9, 0xdae1e2e3, 0xe4e5e6e7, 0xe8e9eaf1
109+, 0xf2f3f4f5, 0xf6f7f8f9, 0xfaffc400, 0x1f010003
110+, 0x01010101, 0x01010101, 0x01000000, 0x00000001
111+, 0x02030405, 0x06070809, 0x0a0bffc4, 0x00b51100
112+, 0x02010204, 0x04030407, 0x05040400, 0x01027700
113+, 0x01020311, 0x04052131, 0x06124151, 0x07617113
114+, 0x22328108, 0x144291a1, 0xb1c10923, 0x3352f015
115+, 0x6272d10a, 0x162434e1, 0x25f11718, 0x191a2627
116+, 0x28292a35, 0x36373839, 0x3a434445, 0x46474849
117+, 0x4a535455, 0x56575859, 0x5a636465, 0x66676869
118+, 0x6a737475, 0x76777879, 0x7a828384, 0x85868788
119+, 0x898a9293, 0x94959697, 0x98999aa2, 0xa3a4a5a6
120+, 0xa7a8a9aa, 0xb2b3b4b5, 0xb6b7b8b9, 0xbac2c3c4
121+, 0xc5c6c7c8, 0xc9cad2d3, 0xd4d5d6d7, 0xd8d9dae2
122+, 0xe3e4e5e6, 0xe7e8e9ea, 0xf2f3f4f5, 0xf6f7f8f9
123+, 0xfaffda00, 0x0c030100, 0x02110311, 0x003f00fd
124+, 0xfca28a28, 0x03ffd900
125+
126+ };
127+
128+ private static int[] stopSignWords = {
129+ 0xffd8ffe0, 0x00104a46, 0x49460001, 0x01020000
130+, 0x00000000, 0xffdb0043, 0x00020101, 0x01010102
131+, 0x01010102, 0x02020202, 0x04030202, 0x02020504
132+, 0x04030406, 0x05060606, 0x05060606, 0x07090806
133+, 0x07090706, 0x06080b08, 0x090a0a0a, 0x0a0a0608
134+, 0x0b0c0b0a, 0x0c090a0a, 0x0affdb00, 0x43010202
135+, 0x02020202, 0x05030305, 0x0a070607, 0x0a0a0a0a
136+, 0x0a0a0a0a, 0x0a0a0a0a, 0x0a0a0a0a, 0x0a0a0a0a
137+, 0x0a0a0a0a, 0x0a0a0a0a, 0x0a0a0a0a, 0x0a0a0a0a
138+, 0x0a0a0a0a, 0x0a0a0a0a, 0x0a0a0a0a, 0x0a0affc0
139+, 0x00110800, 0x0c000c03, 0x01220002, 0x11010311
140+, 0x01ffc400, 0x1f000001, 0x05010101, 0x01010100
141+, 0x00000000, 0x00000001, 0x02030405, 0x06070809
142+, 0x0a0bffc4, 0x00b51000, 0x02010303, 0x02040305
143+, 0x05040400, 0x00017d01, 0x02030004, 0x11051221
144+, 0x31410613, 0x51610722, 0x71143281, 0x91a10823
145+, 0x42b1c115, 0x52d1f024, 0x33627282, 0x090a1617
146+, 0x18191a25, 0x26272829, 0x2a343536, 0x3738393a
147+, 0x43444546, 0x4748494a, 0x53545556, 0x5758595a
148+, 0x63646566, 0x6768696a, 0x73747576, 0x7778797a
149+, 0x83848586, 0x8788898a, 0x92939495, 0x96979899
150+, 0x9aa2a3a4, 0xa5a6a7a8, 0xa9aab2b3, 0xb4b5b6b7
151+, 0xb8b9bac2, 0xc3c4c5c6, 0xc7c8c9ca, 0xd2d3d4d5
152+, 0xd6d7d8d9, 0xdae1e2e3, 0xe4e5e6e7, 0xe8e9eaf1
153+, 0xf2f3f4f5, 0xf6f7f8f9, 0xfaffc400, 0x1f010003
154+, 0x01010101, 0x01010101, 0x01000000, 0x00000001
155+, 0x02030405, 0x06070809, 0x0a0bffc4, 0x00b51100
156+, 0x02010204, 0x04030407, 0x05040400, 0x01027700
157+, 0x01020311, 0x04052131, 0x06124151, 0x07617113
158+, 0x22328108, 0x144291a1, 0xb1c10923, 0x3352f015
159+, 0x6272d10a, 0x162434e1, 0x25f11718, 0x191a2627
160+, 0x28292a35, 0x36373839, 0x3a434445, 0x46474849
161+, 0x4a535455, 0x56575859, 0x5a636465, 0x66676869
162+, 0x6a737475, 0x76777879, 0x7a828384, 0x85868788
163+, 0x898a9293, 0x94959697, 0x98999aa2, 0xa3a4a5a6
164+, 0xa7a8a9aa, 0xb2b3b4b5, 0xb6b7b8b9, 0xbac2c3c4
165+, 0xc5c6c7c8, 0xc9cad2d3, 0xd4d5d6d7, 0xd8d9dae2
166+, 0xe3e4e5e6, 0xe7e8e9ea, 0xf2f3f4f5, 0xf6f7f8f9
167+, 0xfaffda00, 0x0c030100, 0x02110311, 0x003f00f8
168+, 0xe7e37fc6, 0xff00197f, 0xc142fc65, 0x17ed5bfb
169+, 0x56db699e, 0x27f14f89, 0xf4cb7b85, 0x5bcd3924
170+, 0xb5d1ed5d, 0x3cc8b4db, 0x08a4ddf6, 0x6b387cc6
171+, 0x09182599, 0x99e595e5, 0x9e69a693, 0xbaf0dffc
172+, 0x1c9dff00, 0x050aff00, 0x82637837, 0x44fd94be
173+, 0x11e89f0f, 0xfc61e16d, 0x334c5b8f, 0x0f37c45d
174+, 0x26fef2eb, 0x46b56778, 0xd34db796, 0xd6fadbfd
175+, 0x0e2f2898, 0xa3903b42, 0xb21891d6, 0x08e08623
176+, 0xfe0e4ef0, 0xdf837fe0, 0x98dff050, 0xbb2f847f
177+, 0xb2978274, 0xcd33c2de, 0x30f87f69, 0xe2e6f0f5
178+, 0xe44ef6ba, 0x35d5c5fe, 0xa16b2dad, 0x8246d1f9
179+, 0x167fe84b, 0x2a40772c, 0x2d33c717, 0x9702c304
180+, 0x5fb0dff0, 0x4abff825, 0x5ffc13d7, 0xc55ff04f
181+, 0x5f845f17, 0x3e2e7ec8, 0xbf0ffe21, 0xf8a7e21f
182+, 0xc3fd1fc5, 0xde21f10f, 0xc45f0758, 0x6b774b75
183+, 0xa9584174, 0xf6b6ef75, 0x0b7d9ace, 0x1f304514
184+, 0x11ed50a8, 0x647f3279, 0x679e5fcf, 0x720cbb37
185+, 0xc3f1257a, 0x95eb7343, 0xdebabc9d, 0xeef4d1ab
186+, 0x2b7e1b2d, 0x0fec0f16, 0xb8c7c3cc, 0xdbc15caf
187+, 0x0795e59e, 0xc710fd97, 0x2cfd9d38, 0xf2f241aa
188+, 0x9efc64e5, 0x2e67dd7b, 0xdf14acd1, 0xffd90000
189+
190+};
191+
192+ static private byte[] wordsToBytes(int[] wordArray) {
193+ byte[] bytes = new byte[wordArray.length * 4];
194+ int inx = bytes.length;
195+ for (int i = wordArray.length-1; i >= 0; --i) {
196+ int word = wordArray[i];
197+ for (int j = 0; j < 4; ++j) {
198+ bytes[--inx] = (byte)(word & 0xff);
199+ word = word >>> 8;
200+ }
201+ }
202+ return bytes;
203+ }
204+
205+ static Icon stopSignIcon = new ImageIcon(wordsToBytes(stopSignWords));
206+ static Icon blankIcon = new ImageIcon(wordsToBytes(blank));
207+
208+ static Icon execIcon = new ImageIcon(wordsToBytes(exec));
209+}
java/pkg/com/sun/tools/example/debug/gui/JDBFileFilter.java+269−0
@@ -0,0 +1,269 @@
1+/*
2+ * Copyright (c) 1998, 2008, Oracle and/or its affiliates. All rights reserved.
3+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+ *
5+ * This code is free software; you can redistribute it and/or modify it
6+ * under the terms of the GNU General Public License version 2 only, as
7+ * published by the Free Software Foundation. Oracle designates this
8+ * particular file as subject to the "Classpath" exception as provided
9+ * by Oracle in the LICENSE file that accompanied this code.
10+ *
11+ * This code is distributed in the hope that it will be useful, but WITHOUT
12+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+ * version 2 for more details (a copy is included in the LICENSE file that
15+ * accompanied this code).
16+ *
17+ * You should have received a copy of the GNU General Public License version
18+ * 2 along with this work; if not, write to the Free Software Foundation,
19+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+ *
21+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+ * or visit www.oracle.com if you need additional information or have any
23+ * questions.
24+ */
25+
26+package com.sun.tools.example.debug.gui;
27+
28+import java.io.File;
29+import java.util.Hashtable;
30+import java.util.Enumeration;
31+import javax.swing.filechooser.*;
32+
33+//### Renamed from 'ExampleFileFilter.java' provided with Swing demos.
34+
35+/**
36+ * A convenience implementation of FileFilter that filters out
37+ * all files except for those type extensions that it knows about.
38+ *
39+ * Extensions are of the type ".foo", which is typically found on
40+ * Windows and Unix boxes, but not on Macinthosh. Case is ignored.
41+ *
42+ * Example - create a new filter that filerts out all files
43+ * but gif and jpg image files:
44+ *
45+ * JFileChooser chooser = new JFileChooser();
46+ * ExampleFileFilter filter = new ExampleFileFilter(
47+ * new String{"gif", "jpg"}, "JPEG & GIF Images")
48+ * chooser.addChoosableFileFilter(filter);
49+ * chooser.showOpenDialog(this);
50+ *
51+ * @author Jeff Dinkins
52+ */
53+
54+public class JDBFileFilter extends FileFilter {
55+
56+ private static String TYPE_UNKNOWN = "Type Unknown";
57+ private static String HIDDEN_FILE = "Hidden File";
58+
59+ private Hashtable<String, JDBFileFilter> filters = null;
60+ private String description = null;
61+ private String fullDescription = null;
62+ private boolean useExtensionsInDescription = true;
63+
64+ /**
65+ * Creates a file filter. If no filters are added, then all
66+ * files are accepted.
67+ *
68+ * @see #addExtension
69+ */
70+ public JDBFileFilter() {
71+ this.filters = new Hashtable<String, JDBFileFilter>();
72+ }
73+
74+ /**
75+ * Creates a file filter that accepts files with the given extension.
76+ * Example: new JDBFileFilter("jpg");
77+ *
78+ * @see #addExtension
79+ */
80+ public JDBFileFilter(String extension) {
81+ this(extension,null);
82+ }
83+
84+ /**
85+ * Creates a file filter that accepts the given file type.
86+ * Example: new JDBFileFilter("jpg", "JPEG Image Images");
87+ *
88+ * Note that the "." before the extension is not needed. If
89+ * provided, it will be ignored.
90+ *
91+ * @see #addExtension
92+ */
93+ public JDBFileFilter(String extension, String description) {
94+ this();
95+ if(extension!=null) {
96+ addExtension(extension);
97+ }
98+ if(description!=null) {
99+ setDescription(description);
100+ }
101+ }
102+
103+ /**
104+ * Creates a file filter from the given string array.
105+ * Example: new JDBFileFilter(String {"gif", "jpg"});
106+ *
107+ * Note that the "." before the extension is not needed adn
108+ * will be ignored.
109+ *
110+ * @see #addExtension
111+ */
112+ public JDBFileFilter(String[] filters) {
113+ this(filters, null);
114+ }
115+
116+ /**
117+ * Creates a file filter from the given string array and description.
118+ * Example: new JDBFileFilter(String {"gif", "jpg"}, "Gif and JPG Images");
119+ *
120+ * Note that the "." before the extension is not needed and will be ignored.
121+ *
122+ * @see #addExtension
123+ */
124+ public JDBFileFilter(String[] filters, String description) {
125+ this();
126+ for (String filter : filters) {
127+ // add filters one by one
128+ addExtension(filter);
129+ }
130+ if(description!=null) {
131+ setDescription(description);
132+ }
133+ }
134+
135+ /**
136+ * Return true if this file should be shown in the directory pane,
137+ * false if it shouldn't.
138+ *
139+ * Files that begin with "." are ignored.
140+ *
141+ * @see #getExtension
142+ * @see FileFilter#accepts
143+ */
144+ @Override
145+ public boolean accept(File f) {
146+ if(f != null) {
147+ if(f.isDirectory()) {
148+ return true;
149+ }
150+ String extension = getExtension(f);
151+ if(extension != null && filters.get(getExtension(f)) != null) {
152+ return true;
153+ };
154+ }
155+ return false;
156+ }
157+
158+ /**
159+ * Return the extension portion of the file's name .
160+ *
161+ * @see #getExtension
162+ * @see FileFilter#accept
163+ */
164+ public String getExtension(File f) {
165+ if(f != null) {
166+ String filename = f.getName();
167+ int i = filename.lastIndexOf('.');
168+ if(i>0 && i<filename.length()-1) {
169+ return filename.substring(i+1).toLowerCase();
170+ };
171+ }
172+ return null;
173+ }
174+
175+ /**
176+ * Adds a filetype "dot" extension to filter against.
177+ *
178+ * For example: the following code will create a filter that filters
179+ * out all files except those that end in ".jpg" and ".tif":
180+ *
181+ * JDBFileFilter filter = new JDBFileFilter();
182+ * filter.addExtension("jpg");
183+ * filter.addExtension("tif");
184+ *
185+ * Note that the "." before the extension is not needed and will be ignored.
186+ */
187+ public void addExtension(String extension) {
188+ if(filters == null) {
189+ filters = new Hashtable<String, JDBFileFilter>(5);
190+ }
191+ filters.put(extension.toLowerCase(), this);
192+ fullDescription = null;
193+ }
194+
195+
196+ /**
197+ * Returns the human readable description of this filter. For
198+ * example: "JPEG and GIF Image Files (*.jpg, *.gif)"
199+ *
200+ * @see setDescription
201+ * @see setExtensionListInDescription
202+ * @see isExtensionListInDescription
203+ * @see FileFilter#getDescription
204+ */
205+ @Override
206+ public String getDescription() {
207+ if(fullDescription == null) {
208+ if(description == null || isExtensionListInDescription()) {
209+ fullDescription = description==null ? "(" : description + " (";
210+ // build the description from the extension list
211+ Enumeration<String> extensions = filters.keys();
212+ if(extensions != null) {
213+ fullDescription += "." + extensions.nextElement();
214+ while (extensions.hasMoreElements()) {
215+ fullDescription += ", " + extensions.nextElement();
216+ }
217+ }
218+ fullDescription += ")";
219+ } else {
220+ fullDescription = description;
221+ }
222+ }
223+ return fullDescription;
224+ }
225+
226+ /**
227+ * Sets the human readable description of this filter. For
228+ * example: filter.setDescription("Gif and JPG Images");
229+ *
230+ * @see setDescription
231+ * @see setExtensionListInDescription
232+ * @see isExtensionListInDescription
233+ */
234+ public void setDescription(String description) {
235+ this.description = description;
236+ fullDescription = null;
237+ }
238+
239+ /**
240+ * Determines whether the extension list (.jpg, .gif, etc) should
241+ * show up in the human readable description.
242+ *
243+ * Only relevent if a description was provided in the constructor
244+ * or using setDescription();
245+ *
246+ * @see getDescription
247+ * @see setDescription
248+ * @see isExtensionListInDescription
249+ */
250+ public void setExtensionListInDescription(boolean b) {
251+ useExtensionsInDescription = b;
252+ fullDescription = null;
253+ }
254+
255+ /**
256+ * Returns whether the extension list (.jpg, .gif, etc) should
257+ * show up in the human readable description.
258+ *
259+ * Only relevent if a description was provided in the constructor
260+ * or using setDescription();
261+ *
262+ * @see getDescription
263+ * @see setDescription
264+ * @see setExtensionListInDescription
265+ */
266+ public boolean isExtensionListInDescription() {
267+ return useExtensionsInDescription;
268+ }
269+}
java/pkg/com/sun/tools/example/debug/gui/JDBMenuBar.java+190−0
@@ -0,0 +1,190 @@
1+/*
2+ * Copyright (c) 1998, 1999, Oracle and/or its affiliates. All rights reserved.
3+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+ *
5+ * This code is free software; you can redistribute it and/or modify it
6+ * under the terms of the GNU General Public License version 2 only, as
7+ * published by the Free Software Foundation. Oracle designates this
8+ * particular file as subject to the "Classpath" exception as provided
9+ * by Oracle in the LICENSE file that accompanied this code.
10+ *
11+ * This code is distributed in the hope that it will be useful, but WITHOUT
12+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+ * version 2 for more details (a copy is included in the LICENSE file that
15+ * accompanied this code).
16+ *
17+ * You should have received a copy of the GNU General Public License version
18+ * 2 along with this work; if not, write to the Free Software Foundation,
19+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+ *
21+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+ * or visit www.oracle.com if you need additional information or have any
23+ * questions.
24+ */
25+
26+package com.sun.tools.example.debug.gui;
27+
28+import javax.swing.*;
29+import java.awt.*;
30+import java.awt.event.*;
31+import java.util.Vector;
32+import java.util.List;
33+
34+import com.sun.tools.example.debug.bdi.*;
35+
36+//### This is currently just a placeholder!
37+
38+class JDBMenuBar extends JMenuBar {
39+
40+ Environment env;
41+
42+ ExecutionManager runtime;
43+ ClassManager classManager;
44+ SourceManager sourceManager;
45+
46+ CommandInterpreter interpreter;
47+
48+ JDBMenuBar(Environment env) {
49+ this.env = env;
50+ this.runtime = env.getExecutionManager();
51+ this.classManager = env.getClassManager();
52+ this.sourceManager = env.getSourceManager();
53+ this.interpreter = new CommandInterpreter(env, true);
54+
55+ JMenu fileMenu = new JMenu("File");
56+
57+ JMenuItem openItem = new JMenuItem("Open...", 'O');
58+ openItem.addActionListener(new ActionListener() {
59+ @Override
60+ public void actionPerformed(ActionEvent e) {
61+ openCommand();
62+ }
63+ });
64+ fileMenu.add(openItem);
65+ addTool(fileMenu, "Exit debugger", "Exit", "exit");
66+
67+ JMenu cmdMenu = new JMenu("Commands");
68+
69+ addTool(cmdMenu, "Step into next line", "Step", "step");
70+ addTool(cmdMenu, "Step over next line", "Next", "next");
71+ cmdMenu.addSeparator();
72+
73+ addTool(cmdMenu, "Step into next instruction",
74+ "Step Instruction", "stepi");
75+ addTool(cmdMenu, "Step over next instruction",
76+ "Next Instruction", "nexti");
77+ cmdMenu.addSeparator();
78+
79+ addTool(cmdMenu, "Step out of current method call",
80+ "Step Up", "step up");
81+ cmdMenu.addSeparator();
82+
83+ addTool(cmdMenu, "Suspend execution", "Interrupt", "interrupt");
84+ addTool(cmdMenu, "Continue execution", "Continue", "cont");
85+ cmdMenu.addSeparator();
86+
87+ addTool(cmdMenu, "Display current stack", "Where", "where");
88+ cmdMenu.addSeparator();
89+
90+ addTool(cmdMenu, "Move up one stack frame", "Up", "up");
91+ addTool(cmdMenu, "Move down one stack frame", "Down", "down");
92+ cmdMenu.addSeparator();
93+
94+ JMenuItem monitorItem = new JMenuItem("Monitor Expression...", 'M');
95+ monitorItem.addActionListener(new ActionListener() {
96+ @Override
97+ public void actionPerformed(ActionEvent e) {
98+ monitorCommand();
99+ }
100+ });
101+ cmdMenu.add(monitorItem);
102+
103+ JMenuItem unmonitorItem = new JMenuItem("Unmonitor Expression...");
104+ unmonitorItem.addActionListener(new ActionListener() {
105+ @Override
106+ public void actionPerformed(ActionEvent e) {
107+ unmonitorCommand();
108+ }
109+ });
110+ cmdMenu.add(unmonitorItem);
111+
112+ JMenu breakpointMenu = new JMenu("Breakpoint");
113+ JMenuItem stopItem = new JMenuItem("Stop in...", 'S');
114+ stopItem.addActionListener(new ActionListener() {
115+ @Override
116+ public void actionPerformed(ActionEvent e) {
117+ buildBreakpoint();
118+ }
119+ });
120+ breakpointMenu.add(stopItem);
121+
122+ JMenu helpMenu = new JMenu("Help");
123+ addTool(helpMenu, "Display command list", "Help", "help");
124+
125+ this.add(fileMenu);
126+ this.add(cmdMenu);
127+// this.add(breakpointMenu);
128+ this.add(helpMenu);
129+ }
130+
131+ private void buildBreakpoint() {
132+ Frame frame = JOptionPane.getRootFrame();
133+ JDialog dialog = new JDialog(frame, "Specify Breakpoint");
134+ Container contents = dialog.getContentPane();
135+ Vector<String> classes = new Vector<String>();
136+ classes.add("Foo");
137+ classes.add("Bar");
138+ JList list = new JList(classes);
139+ JScrollPane scrollPane = new JScrollPane(list);
140+ contents.add(scrollPane);
141+ dialog.show();
142+
143+ }
144+
145+ private void monitorCommand() {
146+ String expr = (String)JOptionPane.showInputDialog(null,
147+ "Expression to monitor:", "Add Monitor",
148+ JOptionPane.QUESTION_MESSAGE, null, null, null);
149+ if (expr != null) {
150+ interpreter.executeCommand("monitor " + expr);
151+ }
152+ }
153+
154+ private void unmonitorCommand() {
155+ List monitors = env.getMonitorListModel().monitors();
156+ String expr = (String)JOptionPane.showInputDialog(null,
157+ "Expression to unmonitor:", "Remove Monitor",
158+ JOptionPane.QUESTION_MESSAGE, null,
159+ monitors.toArray(),
160+ monitors.get(monitors.size()-1));
161+ if (expr != null) {
162+ interpreter.executeCommand("unmonitor " + expr);
163+ }
164+ }
165+
166+ private void openCommand() {
167+ JFileChooser chooser = new JFileChooser();
168+ JDBFileFilter filter = new JDBFileFilter("java", "Java source code");
169+ chooser.setFileFilter(filter);
170+ int result = chooser.showOpenDialog(this);
171+ if (result == JFileChooser.APPROVE_OPTION) {
172+ System.out.println("Chose file: " + chooser.getSelectedFile().getName());
173+ }
174+ }
175+
176+ private void addTool(JMenu menu, String toolTip, String labelText,
177+ String command) {
178+ JMenuItem mi = new JMenuItem(labelText);
179+ mi.setToolTipText(toolTip);
180+ final String cmd = command;
181+ mi.addActionListener(new ActionListener() {
182+ @Override
183+ public void actionPerformed(ActionEvent e) {
184+ interpreter.executeCommand(cmd);
185+ }
186+ });
187+ menu.add(mi);
188+ }
189+
190+}
java/pkg/com/sun/tools/example/debug/gui/JDBToolBar.java+101−0
@@ -0,0 +1,101 @@
1+/*
2+ * Copyright (c) 1998, 1999, Oracle and/or its affiliates. All rights reserved.
3+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+ *
5+ * This code is free software; you can redistribute it and/or modify it
6+ * under the terms of the GNU General Public License version 2 only, as
7+ * published by the Free Software Foundation. Oracle designates this
8+ * particular file as subject to the "Classpath" exception as provided
9+ * by Oracle in the LICENSE file that accompanied this code.
10+ *
11+ * This code is distributed in the hope that it will be useful, but WITHOUT
12+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+ * version 2 for more details (a copy is included in the LICENSE file that
15+ * accompanied this code).
16+ *
17+ * You should have received a copy of the GNU General Public License version
18+ * 2 along with this work; if not, write to the Free Software Foundation,
19+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+ *
21+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+ * or visit www.oracle.com if you need additional information or have any
23+ * questions.
24+ */
25+
26+package com.sun.tools.example.debug.gui;
27+
28+import javax.swing.*;
29+import java.awt.event.*;
30+
31+import com.sun.tools.example.debug.bdi.*;
32+
33+class JDBToolBar extends JToolBar {
34+
35+ Environment env;
36+
37+ ExecutionManager runtime;
38+ ClassManager classManager;
39+ SourceManager sourceManager;
40+
41+ CommandInterpreter interpreter;
42+
43+ JDBToolBar(Environment env) {
44+
45+ this.env = env;
46+ this.runtime = env.getExecutionManager();
47+ this.classManager = env.getClassManager();
48+ this.sourceManager = env.getSourceManager();
49+ this.interpreter = new CommandInterpreter(env, true);
50+
51+ //===== Configure toolbar here =====
52+
53+ addTool("Run application", "run", "run");
54+ addTool("Connect to application", "connect", "connect");
55+ addSeparator();
56+
57+ addTool("Step into next line", "step", "step");
58+ addTool("Step over next line", "next", "next");
59+// addSeparator();
60+
61+// addTool("Step into next instruction", "stepi", "stepi");
62+// addTool("Step over next instruction", "nexti", "nexti");
63+// addSeparator();
64+
65+ addTool("Step out of current method call", "step up", "step up");
66+ addSeparator();
67+
68+ addTool("Suspend execution", "interrupt", "interrupt");
69+ addTool("Continue execution", "cont", "cont");
70+ addSeparator();
71+
72+// addTool("Display current stack", "where", "where");
73+// addSeparator();
74+
75+ addTool("Move up one stack frame", "up", "up");
76+ addTool("Move down one stack frame", "down", "down");
77+// addSeparator();
78+
79+// addTool("Display command list", "help", "help");
80+// addSeparator();
81+
82+// addTool("Exit debugger", "exit", "exit");
83+
84+ //==================================
85+
86+ }
87+
88+ private void addTool(String toolTip, String labelText, String command) {
89+ JButton button = new JButton(labelText);
90+ button.setToolTipText(toolTip);
91+ final String cmd = command;
92+ button.addActionListener(new ActionListener() {
93+ @Override
94+ public void actionPerformed(ActionEvent e) {
95+ interpreter.executeCommand(cmd);
96+ }
97+ });
98+ this.add(button);
99+ }
100+
101+}
java/pkg/com/sun/tools/example/debug/gui/LaunchTool.java+263−0
@@ -0,0 +1,263 @@
1+/*
2+ * Copyright (c) 1999, 2008, Oracle and/or its affiliates. All rights reserved.
3+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+ *
5+ * This code is free software; you can redistribute it and/or modify it
6+ * under the terms of the GNU General Public License version 2 only, as
7+ * published by the Free Software Foundation. Oracle designates this
8+ * particular file as subject to the "Classpath" exception as provided
9+ * by Oracle in the LICENSE file that accompanied this code.
10+ *
11+ * This code is distributed in the hope that it will be useful, but WITHOUT
12+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+ * version 2 for more details (a copy is included in the LICENSE file that
15+ * accompanied this code).
16+ *
17+ * You should have received a copy of the GNU General Public License version
18+ * 2 along with this work; if not, write to the Free Software Foundation,
19+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+ *
21+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+ * or visit www.oracle.com if you need additional information or have any
23+ * questions.
24+ */
25+
26+package com.sun.tools.example.debug.gui;
27+
28+import java.util.List;
29+import java.util.ArrayList;
30+import java.util.Map;
31+import java.util.HashMap;
32+import java.awt.BorderLayout;
33+import java.awt.Container;
34+import java.awt.event.ActionEvent;
35+import java.awt.event.ActionListener;
36+import javax.swing.*;
37+import javax.swing.border.Border;
38+import javax.swing.border.TitledBorder;
39+
40+import com.sun.jdi.*;
41+import com.sun.jdi.connect.*;
42+
43+import com.sun.tools.example.debug.bdi.*;
44+
45+class LaunchTool {
46+
47+ private final ExecutionManager runtime;
48+
49+ private abstract class ArgRep {
50+ final Connector.Argument arg;
51+ final JPanel panel;
52+
53+ ArgRep(Connector.Argument arg) {
54+ this.arg = arg;
55+ panel = new JPanel();
56+ Border etched = BorderFactory.createEtchedBorder();
57+ Border titled = BorderFactory.createTitledBorder(etched,
58+ arg.description(),
59+ TitledBorder.LEFT, TitledBorder.TOP);
60+ panel.setBorder(titled);
61+ }
62+
63+ abstract String getText();
64+
65+ boolean isValid() {
66+ return arg.isValid(getText());
67+ }
68+
69+ boolean isSpecified() {
70+ String value = getText();
71+ return (value != null && value.length() > 0) ||
72+ !arg.mustSpecify();
73+ }
74+
75+ void install() {
76+ arg.setValue(getText());
77+ }
78+ }
79+
80+ private class StringArgRep extends ArgRep {
81+ final JTextField textField;
82+
83+ StringArgRep(Connector.Argument arg, JPanel comp) {
84+ super(arg);
85+ textField = new JTextField(arg.value(), 50 );
86+ textField.setBorder(BorderFactory.createLoweredBevelBorder());
87+
88+ panel.add(new JLabel(arg.label(), SwingConstants.RIGHT));
89+ panel.add(textField); // , BorderLayout.CENTER);
90+ comp.add(panel);
91+ }
92+
93+ @Override
94+ String getText() {
95+ return textField.getText();
96+ }
97+ }
98+
99+ private class BooleanArgRep extends ArgRep {
100+ final JCheckBox check;
101+
102+ BooleanArgRep(Connector.BooleanArgument barg, JPanel comp) {
103+ super(barg);
104+ check = new JCheckBox(barg.label());
105+ check.setSelected(barg.booleanValue());
106+ panel.add(check);
107+ comp.add(panel);
108+ }
109+
110+ @Override
111+ String getText() {
112+ return ((Connector.BooleanArgument)arg)
113+ .stringValueOf(check.getModel().isSelected());
114+ }
115+ }
116+
117+
118+ private LaunchTool(ExecutionManager runtime) {
119+ this.runtime = runtime;
120+ }
121+
122+ private Connector selectConnector() {
123+ final JDialog dialog = new JDialog();
124+ Container content = dialog.getContentPane();
125+ final JPanel radioPanel = new JPanel();
126+ final ButtonGroup radioGroup = new ButtonGroup();
127+ VirtualMachineManager manager = Bootstrap.virtualMachineManager();
128+ List<Connector> all = manager.allConnectors();
129+ Map<ButtonModel, Connector> modelToConnector = new HashMap<ButtonModel, Connector>(all.size(), 0.5f);
130+
131+ dialog.setModal(true);
132+ dialog.setTitle("Select Connector Type");
133+ radioPanel.setLayout(new BoxLayout(radioPanel, BoxLayout.Y_AXIS));
134+ for (Connector connector : all) {
135+ JRadioButton radio = new JRadioButton(connector.description());
136+ modelToConnector.put(radio.getModel(), connector);
137+ radioPanel.add(radio);
138+ radioGroup.add(radio);
139+ }
140+ content.add(radioPanel);
141+
142+ final boolean[] oked = {false};
143+ JPanel buttonPanel = okCancel( dialog, new ActionListener() {
144+ @Override
145+ public void actionPerformed(ActionEvent event) {
146+ if (radioGroup.getSelection() == null) {
147+ JOptionPane.showMessageDialog(dialog,
148+ "Please select a connector type",
149+ "No Selection",
150+ JOptionPane.ERROR_MESSAGE);
151+ } else {
152+ oked[0] = true;
153+ dialog.setVisible(false);
154+ dialog.dispose();
155+ }
156+ }
157+ } );
158+ content.add(BorderLayout.SOUTH, buttonPanel);
159+ dialog.pack();
160+ dialog.setVisible(true);
161+
162+ return oked[0] ?
163+ modelToConnector.get(radioGroup.getSelection()) :
164+ null;
165+ }
166+
167+ private void configureAndConnect(final Connector connector) {
168+ final JDialog dialog = new JDialog();
169+ final Map<String, Connector.Argument> args = connector.defaultArguments();
170+
171+ dialog.setModal(true);
172+ dialog.setTitle("Connector Arguments");
173+ Container content = dialog.getContentPane();
174+ JPanel guts = new JPanel();
175+ Border etched = BorderFactory.createEtchedBorder();
176+ BorderFactory.createTitledBorder(etched,
177+ connector.description(),
178+ TitledBorder.LEFT, TitledBorder.TOP);
179+ guts.setBorder(etched);
180+ guts.setLayout(new BoxLayout(guts, BoxLayout.Y_AXIS));
181+
182+ // guts.add(new JLabel(connector.description()));
183+
184+ final List<ArgRep> argReps = new ArrayList<ArgRep>(args.size());
185+ for (Connector.Argument arg : args.values()) {
186+ ArgRep ar;
187+ if (arg instanceof Connector.BooleanArgument) {
188+ ar = new BooleanArgRep((Connector.BooleanArgument)arg, guts);
189+ } else {
190+ ar = new StringArgRep(arg, guts);
191+ }
192+ argReps.add(ar);
193+ }
194+ content.add(guts);
195+
196+ JPanel buttonPanel = okCancel( dialog, new ActionListener() {
197+ @Override
198+ public void actionPerformed(ActionEvent event) {
199+ for (ArgRep ar : argReps) {
200+ if (!ar.isSpecified()) {
201+ JOptionPane.showMessageDialog(dialog,
202+ ar.arg.label() +
203+ ": Argument must be specified",
204+ "No argument", JOptionPane.ERROR_MESSAGE);
205+ return;
206+ }
207+ if (!ar.isValid()) {
208+ JOptionPane.showMessageDialog(dialog,
209+ ar.arg.label() +
210+ ": Bad argument value: " +
211+ ar.getText(),
212+ "Bad argument", JOptionPane.ERROR_MESSAGE);
213+ return;
214+ }
215+ ar.install();
216+ }
217+ try {
218+ if (runtime.explictStart(connector, args)) {
219+ dialog.setVisible(false);
220+ dialog.dispose();
221+ } else {
222+ JOptionPane.showMessageDialog(dialog,
223+ "Bad arguments values: See diagnostics window.",
224+ "Bad arguments", JOptionPane.ERROR_MESSAGE);
225+ }
226+ } catch (VMLaunchFailureException exc) {
227+ JOptionPane.showMessageDialog(dialog,
228+ "Launch Failure: " + exc,
229+ "Launch Failed",JOptionPane.ERROR_MESSAGE);
230+ }
231+ }
232+ } );
233+ content.add(BorderLayout.SOUTH, buttonPanel);
234+ dialog.pack();
235+ dialog.setVisible(true);
236+ }
237+
238+ private JPanel okCancel(final JDialog dialog, ActionListener okListener) {
239+ JPanel buttonPanel = new JPanel();
240+ JButton ok = new JButton("OK");
241+ JButton cancel = new JButton("Cancel");
242+ buttonPanel.add(ok);
243+ buttonPanel.add(cancel);
244+ ok.addActionListener(okListener);
245+ cancel.addActionListener( new ActionListener() {
246+ @Override
247+ public void actionPerformed(ActionEvent event) {
248+ dialog.setVisible(false);
249+ dialog.dispose();
250+ }
251+ } );
252+ return buttonPanel;
253+ }
254+
255+ static void queryAndLaunchVM(ExecutionManager runtime)
256+ throws VMLaunchFailureException {
257+ LaunchTool lt = new LaunchTool(runtime);
258+ Connector connector = lt.selectConnector();
259+ if (connector != null) {
260+ lt.configureAndConnect(connector);
261+ }
262+ }
263+}
java/pkg/com/sun/tools/example/debug/gui/MonitorListModel.java+90−0
@@ -0,0 +1,90 @@
1+/*
2+ * Copyright (c) 1999, Oracle and/or its affiliates. All rights reserved.
3+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+ *
5+ * This code is free software; you can redistribute it and/or modify it
6+ * under the terms of the GNU General Public License version 2 only, as
7+ * published by the Free Software Foundation. Oracle designates this
8+ * particular file as subject to the "Classpath" exception as provided
9+ * by Oracle in the LICENSE file that accompanied this code.
10+ *
11+ * This code is distributed in the hope that it will be useful, but WITHOUT
12+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+ * version 2 for more details (a copy is included in the LICENSE file that
15+ * accompanied this code).
16+ *
17+ * You should have received a copy of the GNU General Public License version
18+ * 2 along with this work; if not, write to the Free Software Foundation,
19+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+ *
21+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+ * or visit www.oracle.com if you need additional information or have any
23+ * questions.
24+ */
25+
26+package com.sun.tools.example.debug.gui;
27+
28+import java.util.*;
29+
30+import javax.swing.AbstractListModel;
31+
32+public class MonitorListModel extends AbstractListModel {
33+
34+ private final List<String> monitors = new ArrayList<String>();
35+
36+ MonitorListModel(Environment env) {
37+
38+ // Create listener.
39+ MonitorListListener listener = new MonitorListListener();
40+ env.getContextManager().addContextListener(listener);
41+
42+ //### remove listeners on exit!
43+ }
44+
45+ @Override
46+ public Object getElementAt(int index) {
47+ return monitors.get(index);
48+ }
49+
50+ @Override
51+ public int getSize() {
52+ return monitors.size();
53+ }
54+
55+ public void add(String expr) {
56+ monitors.add(expr);
57+ int newIndex = monitors.size()-1; // order important
58+ fireIntervalAdded(this, newIndex, newIndex);
59+ }
60+
61+ public void remove(String expr) {
62+ int index = monitors.indexOf(expr);
63+ remove(index);
64+ }
65+
66+ public void remove(int index) {
67+ monitors.remove(index);
68+ fireIntervalRemoved(this, index, index);
69+ }
70+
71+ public List<String> monitors() {
72+ return Collections.unmodifiableList(monitors);
73+ }
74+
75+ public Iterator<?> iterator() {
76+ return monitors().iterator();
77+ }
78+
79+ private void invalidate() {
80+ fireContentsChanged(this, 0, monitors.size()-1);
81+ }
82+
83+ private class MonitorListListener implements ContextListener {
84+
85+ @Override
86+ public void currentFrameChanged(final CurrentFrameChangedEvent e) {
87+ invalidate();
88+ }
89+ }
90+}
java/pkg/com/sun/tools/example/debug/gui/MonitorTool.java+125−0
@@ -0,0 +1,125 @@
1+/*
2+ * Copyright (c) 1999, Oracle and/or its affiliates. All rights reserved.
3+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+ *
5+ * This code is free software; you can redistribute it and/or modify it
6+ * under the terms of the GNU General Public License version 2 only, as
7+ * published by the Free Software Foundation. Oracle designates this
8+ * particular file as subject to the "Classpath" exception as provided
9+ * by Oracle in the LICENSE file that accompanied this code.
10+ *
11+ * This code is distributed in the hope that it will be useful, but WITHOUT
12+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+ * version 2 for more details (a copy is included in the LICENSE file that
15+ * accompanied this code).
16+ *
17+ * You should have received a copy of the GNU General Public License version
18+ * 2 along with this work; if not, write to the Free Software Foundation,
19+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+ *
21+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+ * or visit www.oracle.com if you need additional information or have any
23+ * questions.
24+ */
25+
26+package com.sun.tools.example.debug.gui;
27+
28+import javax.swing.*;
29+import javax.swing.event.*;
30+import java.awt.*;
31+import com.sun.jdi.*;
32+import com.sun.tools.example.debug.bdi.*;
33+import com.sun.tools.example.debug.expr.ExpressionParser;
34+import com.sun.tools.example.debug.expr.ParseException;
35+
36+public class MonitorTool extends JPanel {
37+
38+ private static final long serialVersionUID = -645235951031726647L;
39+ private ExecutionManager runtime;
40+ private ContextManager context;
41+
42+ private JList list;
43+
44+ public MonitorTool(Environment env) {
45+ super(new BorderLayout());
46+ this.runtime = env.getExecutionManager();
47+ this.context = env.getContextManager();
48+
49+ list = new JList(env.getMonitorListModel());
50+ list.setCellRenderer(new MonitorRenderer());
51+
52+ JScrollPane listView = new JScrollPane(list);
53+ add(listView);
54+
55+ // Create listener.
56+ MonitorToolListener listener = new MonitorToolListener();
57+ list.addListSelectionListener(listener);
58+ //### remove listeners on exit!
59+ }
60+
61+ private class MonitorToolListener implements ListSelectionListener {
62+ @Override
63+ public void valueChanged(ListSelectionEvent e) {
64+ int index = list.getSelectedIndex();
65+ if (index != -1) {
66+ }
67+ }
68+ }
69+
70+ private Value evaluate(String expr) throws ParseException,
71+ InvocationException,
72+ InvalidTypeException,
73+ ClassNotLoadedException,
74+ IncompatibleThreadStateException {
75+ ExpressionParser.GetFrame frameGetter =
76+ new ExpressionParser.GetFrame() {
77+ @Override
78+ public StackFrame get()
79+ throws IncompatibleThreadStateException
80+ {
81+ try {
82+ return context.getCurrentFrame();
83+ } catch (VMNotInterruptedException exc) {
84+ throw new IncompatibleThreadStateException();
85+ }
86+ }
87+ };
88+ return ExpressionParser.evaluate(expr, runtime.vm(), frameGetter);
89+ }
90+
91+ private class MonitorRenderer extends DefaultListCellRenderer {
92+
93+ @Override
94+ public Component getListCellRendererComponent(JList list,
95+ Object value,
96+ int index,
97+ boolean isSelected,
98+ boolean cellHasFocus) {
99+
100+ //### We should indicate the current thread independently of the
101+ //### selection, e.g., with an icon, because the user may change
102+ //### the selection graphically without affecting the current
103+ //### thread.
104+
105+ super.getListCellRendererComponent(list, value, index,
106+ isSelected, cellHasFocus);
107+ if (value == null) {
108+ this.setText("<unavailable>");
109+ } else {
110+ String expr = (String)value;
111+ try {
112+ Value result = evaluate(expr);
113+ this.setText(expr + " = " + result);
114+ } catch (ParseException exc) {
115+ this.setText(expr + " ? " + exc.getMessage());
116+ } catch (IncompatibleThreadStateException exc) {
117+ this.setText(expr + " ...");
118+ } catch (Exception exc) {
119+ this.setText(expr + " ? " + exc);
120+ }
121+ }
122+ return this;
123+ }
124+ }
125+}
java/pkg/com/sun/tools/example/debug/gui/OutputSink.java+46−0
@@ -0,0 +1,46 @@
1+/*
2+ * Copyright (c) 1998, 1999, Oracle and/or its affiliates. All rights reserved.
3+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+ *
5+ * This code is free software; you can redistribute it and/or modify it
6+ * under the terms of the GNU General Public License version 2 only, as
7+ * published by the Free Software Foundation. Oracle designates this
8+ * particular file as subject to the "Classpath" exception as provided
9+ * by Oracle in the LICENSE file that accompanied this code.
10+ *
11+ * This code is distributed in the hope that it will be useful, but WITHOUT
12+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+ * version 2 for more details (a copy is included in the LICENSE file that
15+ * accompanied this code).
16+ *
17+ * You should have received a copy of the GNU General Public License version
18+ * 2 along with this work; if not, write to the Free Software Foundation,
19+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+ *
21+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+ * or visit www.oracle.com if you need additional information or have any
23+ * questions.
24+ */
25+
26+package com.sun.tools.example.debug.gui;
27+
28+import java.io.*;
29+
30+// This class is used in 'CommandInterpreter' as a hook to
31+// allow messagebox style command output as an alternative
32+// to a typescript. It should be an interface, not a class.
33+
34+public class OutputSink extends PrintWriter {
35+
36+ // Currently, we do no buffering,
37+ // so 'show' is a no-op.
38+
39+ OutputSink(Writer writer) {
40+ super(writer);
41+ }
42+
43+ public void show() {
44+ // ignore
45+ }
46+}
java/pkg/com/sun/tools/example/debug/gui/SearchPath.java+95−0
@@ -0,0 +1,95 @@
1+/*
2+ * Copyright (c) 1998, 2008, Oracle and/or its affiliates. All rights reserved.
3+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+ *
5+ * This code is free software; you can redistribute it and/or modify it
6+ * under the terms of the GNU General Public License version 2 only, as
7+ * published by the Free Software Foundation. Oracle designates this
8+ * particular file as subject to the "Classpath" exception as provided
9+ * by Oracle in the LICENSE file that accompanied this code.
10+ *
11+ * This code is distributed in the hope that it will be useful, but WITHOUT
12+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+ * version 2 for more details (a copy is included in the LICENSE file that
15+ * accompanied this code).
16+ *
17+ * You should have received a copy of the GNU General Public License version
18+ * 2 along with this work; if not, write to the Free Software Foundation,
19+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+ *
21+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+ * or visit www.oracle.com if you need additional information or have any
23+ * questions.
24+ */
25+
26+package com.sun.tools.example.debug.gui;
27+
28+import java.io.*;
29+import java.util.*;
30+
31+public class SearchPath {
32+
33+ private String pathString;
34+
35+ private String[] pathArray;
36+
37+ public SearchPath(String searchPath) {
38+ //### Should check searchpath for well-formedness.
39+ StringTokenizer st = new StringTokenizer(searchPath, File.pathSeparator);
40+ List<String> dlist = new ArrayList<String>();
41+ while (st.hasMoreTokens()) {
42+ dlist.add(st.nextToken());
43+ }
44+ pathString = searchPath;
45+ pathArray = dlist.toArray(new String[dlist.size()]);
46+ }
47+
48+ public boolean isEmpty() {
49+ return (pathArray.length == 0);
50+ }
51+
52+ public String asString() {
53+ return pathString;
54+ }
55+
56+ public String[] asArray() {
57+ return pathArray.clone();
58+ }
59+
60+ public File resolve(String relativeFileName) {
61+ for (String element : pathArray) {
62+ File path = new File(element, relativeFileName);
63+ if (path.exists()) {
64+ return path;
65+ }
66+ }
67+ return null;
68+ }
69+
70+ //### return List?
71+
72+ public String[] children(String relativeDirName, FilenameFilter filter) {
73+ // If a file appears at the same relative path
74+ // with respect to multiple entries on the classpath,
75+ // the one corresponding to the earliest entry on the
76+ // classpath is retained. This is the one that will be
77+ // found if we later do a 'resolve'.
78+ SortedSet<String> s = new TreeSet<String>(); // sorted, no duplicates
79+ for (String element : pathArray) {
80+ File path = new File(element, relativeDirName);
81+ if (path.exists()) {
82+ String[] childArray = path.list(filter);
83+ if (childArray != null) {
84+ for (int j = 0; j < childArray.length; j++) {
85+ if (!s.contains(childArray[j])) {
86+ s.add(childArray[j]);
87+ }
88+ }
89+ }
90+ }
91+ }
92+ return s.toArray(new String[s.size()]);
93+ }
94+
95+}
java/pkg/com/sun/tools/example/debug/gui/SingleLeafTreeSelectionModel.java+70−0
@@ -0,0 +1,70 @@
1+/*
2+ * Copyright (c) 1998, 1999, Oracle and/or its affiliates. All rights reserved.
3+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+ *
5+ * This code is free software; you can redistribute it and/or modify it
6+ * under the terms of the GNU General Public License version 2 only, as
7+ * published by the Free Software Foundation. Oracle designates this
8+ * particular file as subject to the "Classpath" exception as provided
9+ * by Oracle in the LICENSE file that accompanied this code.
10+ *
11+ * This code is distributed in the hope that it will be useful, but WITHOUT
12+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+ * version 2 for more details (a copy is included in the LICENSE file that
15+ * accompanied this code).
16+ *
17+ * You should have received a copy of the GNU General Public License version
18+ * 2 along with this work; if not, write to the Free Software Foundation,
19+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+ *
21+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+ * or visit www.oracle.com if you need additional information or have any
23+ * questions.
24+ */
25+
26+package com.sun.tools.example.debug.gui;
27+
28+import javax.swing.tree.*;
29+
30+public class SingleLeafTreeSelectionModel extends DefaultTreeSelectionModel {
31+
32+ private static final long serialVersionUID = -7849105107888117679L;
33+
34+ SingleLeafTreeSelectionModel() {
35+ super();
36+ selectionMode = SINGLE_TREE_SELECTION;
37+ }
38+
39+ @Override
40+ public void setSelectionPath(TreePath path) {
41+ if(((TreeNode)(path.getLastPathComponent())).isLeaf()) {
42+ super.setSelectionPath(path);
43+ }
44+ }
45+
46+ @Override
47+ public void setSelectionPaths(TreePath[] paths) {
48+ // Only look at first path, as all others will be
49+ // ignored anyway in single tree selection mode.
50+ if(((TreeNode)(paths[0].getLastPathComponent())).isLeaf()) {
51+ super.setSelectionPaths(paths);
52+ }
53+ }
54+
55+ @Override
56+ public void addSelectionPath(TreePath path) {
57+ if(((TreeNode)(path.getLastPathComponent())).isLeaf()) {
58+ super.setSelectionPath(path);
59+ }
60+ }
61+
62+ @Override
63+ public void addSelectionPaths(TreePath[] paths) {
64+ // Only look at first path, as all others will be
65+ // ignored anyway in single tree selection mode.
66+ if(((TreeNode)(paths[0].getLastPathComponent())).isLeaf()) {
67+ super.addSelectionPaths(paths);
68+ }
69+ }
70+}
java/pkg/com/sun/tools/example/debug/gui/SourceListener.java+30−0
@@ -0,0 +1,30 @@
1+/*
2+ * Copyright (c) 1998, 1999, Oracle and/or its affiliates. All rights reserved.
3+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+ *
5+ * This code is free software; you can redistribute it and/or modify it
6+ * under the terms of the GNU General Public License version 2 only, as
7+ * published by the Free Software Foundation. Oracle designates this
8+ * particular file as subject to the "Classpath" exception as provided
9+ * by Oracle in the LICENSE file that accompanied this code.
10+ *
11+ * This code is distributed in the hope that it will be useful, but WITHOUT
12+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+ * version 2 for more details (a copy is included in the LICENSE file that
15+ * accompanied this code).
16+ *
17+ * You should have received a copy of the GNU General Public License version
18+ * 2 along with this work; if not, write to the Free Software Foundation,
19+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+ *
21+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+ * or visit www.oracle.com if you need additional information or have any
23+ * questions.
24+ */
25+
26+package com.sun.tools.example.debug.gui;
27+
28+public interface SourceListener {
29+ void sourcepathChanged(SourcepathChangedEvent e);
30+}
java/pkg/com/sun/tools/example/debug/gui/SourceManager.java+180−0
@@ -0,0 +1,180 @@
1+/*
2+ * Copyright (c) 1998, 2008, Oracle and/or its affiliates. All rights reserved.
3+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+ *
5+ * This code is free software; you can redistribute it and/or modify it
6+ * under the terms of the GNU General Public License version 2 only, as
7+ * published by the Free Software Foundation. Oracle designates this
8+ * particular file as subject to the "Classpath" exception as provided
9+ * by Oracle in the LICENSE file that accompanied this code.
10+ *
11+ * This code is distributed in the hope that it will be useful, but WITHOUT
12+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+ * version 2 for more details (a copy is included in the LICENSE file that
15+ * accompanied this code).
16+ *
17+ * You should have received a copy of the GNU General Public License version
18+ * 2 along with this work; if not, write to the Free Software Foundation,
19+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+ *
21+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+ * or visit www.oracle.com if you need additional information or have any
23+ * questions.
24+ */
25+
26+package com.sun.tools.example.debug.gui;
27+
28+import java.io.*;
29+import java.util.*;
30+
31+import com.sun.jdi.*;
32+
33+import com.sun.tools.example.debug.event.*;
34+
35+/**
36+ * Manage the list of source files.
37+ * Origin of SourceListener events.
38+ */
39+public class SourceManager {
40+
41+ //### TODO: The source cache should be aged, and some cap
42+ //### put on memory consumption by source files loaded into core.
43+
44+ private List<SourceModel> sourceList;
45+ private SearchPath sourcePath;
46+
47+ private ArrayList<SourceListener> sourceListeners = new ArrayList<SourceListener>();
48+
49+ private Map<ReferenceType, SourceModel> classToSource = new HashMap<ReferenceType, SourceModel>();
50+
51+ private Environment env;
52+
53+ /**
54+ * Hold on to it so it can be removed.
55+ */
56+ private SMClassListener classListener = new SMClassListener();
57+
58+ public SourceManager(Environment env) {
59+ this(env, new SearchPath(""));
60+ }
61+
62+ public SourceManager(Environment env, SearchPath sourcePath) {
63+ this.env = env;
64+ this.sourceList = new LinkedList<SourceModel>();
65+ this.sourcePath = sourcePath;
66+ env.getExecutionManager().addJDIListener(classListener);
67+ }
68+
69+ /**
70+ * Set path for access to source code.
71+ */
72+ public void setSourcePath(SearchPath sp) {
73+ sourcePath = sp;
74+ // Old cached sources are now invalid.
75+ sourceList = new LinkedList<SourceModel>();
76+ notifySourcepathChanged();
77+ classToSource = new HashMap<ReferenceType, SourceModel>();
78+ }
79+
80+ public void addSourceListener(SourceListener l) {
81+ sourceListeners.add(l);
82+ }
83+
84+ public void removeSourceListener(SourceListener l) {
85+ sourceListeners.remove(l);
86+ }
87+
88+ private void notifySourcepathChanged() {
89+ ArrayList<SourceListener> l = new ArrayList<SourceListener>(sourceListeners);
90+ SourcepathChangedEvent evt = new SourcepathChangedEvent(this);
91+ for (int i = 0; i < l.size(); i++) {
92+ l.get(i).sourcepathChanged(evt);
93+ }
94+ }
95+
96+ /**
97+ * Get path for access to source code.
98+ */
99+ public SearchPath getSourcePath() {
100+ return sourcePath;
101+ }
102+
103+ /**
104+ * Get source object associated with a Location.
105+ */
106+ public SourceModel sourceForLocation(Location loc) {
107+ return sourceForClass(loc.declaringType());
108+ }
109+
110+ /**
111+ * Get source object associated with a class or interface.
112+ * Returns null if not available.
113+ */
114+ public SourceModel sourceForClass(ReferenceType refType) {
115+ SourceModel sm = classToSource.get(refType);
116+ if (sm != null) {
117+ return sm;
118+ }
119+ try {
120+ String filename = refType.sourceName();
121+ String refName = refType.name();
122+ int iDot = refName.lastIndexOf('.');
123+ String pkgName = (iDot >= 0)? refName.substring(0, iDot+1) : "";
124+ String full = pkgName.replace('.', File.separatorChar) + filename;
125+ File path = sourcePath.resolve(full);
126+ if (path != null) {
127+ sm = sourceForFile(path);
128+ classToSource.put(refType, sm);
129+ return sm;
130+ }
131+ return null;
132+ } catch (AbsentInformationException e) {
133+ return null;
134+ }
135+ }
136+
137+ /**
138+ * Get source object associated with an absolute file path.
139+ */
140+ //### Use hash table for this?
141+ public SourceModel sourceForFile(File path) {
142+ Iterator<SourceModel> iter = sourceList.iterator();
143+ SourceModel sm = null;
144+ while (iter.hasNext()) {
145+ SourceModel candidate = iter.next();
146+ if (candidate.fileName().equals(path)) {
147+ sm = candidate;
148+ iter.remove(); // Will move to start of list.
149+ break;
150+ }
151+ }
152+ if (sm == null && path.exists()) {
153+ sm = new SourceModel(env, path);
154+ }
155+ if (sm != null) {
156+ // At start of list for faster access
157+ sourceList.add(0, sm);
158+ }
159+ return sm;
160+ }
161+
162+ private class SMClassListener extends JDIAdapter
163+ implements JDIListener {
164+
165+ @Override
166+ public void classPrepare(ClassPrepareEventSet e) {
167+ ReferenceType refType = e.getReferenceType();
168+ SourceModel sm = sourceForClass(refType);
169+ if (sm != null) {
170+ sm.addClass(refType);
171+ }
172+ }
173+
174+ @Override
175+ public void classUnload(ClassUnloadEventSet e) {
176+ //### iterate through looking for (e.getTypeName()).
177+ //### then remove it.
178+ }
179+ }
180+}
java/pkg/com/sun/tools/example/debug/gui/SourceModel.java+247−0
@@ -0,0 +1,247 @@
1+/*
2+ * Copyright (c) 1998, 2008, Oracle and/or its affiliates. All rights reserved.
3+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+ *
5+ * This code is free software; you can redistribute it and/or modify it
6+ * under the terms of the GNU General Public License version 2 only, as
7+ * published by the Free Software Foundation. Oracle designates this
8+ * particular file as subject to the "Classpath" exception as provided
9+ * by Oracle in the LICENSE file that accompanied this code.
10+ *
11+ * This code is distributed in the hope that it will be useful, but WITHOUT
12+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+ * version 2 for more details (a copy is included in the LICENSE file that
15+ * accompanied this code).
16+ *
17+ * You should have received a copy of the GNU General Public License version
18+ * 2 along with this work; if not, write to the Free Software Foundation,
19+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+ *
21+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+ * or visit www.oracle.com if you need additional information or have any
23+ * questions.
24+ */
25+
26+package com.sun.tools.example.debug.gui;
27+
28+import java.io.*;
29+import java.util.*;
30+
31+import com.sun.jdi.*;
32+import com.sun.jdi.request.*;
33+
34+import javax.swing.*;
35+
36+/**
37+ * Represents and manages one source file.
38+ * Caches source lines. Holds other source file info.
39+ */
40+public class SourceModel extends AbstractListModel {
41+
42+ private File path;
43+
44+ boolean isActuallySource = true;
45+
46+ private List<ReferenceType> classes = new ArrayList<ReferenceType>();
47+
48+ private Environment env;
49+
50+ // Cached line-by-line access.
51+
52+ //### Unify this with source model used in source view?
53+ //### What is our cache-management policy for these?
54+ //### Even with weak refs, we won't discard any part of the
55+ //### source if the SourceModel object is reachable.
56+ /**
57+ * List of Line.
58+ */
59+ private List<Line> sourceLines = null;
60+
61+ public static class Line {
62+ public String text;
63+ public boolean hasBreakpoint = false;
64+ public ReferenceType refType = null;
65+ Line(String text) {
66+ this.text = text;
67+ }
68+ public boolean isExecutable() {
69+ return refType != null;
70+ }
71+ public boolean hasBreakpoint() {
72+ return hasBreakpoint;
73+ }
74+ };
75+
76+ // 132 characters long, all printable characters.
77+ public static final Line prototypeCellValue = new Line(
78+ "abcdefghijklmnopqrstuvwxyz" +
79+ "ABCDEFGHIJKLMNOPQRSTUVWXYZ" +
80+ "ABCDEFGHIJKLMNOPQRSTUVWXYZ" +
81+ "1234567890~!@#$%^&*()_+{}|" +
82+ ":<>?`-=[];',.XXXXXXXXXXXX/\\\"");
83+
84+ SourceModel(Environment env, File path) {
85+ this.env = env;
86+ this.path = path;
87+ }
88+
89+ public SourceModel(String message) {
90+ this.path = null;
91+ setMessage(message);
92+ }
93+
94+ private void setMessage(String message) {
95+ isActuallySource = false;
96+ sourceLines = new ArrayList<Line>();
97+ sourceLines.add(new Line(message));
98+ }
99+
100+ // **** Implement ListModel *****
101+
102+ @Override
103+ public Object getElementAt(int index) {
104+ if (sourceLines == null) {
105+ initialize();
106+ }
107+ return sourceLines.get(index);
108+ }
109+
110+ @Override
111+ public int getSize() {
112+ if (sourceLines == null) {
113+ initialize();
114+ }
115+ return sourceLines.size();
116+ }
117+
118+ // ***** Other functionality *****
119+
120+ public File fileName() {
121+ return path;
122+ }
123+
124+ public BufferedReader sourceReader() throws IOException {
125+ return new BufferedReader(new FileReader(path));
126+ }
127+
128+ public Line line(int lineNo) {
129+ if (sourceLines == null) {
130+ initialize();
131+ }
132+ int index = lineNo - 1; // list is 0-indexed
133+ if (index >= sourceLines.size() || index < 0) {
134+ return null;
135+ } else {
136+ return sourceLines.get(index);
137+ }
138+ }
139+
140+ public String sourceLine(int lineNo) {
141+ Line line = line(lineNo);
142+ if (line == null) {
143+ return null;
144+ } else {
145+ return line.text;
146+ }
147+ }
148+
149+ void addClass(ReferenceType refType) {
150+ // Logically is Set
151+ if (classes.indexOf(refType) == -1) {
152+ classes.add(refType);
153+ if (sourceLines != null) {
154+ markClassLines(refType);
155+ }
156+ }
157+ }
158+
159+ /**
160+ * @return List of currently known {@link com.sun.jdi.ReferenceType}
161+ * in this source file.
162+ */
163+ public List<ReferenceType> referenceTypes() {
164+ return Collections.unmodifiableList(classes);
165+ }
166+
167+ private void initialize() {
168+ try {
169+ rawInit();
170+ } catch (IOException exc) {
171+ setMessage("[Error reading source code]");
172+ }
173+ }
174+
175+ public void showBreakpoint(int ln, boolean hasBreakpoint) {
176+ line(ln).hasBreakpoint = hasBreakpoint;
177+ fireContentsChanged(this, ln, ln);
178+ }
179+
180+ public void showExecutable(int ln, ReferenceType refType) {
181+ line(ln).refType = refType;
182+ fireContentsChanged(this, ln, ln);
183+ }
184+
185+ /**
186+ * Mark executable lines and breakpoints, but only
187+ * when sourceLines is set.
188+ */
189+ private void markClassLines(ReferenceType refType) {
190+ for (Method meth : refType.methods()) {
191+ try {
192+ for (Location loc : meth.allLineLocations()) {
193+ showExecutable(loc.lineNumber(), refType);
194+ }
195+ } catch (AbsentInformationException exc) {
196+ // do nothing
197+ }
198+ }
199+ for (BreakpointRequest bp :
200+ env.getExecutionManager().eventRequestManager().breakpointRequests()) {
201+ if (bp.location() != null) {
202+ Location loc = bp.location();
203+ if (loc.declaringType().equals(refType)) {
204+ showBreakpoint(loc.lineNumber(),true);
205+ }
206+ }
207+ }
208+ }
209+
210+ private void rawInit() throws IOException {
211+ sourceLines = new ArrayList<Line>();
212+ BufferedReader reader = sourceReader();
213+ try {
214+ String line = reader.readLine();
215+ while (line != null) {
216+ sourceLines.add(new Line(expandTabs(line)));
217+ line = reader.readLine();
218+ }
219+ } finally {
220+ reader.close();
221+ }
222+ for (ReferenceType refType : classes) {
223+ markClassLines(refType);
224+ }
225+ }
226+
227+ private String expandTabs(String s) {
228+ int col = 0;
229+ int len = s.length();
230+ StringBuffer sb = new StringBuffer(132);
231+ for (int i = 0; i < len; i++) {
232+ char c = s.charAt(i);
233+ sb.append(c);
234+ if (c == '\t') {
235+ int pad = (8 - (col % 8));
236+ for (int j = 0; j < pad; j++) {
237+ sb.append(' ');
238+ }
239+ col += pad;
240+ } else {
241+ col++;
242+ }
243+ }
244+ return sb.toString();
245+ }
246+
247+}
java/pkg/com/sun/tools/example/debug/gui/SourceTool.java+383−0
@@ -0,0 +1,383 @@
1+/*
2+ * Copyright (c) 1998, 1999, Oracle and/or its affiliates. All rights reserved.
3+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+ *
5+ * This code is free software; you can redistribute it and/or modify it
6+ * under the terms of the GNU General Public License version 2 only, as
7+ * published by the Free Software Foundation. Oracle designates this
8+ * particular file as subject to the "Classpath" exception as provided
9+ * by Oracle in the LICENSE file that accompanied this code.
10+ *
11+ * This code is distributed in the hope that it will be useful, but WITHOUT
12+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+ * version 2 for more details (a copy is included in the LICENSE file that
15+ * accompanied this code).
16+ *
17+ * You should have received a copy of the GNU General Public License version
18+ * 2 along with this work; if not, write to the Free Software Foundation,
19+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+ *
21+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+ * or visit www.oracle.com if you need additional information or have any
23+ * questions.
24+ */
25+
26+package com.sun.tools.example.debug.gui;
27+
28+import java.io.*;
29+import java.awt.*;
30+import java.awt.event.*;
31+import javax.swing.*;
32+
33+import com.sun.jdi.*;
34+import com.sun.jdi.request.*;
35+
36+import com.sun.tools.example.debug.bdi.*;
37+
38+public class SourceTool extends JPanel {
39+
40+ private static final long serialVersionUID = -5461299294186395257L;
41+
42+ private Environment env;
43+
44+ private ExecutionManager runtime;
45+ private ContextManager context;
46+ private SourceManager sourceManager;
47+
48+ private JList list;
49+ private ListModel sourceModel;
50+
51+ // Information on source file that is on display, or failed to be
52+ // displayed due to inaccessible source. Used to update display
53+ // when sourcepath is changed.
54+
55+ private String sourceName; // relative path name, if showSourceFile
56+ private Location sourceLocn; // location, if showSourceForLocation
57+ private CommandInterpreter interpreter;
58+
59+ public SourceTool(Environment env) {
60+
61+ super(new BorderLayout());
62+
63+ this.env = env;
64+
65+ runtime = env.getExecutionManager();
66+ sourceManager = env.getSourceManager();
67+ this.context = env.getContextManager();
68+ this.interpreter = new CommandInterpreter(env, true);
69+
70+ sourceModel = new DefaultListModel(); // empty
71+
72+ list = new JList(sourceModel);
73+ list.setCellRenderer(new SourceLineRenderer());
74+
75+ list.setPrototypeCellValue(SourceModel.prototypeCellValue);
76+
77+ SourceToolListener listener = new SourceToolListener();
78+ context.addContextListener(listener);
79+ runtime.addSpecListener(listener);
80+ sourceManager.addSourceListener(listener);
81+
82+ MouseListener squeek = new STMouseListener();
83+ list.addMouseListener(squeek);
84+
85+ add(new JScrollPane(list));
86+ }
87+
88+ public void setTextFont(Font f) {
89+ list.setFont(f);
90+ list.setPrototypeCellValue(SourceModel.prototypeCellValue);
91+ }
92+
93+ private class SourceToolListener
94+ implements ContextListener, SourceListener, SpecListener
95+ {
96+
97+ // ContextListener
98+
99+ @Override
100+ public void currentFrameChanged(CurrentFrameChangedEvent e) {
101+ showSourceContext(e.getThread(), e.getIndex());
102+ }
103+
104+ // Clear source view.
105+ // sourceModel = new DefaultListModel(); // empty
106+
107+ // SourceListener
108+
109+ @Override
110+ public void sourcepathChanged(SourcepathChangedEvent e) {
111+ // Reload source view if its contents depend
112+ // on the source path.
113+ if (sourceName != null) {
114+ showSourceFile(sourceName);
115+ } else if (sourceLocn != null) {
116+ showSourceForLocation(sourceLocn);
117+ }
118+ }
119+
120+ // SpecListener
121+
122+ @Override
123+ public void breakpointSet(SpecEvent e) {
124+ breakpointResolved(e);
125+ }
126+
127+ @Override
128+ public void breakpointDeferred(SpecEvent e) { }
129+
130+ @Override
131+ public void breakpointDeleted(SpecEvent e) {
132+ BreakpointRequest req = (BreakpointRequest)e.getEventRequest();
133+ Location loc = req.location();
134+ if (loc != null) {
135+ try {
136+ SourceModel sm = sourceManager.sourceForLocation(loc);
137+ sm.showBreakpoint(loc.lineNumber(), false);
138+ showSourceForLocation(loc);
139+ } catch (Exception exc) {
140+ }
141+ }
142+ }
143+
144+ @Override
145+ public void breakpointResolved(SpecEvent e) {
146+ BreakpointRequest req = (BreakpointRequest)e.getEventRequest();
147+ Location loc = req.location();
148+ try {
149+ SourceModel sm = sourceManager.sourceForLocation(loc);
150+ sm.showBreakpoint(loc.lineNumber(), true);
151+ showSourceForLocation(loc);
152+ } catch (Exception exc) {
153+ }
154+ }
155+
156+ @Override
157+ public void breakpointError(SpecErrorEvent e) {
158+ breakpointDeleted(e);
159+ }
160+
161+ @Override
162+ public void watchpointSet(SpecEvent e) {
163+ }
164+ @Override
165+ public void watchpointDeferred(SpecEvent e) {
166+ }
167+ @Override
168+ public void watchpointDeleted(SpecEvent e) {
169+ }
170+ @Override
171+ public void watchpointResolved(SpecEvent e) {
172+ }
173+ @Override
174+ public void watchpointError(SpecErrorEvent e) {
175+ }
176+
177+ @Override
178+ public void exceptionInterceptSet(SpecEvent e) {
179+ }
180+ @Override
181+ public void exceptionInterceptDeferred(SpecEvent e) {
182+ }
183+ @Override
184+ public void exceptionInterceptDeleted(SpecEvent e) {
185+ }
186+ @Override
187+ public void exceptionInterceptResolved(SpecEvent e) {
188+ }
189+ @Override
190+ public void exceptionInterceptError(SpecErrorEvent e) {
191+ }
192+ }
193+
194+ private void showSourceContext(ThreadReference thread, int index) {
195+ //### Should use ThreadInfo here.
196+ StackFrame frame = null;
197+ if (thread != null) {
198+ try {
199+ frame = thread.frame(index);
200+ } catch (IncompatibleThreadStateException e) {}
201+ }
202+ if (frame == null) {
203+ return;
204+ }
205+ Location locn = frame.location();
206+ /*****
207+ if (!showSourceForLocation(locn)) {
208+ env.notice("Could not display source for "
209+ + Utils.locationString(locn));
210+ }
211+ *****/
212+ showSourceForLocation(locn);
213+ }
214+
215+ public boolean showSourceForLocation(Location locn) {
216+ sourceName = null;
217+ sourceLocn = locn;
218+ int lineNo = locn.lineNumber();
219+ if (lineNo != -1) {
220+ SourceModel source = sourceManager.sourceForLocation(locn);
221+ if (source != null) {
222+ showSourceAtLine(source, lineNo-1);
223+ return true;
224+ }
225+ }
226+ // Here if we could not display source.
227+ showSourceUnavailable();
228+ return false;
229+ }
230+
231+ public boolean showSourceFile(String fileName) {
232+ sourceLocn = null;
233+ File file;
234+ if (!fileName.startsWith(File.separator)) {
235+ sourceName = fileName;
236+ SearchPath sourcePath = sourceManager.getSourcePath();
237+ file = sourcePath.resolve(fileName);
238+ if (file == null) {
239+ //env.failure("Source not found on current source path.");
240+ showSourceUnavailable();
241+ return false;
242+ }
243+ } else {
244+ sourceName = null; // Absolute pathname does not depend on sourcepath.
245+ file = new File(fileName);
246+ }
247+ SourceModel source = sourceManager.sourceForFile(file);
248+ if (source != null) {
249+ showSource(source);
250+ return true;
251+ }
252+ showSourceUnavailable();
253+ return false;
254+ }
255+
256+ private void showSource(SourceModel model) {
257+ setViewModel(model);
258+ }
259+
260+ private void showSourceAtLine(SourceModel model, int lineNo) {
261+ setViewModel(model);
262+ if (model.isActuallySource && (lineNo < model.getSize())) {
263+ list.setSelectedIndex(lineNo);
264+ if (lineNo+4 < model.getSize()) {
265+ list.ensureIndexIsVisible(lineNo+4); // give some context
266+ }
267+ list.ensureIndexIsVisible(lineNo);
268+ }
269+ }
270+
271+ private void showSourceUnavailable() {
272+ SourceModel model = new SourceModel("[Source code is not available]");
273+ setViewModel(model);
274+ }
275+
276+ private void setViewModel(SourceModel model) {
277+ if (model != sourceModel) {
278+ // install new model
279+ list.setModel(model);
280+ sourceModel = model;
281+ }
282+ }
283+
284+ private class SourceLineRenderer extends DefaultListCellRenderer {
285+
286+ @Override
287+ public Component getListCellRendererComponent(JList list,
288+ Object value,
289+ int index,
290+ boolean isSelected,
291+ boolean cellHasFocus) {
292+
293+ //### Should set background highlight and/or icon if breakpoint on this line.
294+ // Configures "this"
295+ super.getListCellRendererComponent(list, value, index,
296+ isSelected, cellHasFocus);
297+
298+ SourceModel.Line line = (SourceModel.Line)value;
299+
300+ //### Tab expansion is now done when source file is read in,
301+ //### to speed up display. This costs a lot of space, slows
302+ //### down source file loading, and has not been demonstrated
303+ //### to yield an observable improvement in display performance.
304+ //### Measurements may be appropriate here.
305+ //String sourceLine = expandTabs((String)value);
306+ setText(line.text);
307+ if (line.hasBreakpoint) {
308+ setIcon(Icons.stopSignIcon);
309+ } else if (line.isExecutable()) {
310+ setIcon(Icons.execIcon);
311+ } else {
312+ setIcon(Icons.blankIcon);
313+ }
314+
315+
316+ return this;
317+ }
318+
319+ @Override
320+ public Dimension getPreferredSize() {
321+ Dimension dim = super.getPreferredSize();
322+ return new Dimension(dim.width, dim.height-5);
323+ }
324+
325+ }
326+
327+ private class STMouseListener extends MouseAdapter implements MouseListener {
328+ @Override
329+ public void mousePressed(MouseEvent e) {
330+ if (e.isPopupTrigger()) {
331+ showPopupMenu((Component)e.getSource(),
332+ e.getX(), e.getY());
333+ }
334+ }
335+
336+ @Override
337+ public void mouseReleased(MouseEvent e) {
338+ if (e.isPopupTrigger()) {
339+ showPopupMenu((Component)e.getSource(),
340+ e.getX(), e.getY());
341+ }
342+ }
343+
344+ private void showPopupMenu(Component invoker, int x, int y) {
345+ JList list = (JList)invoker;
346+ int ln = list.getSelectedIndex() + 1;
347+ SourceModel.Line line =
348+ (SourceModel.Line)list.getSelectedValue();
349+ JPopupMenu popup = new JPopupMenu();
350+
351+ if (line == null) {
352+ popup.add(new JMenuItem("please select a line"));
353+ } else if (line.isExecutable()) {
354+ String className = line.refType.name();
355+ if (line.hasBreakpoint()) {
356+ popup.add(commandItem("Clear Breakpoint",
357+ "clear " + className +
358+ ":" + ln));
359+ } else {
360+ popup.add(commandItem("Set Breakpoint",
361+ "stop at " + className +
362+ ":" + ln));
363+ }
364+ } else {
365+ popup.add(new JMenuItem("not an executable line"));
366+ }
367+
368+ popup.show(invoker,
369+ x + popup.getWidth()/2, y + popup.getHeight()/2);
370+ }
371+
372+ private JMenuItem commandItem(String label, final String cmd) {
373+ JMenuItem item = new JMenuItem(label);
374+ item.addActionListener(new ActionListener() {
375+ @Override
376+ public void actionPerformed(ActionEvent e) {
377+ interpreter.executeCommand(cmd);
378+ }
379+ });
380+ return item;
381+ }
382+ }
383+}
java/pkg/com/sun/tools/example/debug/gui/SourceTreeTool.java+283−0
@@ -0,0 +1,283 @@
1+/*
2+ * Copyright (c) 1998, 1999, Oracle and/or its affiliates. All rights reserved.
3+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+ *
5+ * This code is free software; you can redistribute it and/or modify it
6+ * under the terms of the GNU General Public License version 2 only, as
7+ * published by the Free Software Foundation. Oracle designates this
8+ * particular file as subject to the "Classpath" exception as provided
9+ * by Oracle in the LICENSE file that accompanied this code.
10+ *
11+ * This code is distributed in the hope that it will be useful, but WITHOUT
12+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+ * version 2 for more details (a copy is included in the LICENSE file that
15+ * accompanied this code).
16+ *
17+ * You should have received a copy of the GNU General Public License version
18+ * 2 along with this work; if not, write to the Free Software Foundation,
19+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+ *
21+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+ * or visit www.oracle.com if you need additional information or have any
23+ * questions.
24+ */
25+
26+package com.sun.tools.example.debug.gui;
27+
28+import java.io.*;
29+import java.util.*;
30+
31+import javax.swing.*;
32+import javax.swing.tree.*;
33+import java.awt.*;
34+import java.awt.event.*;
35+
36+import com.sun.tools.example.debug.bdi.*;
37+
38+public class SourceTreeTool extends JPanel {
39+
40+ private static final long serialVersionUID = 3336680912107956419L;
41+
42+ private Environment env;
43+
44+ private ExecutionManager runtime;
45+ private SourceManager sourceManager;
46+ private ClassManager classManager;
47+
48+ private JTree tree;
49+ private SourceTreeNode root;
50+ private SearchPath sourcePath;
51+ private CommandInterpreter interpreter;
52+
53+ private static String HEADING = "SOURCES";
54+
55+ public SourceTreeTool(Environment env) {
56+
57+ super(new BorderLayout());
58+
59+ this.env = env;
60+ this.runtime = env.getExecutionManager();
61+ this.sourceManager = env.getSourceManager();
62+
63+ this.interpreter = new CommandInterpreter(env);
64+
65+ sourcePath = sourceManager.getSourcePath();
66+ root = createDirectoryTree(HEADING);
67+
68+ // Create a tree that allows one selection at a time.
69+ tree = new JTree(new DefaultTreeModel(root));
70+ tree.setSelectionModel(new SingleLeafTreeSelectionModel());
71+
72+ /******
73+ // Listen for when the selection changes.
74+ tree.addTreeSelectionListener(new TreeSelectionListener() {
75+ public void valueChanged(TreeSelectionEvent e) {
76+ SourceTreeNode node = (SourceTreeNode)
77+ (e.getPath().getLastPathComponent());
78+ interpreter.executeCommand("view " + node.getRelativePath());
79+ }
80+ });
81+ ******/
82+
83+ MouseListener ml = new MouseAdapter() {
84+ @Override
85+ public void mouseClicked(MouseEvent e) {
86+ int selRow = tree.getRowForLocation(e.getX(), e.getY());
87+ TreePath selPath = tree.getPathForLocation(e.getX(), e.getY());
88+ if(selRow != -1) {
89+ if(e.getClickCount() == 1) {
90+ SourceTreeNode node =
91+ (SourceTreeNode)selPath.getLastPathComponent();
92+ // If user clicks on leaf, select it, and issue 'view' command.
93+ if (node.isLeaf()) {
94+ tree.setSelectionPath(selPath);
95+ interpreter.executeCommand("view " + node.getRelativePath());
96+ }
97+ }
98+ }
99+ }
100+ };
101+ tree.addMouseListener(ml);
102+
103+ JScrollPane treeView = new JScrollPane(tree);
104+ add(treeView);
105+
106+ // Create listener for source path changes.
107+
108+ SourceTreeToolListener listener = new SourceTreeToolListener();
109+ sourceManager.addSourceListener(listener);
110+
111+ //### remove listeners on exit!
112+ }
113+
114+ private class SourceTreeToolListener implements SourceListener {
115+
116+ @Override
117+ public void sourcepathChanged(SourcepathChangedEvent e) {
118+ sourcePath = sourceManager.getSourcePath();
119+ root = createDirectoryTree(HEADING);
120+ tree.setModel(new DefaultTreeModel(root));
121+ }
122+
123+ }
124+
125+ private static class SourceOrDirectoryFilter implements FilenameFilter {
126+ @Override
127+ public boolean accept(File dir, String name) {
128+ return (name.endsWith(".java") ||
129+ new File(dir, name).isDirectory());
130+ }
131+ }
132+
133+ private static FilenameFilter filter = new SourceOrDirectoryFilter();
134+
135+ SourceTreeNode createDirectoryTree(String label) {
136+ try {
137+ return new SourceTreeNode(label, null, "", true);
138+ } catch (SecurityException e) {
139+ env.failure("Cannot access source file or directory");
140+ return null;
141+ }
142+ }
143+
144+
145+ class SourceTreeNode implements TreeNode {
146+
147+ private String name;
148+ private boolean isDirectory;
149+ private SourceTreeNode parent;
150+ private SourceTreeNode[] children;
151+ private String relativePath;
152+ private boolean isExpanded;
153+
154+ private SourceTreeNode(String label,
155+ SourceTreeNode parent,
156+ String relativePath,
157+ boolean isDirectory) {
158+ this.name = label;
159+ this.relativePath = relativePath;
160+ this.parent = parent;
161+ this.isDirectory = isDirectory;
162+ }
163+
164+ @Override
165+ public String toString() {
166+ return name;
167+ }
168+
169+ public String getRelativePath() {
170+ return relativePath;
171+ }
172+
173+ private void expandIfNeeded() {
174+ try {
175+ if (!isExpanded && isDirectory) {
176+ String[] files = sourcePath.children(relativePath, filter);
177+ children = new SourceTreeNode[files.length];
178+ for (int i = 0; i < files.length; i++) {
179+ String childName =
180+ (relativePath.equals(""))
181+ ? files[i]
182+ : relativePath + File.separator + files[i];
183+ File file = sourcePath.resolve(childName);
184+ boolean isDir = (file != null && file.isDirectory());
185+ children[i] =
186+ new SourceTreeNode(files[i], this, childName, isDir);
187+ }
188+ }
189+ isExpanded = true;
190+ } catch (SecurityException e) {
191+ children = null;
192+ env.failure("Cannot access source file or directory");
193+ }
194+ }
195+
196+ // -- interface TreeNode --
197+
198+ /*
199+ * Returns the child <code>TreeNode</code> at index
200+ * <code>childIndex</code>.
201+ */
202+ @Override
203+ public TreeNode getChildAt(int childIndex) {
204+ expandIfNeeded();
205+ return children[childIndex];
206+ }
207+
208+ /**
209+ * Returns the number of children <code>TreeNode</code>s the receiver
210+ * contains.
211+ */
212+ @Override
213+ public int getChildCount() {
214+ expandIfNeeded();
215+ return children.length;
216+ }
217+
218+ /**
219+ * Returns the parent <code>TreeNode</code> of the receiver.
220+ */
221+ @Override
222+ public TreeNode getParent() {
223+ return parent;
224+ }
225+
226+ /**
227+ * Returns the index of <code>node</code> in the receivers children.
228+ * If the receiver does not contain <code>node</code>, -1 will be
229+ * returned.
230+ */
231+ @Override
232+ public int getIndex(TreeNode node) {
233+ expandIfNeeded();
234+ for (int i = 0; i < children.length; i++) {
235+ if (children[i] == node) {
236+ return i;
237+ }
238+ }
239+ return -1;
240+ }
241+
242+ /**
243+ * Returns true if the receiver allows children.
244+ */
245+ @Override
246+ public boolean getAllowsChildren() {
247+ return isDirectory;
248+ }
249+
250+ /**
251+ * Returns true if the receiver is a leaf.
252+ */
253+ @Override
254+ public boolean isLeaf() {
255+ expandIfNeeded();
256+ return !isDirectory;
257+ }
258+
259+ /**
260+ * Returns the children of the receiver as an Enumeration.
261+ */
262+ @Override
263+ public Enumeration children() {
264+ expandIfNeeded();
265+ return new Enumeration() {
266+ int i = 0;
267+ @Override
268+ public boolean hasMoreElements() {
269+ return (i < children.length);
270+ }
271+ @Override
272+ public Object nextElement() throws NoSuchElementException {
273+ if (i >= children.length) {
274+ throw new NoSuchElementException();
275+ }
276+ return children[i++];
277+ }
278+ };
279+ }
280+
281+ }
282+
283+}
java/pkg/com/sun/tools/example/debug/gui/SourcepathChangedEvent.java+37−0
@@ -0,0 +1,37 @@
1+/*
2+ * Copyright (c) 1998, 1999, Oracle and/or its affiliates. All rights reserved.
3+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+ *
5+ * This code is free software; you can redistribute it and/or modify it
6+ * under the terms of the GNU General Public License version 2 only, as
7+ * published by the Free Software Foundation. Oracle designates this
8+ * particular file as subject to the "Classpath" exception as provided
9+ * by Oracle in the LICENSE file that accompanied this code.
10+ *
11+ * This code is distributed in the hope that it will be useful, but WITHOUT
12+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+ * version 2 for more details (a copy is included in the LICENSE file that
15+ * accompanied this code).
16+ *
17+ * You should have received a copy of the GNU General Public License version
18+ * 2 along with this work; if not, write to the Free Software Foundation,
19+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+ *
21+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+ * or visit www.oracle.com if you need additional information or have any
23+ * questions.
24+ */
25+
26+package com.sun.tools.example.debug.gui;
27+
28+import java.util.EventObject;
29+
30+public class SourcepathChangedEvent extends EventObject {
31+
32+ private static final long serialVersionUID = 8762169481005804121L;
33+
34+ public SourcepathChangedEvent(Object source) {
35+ super(source);
36+ }
37+}
java/pkg/com/sun/tools/example/debug/gui/StackTraceTool.java+198−0
@@ -0,0 +1,198 @@
1+/*
2+ * Copyright (c) 1998, 2008, Oracle and/or its affiliates. All rights reserved.
3+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+ *
5+ * This code is free software; you can redistribute it and/or modify it
6+ * under the terms of the GNU General Public License version 2 only, as
7+ * published by the Free Software Foundation. Oracle designates this
8+ * particular file as subject to the "Classpath" exception as provided
9+ * by Oracle in the LICENSE file that accompanied this code.
10+ *
11+ * This code is distributed in the hope that it will be useful, but WITHOUT
12+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+ * version 2 for more details (a copy is included in the LICENSE file that
15+ * accompanied this code).
16+ *
17+ * You should have received a copy of the GNU General Public License version
18+ * 2 along with this work; if not, write to the Free Software Foundation,
19+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+ *
21+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+ * or visit www.oracle.com if you need additional information or have any
23+ * questions.
24+ */
25+
26+package com.sun.tools.example.debug.gui;
27+
28+import javax.swing.*;
29+import javax.swing.event.*;
30+import java.awt.*;
31+import com.sun.jdi.*;
32+import com.sun.tools.example.debug.bdi.*;
33+
34+public class StackTraceTool extends JPanel {
35+
36+ private static final long serialVersionUID = 9140041989427965718L;
37+
38+ private Environment env;
39+
40+ private ExecutionManager runtime;
41+ private ContextManager context;
42+
43+ private ThreadInfo tinfo;
44+
45+ private JList list;
46+ private ListModel stackModel;
47+
48+ public StackTraceTool(Environment env) {
49+
50+ super(new BorderLayout());
51+
52+ this.env = env;
53+ this.runtime = env.getExecutionManager();
54+ this.context = env.getContextManager();
55+
56+ stackModel = new DefaultListModel(); // empty
57+
58+ list = new JList(stackModel);
59+ list.setCellRenderer(new StackFrameRenderer());
60+
61+ JScrollPane listView = new JScrollPane(list);
62+ add(listView);
63+
64+ // Create listener.
65+ StackTraceToolListener listener = new StackTraceToolListener();
66+ context.addContextListener(listener);
67+ list.addListSelectionListener(listener);
68+
69+ //### remove listeners on exit!
70+ }
71+
72+ private class StackTraceToolListener
73+ implements ContextListener, ListSelectionListener
74+ {
75+
76+ // ContextListener
77+
78+ // If the user selects a new current frame, display it in
79+ // this view.
80+
81+ //### I suspect we handle the case badly that the VM is not interrupted.
82+
83+ @Override
84+ public void currentFrameChanged(CurrentFrameChangedEvent e) {
85+ // If the current frame of the thread appearing in this
86+ // view is changed, move the selection to track it.
87+ int frameIndex = e.getIndex();
88+ ThreadInfo ti = e.getThreadInfo();
89+ if (e.getInvalidate() || tinfo != ti) {
90+ tinfo = ti;
91+ showStack(ti, frameIndex);
92+ } else {
93+ if (frameIndex < stackModel.getSize()) {
94+ list.setSelectedIndex(frameIndex);
95+ list.ensureIndexIsVisible(frameIndex);
96+ }
97+ }
98+ }
99+
100+ // ListSelectionListener
101+
102+ @Override
103+ public void valueChanged(ListSelectionEvent e) {
104+ int index = list.getSelectedIndex();
105+ if (index != -1) {
106+ //### should use listener?
107+ try {
108+ context.setCurrentFrameIndex(index);
109+ } catch (VMNotInterruptedException exc) {
110+ }
111+ }
112+ }
113+ }
114+
115+ private class StackFrameRenderer extends DefaultListCellRenderer {
116+
117+ @Override
118+ public Component getListCellRendererComponent(JList list,
119+ Object value,
120+ int index,
121+ boolean isSelected,
122+ boolean cellHasFocus) {
123+
124+ //### We should indicate the current thread independently of the
125+ //### selection, e.g., with an icon, because the user may change
126+ //### the selection graphically without affecting the current
127+ //### thread.
128+
129+ super.getListCellRendererComponent(list, value, index,
130+ isSelected, cellHasFocus);
131+ if (value == null) {
132+ this.setText("<unavailable>");
133+ } else {
134+ StackFrame frame = (StackFrame)value;
135+ Location loc = frame.location();
136+ Method meth = loc.method();
137+ String methName =
138+ meth.declaringType().name() + '.' + meth.name();
139+ String position = "";
140+ if (meth.isNative()) {
141+ position = " (native method)";
142+ } else if (loc.lineNumber() != -1) {
143+ position = ":" + loc.lineNumber();
144+ } else {
145+ long pc = loc.codeIndex();
146+ if (pc != -1) {
147+ position = ", pc = " + pc;
148+ }
149+ }
150+ // Indices are presented to the user starting from 1, not 0.
151+ this.setText("[" + (index+1) +"] " + methName + position);
152+ }
153+ return this;
154+ }
155+ }
156+
157+ // Point this view at the given thread and frame.
158+
159+ private void showStack(ThreadInfo tinfo, int selectFrame) {
160+ StackTraceListModel model = new StackTraceListModel(tinfo);
161+ stackModel = model;
162+ list.setModel(stackModel);
163+ list.setSelectedIndex(selectFrame);
164+ list.ensureIndexIsVisible(selectFrame);
165+ }
166+
167+ private static class StackTraceListModel extends AbstractListModel {
168+
169+ private final ThreadInfo tinfo;
170+
171+ public StackTraceListModel(ThreadInfo tinfo) {
172+ this.tinfo = tinfo;
173+ }
174+
175+ @Override
176+ public Object getElementAt(int index) {
177+ try {
178+ return tinfo == null? null : tinfo.getFrame(index);
179+ } catch (VMNotInterruptedException e) {
180+ //### Is this the right way to handle this?
181+ //### Would happen if user scrolled stack trace
182+ //### while not interrupted -- should probably
183+ //### block user interaction in this case.
184+ return null;
185+ }
186+ }
187+
188+ @Override
189+ public int getSize() {
190+ try {
191+ return tinfo == null? 1 : tinfo.getFrameCount();
192+ } catch (VMNotInterruptedException e) {
193+ //### Is this the right way to handle this?
194+ return 0;
195+ }
196+ }
197+ }
198+}
java/pkg/com/sun/tools/example/debug/gui/ThreadTreeTool.java+346−0
@@ -0,0 +1,346 @@
1+/*
2+ * Copyright (c) 1998, 2008, Oracle and/or its affiliates. All rights reserved.
3+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+ *
5+ * This code is free software; you can redistribute it and/or modify it
6+ * under the terms of the GNU General Public License version 2 only, as
7+ * published by the Free Software Foundation. Oracle designates this
8+ * particular file as subject to the "Classpath" exception as provided
9+ * by Oracle in the LICENSE file that accompanied this code.
10+ *
11+ * This code is distributed in the hope that it will be useful, but WITHOUT
12+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+ * version 2 for more details (a copy is included in the LICENSE file that
15+ * accompanied this code).
16+ *
17+ * You should have received a copy of the GNU General Public License version
18+ * 2 along with this work; if not, write to the Free Software Foundation,
19+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+ *
21+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+ * or visit www.oracle.com if you need additional information or have any
23+ * questions.
24+ */
25+
26+package com.sun.tools.example.debug.gui;
27+
28+import java.util.*;
29+import java.util.List; // Must import explicitly due to conflict with javax.awt.List
30+
31+import javax.swing.*;
32+import javax.swing.tree.*;
33+import java.awt.*;
34+import java.awt.event.*;
35+
36+import com.sun.jdi.*;
37+import com.sun.tools.example.debug.event.*;
38+import com.sun.tools.example.debug.bdi.*;
39+
40+//### Bug: If the name of a thread is changed via Thread.setName(), the
41+//### thread tree view does not reflect this. The name of the thread at
42+//### the time it is created is used throughout its lifetime.
43+
44+public class ThreadTreeTool extends JPanel {
45+
46+ private static final long serialVersionUID = 4168599992853038878L;
47+
48+ private Environment env;
49+
50+ private ExecutionManager runtime;
51+ private SourceManager sourceManager;
52+ private ClassManager classManager;
53+
54+ private JTree tree;
55+ private DefaultTreeModel treeModel;
56+ private ThreadTreeNode root;
57+ private SearchPath sourcePath;
58+
59+ private CommandInterpreter interpreter;
60+
61+ private static String HEADING = "THREADS";
62+
63+ public ThreadTreeTool(Environment env) {
64+
65+ super(new BorderLayout());
66+
67+ this.env = env;
68+ this.runtime = env.getExecutionManager();
69+ this.sourceManager = env.getSourceManager();
70+
71+ this.interpreter = new CommandInterpreter(env);
72+
73+ root = createThreadTree(HEADING);
74+ treeModel = new DefaultTreeModel(root);
75+
76+ // Create a tree that allows one selection at a time.
77+
78+ tree = new JTree(treeModel);
79+ tree.setSelectionModel(new SingleLeafTreeSelectionModel());
80+
81+ MouseListener ml = new MouseAdapter() {
82+ @Override
83+ public void mouseClicked(MouseEvent e) {
84+ int selRow = tree.getRowForLocation(e.getX(), e.getY());
85+ TreePath selPath = tree.getPathForLocation(e.getX(), e.getY());
86+ if(selRow != -1) {
87+ if(e.getClickCount() == 1) {
88+ ThreadTreeNode node =
89+ (ThreadTreeNode)selPath.getLastPathComponent();
90+ // If user clicks on leaf, select it, and issue 'thread' command.
91+ if (node.isLeaf()) {
92+ tree.setSelectionPath(selPath);
93+ interpreter.executeCommand("thread " +
94+ node.getThreadId() +
95+ " (\"" +
96+ node.getName() + "\")");
97+ }
98+ }
99+ }
100+ }
101+ };
102+
103+ tree.addMouseListener(ml);
104+
105+ JScrollPane treeView = new JScrollPane(tree);
106+ add(treeView);
107+
108+ // Create listener.
109+ ThreadTreeToolListener listener = new ThreadTreeToolListener();
110+ runtime.addJDIListener(listener);
111+ runtime.addSessionListener(listener);
112+
113+ //### remove listeners on exit!
114+ }
115+
116+ HashMap<ThreadReference, List<String>> threadTable = new HashMap<ThreadReference, List<String>>();
117+
118+ private List<String> threadPath(ThreadReference thread) {
119+ // May exit abnormally if VM disconnects.
120+ List<String> l = new ArrayList<String>();
121+ l.add(0, thread.name());
122+ ThreadGroupReference group = thread.threadGroup();
123+ while (group != null) {
124+ l.add(0, group.name());
125+ group = group.parent();
126+ }
127+ return l;
128+ }
129+
130+ private class ThreadTreeToolListener extends JDIAdapter
131+ implements JDIListener, SessionListener {
132+
133+ // SessionListener
134+
135+ @Override
136+ public void sessionStart(EventObject e) {
137+ try {
138+ for (ThreadReference thread : runtime.allThreads()) {
139+ root.addThread(thread);
140+ }
141+ } catch (VMDisconnectedException ee) {
142+ // VM went away unexpectedly.
143+ } catch (NoSessionException ee) {
144+ // Ignore. Should not happen.
145+ }
146+ }
147+
148+ @Override
149+ public void sessionInterrupt(EventObject e) {}
150+ @Override
151+ public void sessionContinue(EventObject e) {}
152+
153+
154+ // JDIListener
155+
156+ @Override
157+ public void threadStart(ThreadStartEventSet e) {
158+ root.addThread(e.getThread());
159+ }
160+
161+ @Override
162+ public void threadDeath(ThreadDeathEventSet e) {
163+ root.removeThread(e.getThread());
164+ }
165+
166+ @Override
167+ public void vmDisconnect(VMDisconnectEventSet e) {
168+ // Clear the contents of this view.
169+ root = createThreadTree(HEADING);
170+ treeModel = new DefaultTreeModel(root);
171+ tree.setModel(treeModel);
172+ threadTable = new HashMap<ThreadReference, List<String>>();
173+ }
174+
175+ }
176+
177+ ThreadTreeNode createThreadTree(String label) {
178+ return new ThreadTreeNode(label, null);
179+ }
180+
181+ class ThreadTreeNode extends DefaultMutableTreeNode {
182+
183+ String name;
184+ ThreadReference thread; // null if thread group
185+ long uid;
186+ String description;
187+
188+ ThreadTreeNode(String name, ThreadReference thread) {
189+ if (name == null) {
190+ name = "<unnamed>";
191+ }
192+ this.name = name;
193+ this.thread = thread;
194+ if (thread == null) {
195+ this.uid = -1;
196+ this.description = name;
197+ } else {
198+ this.uid = thread.uniqueID();
199+ this.description = name + " (t@" + Long.toHexString(uid) + ")";
200+ }
201+ }
202+
203+ @Override
204+ public String toString() {
205+ return description;
206+ }
207+
208+ public String getName() {
209+ return name;
210+ }
211+
212+ public ThreadReference getThread() {
213+ return thread;
214+ }
215+
216+ public String getThreadId() {
217+ return "t@" + Long.toHexString(uid);
218+ }
219+
220+ private boolean isThreadGroup() {
221+ return (thread == null);
222+ }
223+
224+ @Override
225+ public boolean isLeaf() {
226+ return !isThreadGroup();
227+ }
228+
229+ public void addThread(ThreadReference thread) {

117 more lines aren’t shown here.

java/pkg/com/sun/tools/example/debug/gui/TypeScript.java+123−0

This diff is large: its 124 lines aren’t shown here.

java/pkg/com/sun/tools/example/debug/gui/TypeScriptOutputListener.java+52−0

This diff is large: its 53 lines aren’t shown here.

java/pkg/com/sun/tools/example/debug/gui/TypeScriptWriter.java+52−0

This diff is large: its 53 lines aren’t shown here.

java/pkg/com/sun/tools/example/debug/gui/mkfile+38−0

This diff is large: its 39 lines aren’t shown here.

java/pkg/com/sun/tools/example/debug/mkfile+10−0

This diff is large: its 11 lines aren’t shown here.

java/pkg/com/sun/tools/example/debug/tty/AccessWatchpointSpec.java+58−0

This diff is large: its 59 lines aren’t shown here.

java/pkg/com/sun/tools/example/debug/tty/AmbiguousMethodException.java+41−0

This diff is large: its 42 lines aren’t shown here.

java/pkg/com/sun/tools/example/debug/tty/BreakpointSpec.java+382−0

This diff is large: its 383 lines aren’t shown here.

java/pkg/com/sun/tools/example/debug/tty/Commands.java+2098−0

This diff is large: its 2099 lines aren’t shown here.

java/pkg/com/sun/tools/example/debug/tty/Env.java+322−0

This diff is large: its 323 lines aren’t shown here.

java/pkg/com/sun/tools/example/debug/tty/EventHandler.java+277−0

This diff is large: its 278 lines aren’t shown here.

java/pkg/com/sun/tools/example/debug/tty/EventNotifier.java+50−0

This diff is large: its 51 lines aren’t shown here.

java/pkg/com/sun/tools/example/debug/tty/EventRequestSpec.java+210−0

This diff is large: its 211 lines aren’t shown here.

java/pkg/com/sun/tools/example/debug/tty/EventRequestSpecList.java+166−0

This diff is large: its 167 lines aren’t shown here.

java/pkg/com/sun/tools/example/debug/tty/ExceptionSpec.java+107−0

This diff is large: its 108 lines aren’t shown here.

java/pkg/com/sun/tools/example/debug/tty/LineNotFoundException.java+41−0

This diff is large: its 42 lines aren’t shown here.

java/pkg/com/sun/tools/example/debug/tty/MalformedMemberNameException.java+38−0

This diff is large: its 39 lines aren’t shown here.

java/pkg/com/sun/tools/example/debug/tty/MessageOutput.java+196−0

This diff is large: its 197 lines aren’t shown here.

java/pkg/com/sun/tools/example/debug/tty/ModificationWatchpointSpec.java+58−0

This diff is large: its 59 lines aren’t shown here.

java/pkg/com/sun/tools/example/debug/tty/PatternReferenceTypeSpec.java+136−0

This diff is large: its 137 lines aren’t shown here.

java/pkg/com/sun/tools/example/debug/tty/ReferenceTypeSpec.java+43−0

This diff is large: its 44 lines aren’t shown here.

java/pkg/com/sun/tools/example/debug/tty/SourceMapper.java+138−0

This diff is large: its 139 lines aren’t shown here.

java/pkg/com/sun/tools/example/debug/tty/TTY.java+1063−0

This diff is large: its 1064 lines aren’t shown here.

java/pkg/com/sun/tools/example/debug/tty/TTYResources.java+456−0

This diff is large: its 457 lines aren’t shown here.

java/pkg/com/sun/tools/example/debug/tty/TTYResources_ja.java+327−0

This diff is large: its 328 lines aren’t shown here.

java/pkg/com/sun/tools/example/debug/tty/TTYResources_zh_CN.java+327−0

This diff is large: its 328 lines aren’t shown here.

java/pkg/com/sun/tools/example/debug/tty/ThreadGroupIterator.java+104−0

This diff is large: its 105 lines aren’t shown here.

java/pkg/com/sun/tools/example/debug/tty/ThreadInfo.java+287−0

This diff is large: its 288 lines aren’t shown here.

java/pkg/com/sun/tools/example/debug/tty/ThreadIterator.java+73−0

This diff is large: its 74 lines aren’t shown here.

java/pkg/com/sun/tools/example/debug/tty/VMConnection.java+376−0

This diff is large: its 377 lines aren’t shown here.

java/pkg/com/sun/tools/example/debug/tty/VMNotConnectedException.java+39−0

This diff is large: its 40 lines aren’t shown here.

java/pkg/com/sun/tools/example/debug/tty/WatchpointSpec.java+68−0

This diff is large: its 69 lines aren’t shown here.

java/pkg/com/sun/tools/example/debug/tty/mkfile+34−0

This diff is large: its 35 lines aren’t shown here.