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/bdi/EventRequestSpecList.java (1 of 18352 files). Show all

Unified · Split

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+}