author | alanb |
Fri, 02 Nov 2012 15:50:11 +0000 | |
changeset 14342 | 8435a30053c1 |
parent 10292 | ed7db6a12c2a |
permissions | -rw-r--r-- |
2 | 1 |
/* |
14342
8435a30053c1
7197491: update copyright year to match last edit in jdk8 jdk repository
alanb
parents:
10292
diff
changeset
|
2 |
* Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved. |
2 | 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 |
|
5506 | 7 |
* published by the Free Software Foundation. Oracle designates this |
2 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5506 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
2 | 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 |
* |
|
5506 | 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. |
|
2 | 24 |
*/ |
25 |
||
10292
ed7db6a12c2a
7067811: Update demo/sample code to state it should not be used for production
nloodin
parents:
9520
diff
changeset
|
26 |
/* |
ed7db6a12c2a
7067811: Update demo/sample code to state it should not be used for production
nloodin
parents:
9520
diff
changeset
|
27 |
* This source code is provided to illustrate the usage of a given feature |
ed7db6a12c2a
7067811: Update demo/sample code to state it should not be used for production
nloodin
parents:
9520
diff
changeset
|
28 |
* or technique and has been deliberately simplified. Additional steps |
ed7db6a12c2a
7067811: Update demo/sample code to state it should not be used for production
nloodin
parents:
9520
diff
changeset
|
29 |
* required for a production-quality application, such as security checks, |
ed7db6a12c2a
7067811: Update demo/sample code to state it should not be used for production
nloodin
parents:
9520
diff
changeset
|
30 |
* input validation and proper error handling, might not be present in |
ed7db6a12c2a
7067811: Update demo/sample code to state it should not be used for production
nloodin
parents:
9520
diff
changeset
|
31 |
* this sample code. |
ed7db6a12c2a
7067811: Update demo/sample code to state it should not be used for production
nloodin
parents:
9520
diff
changeset
|
32 |
*/ |
ed7db6a12c2a
7067811: Update demo/sample code to state it should not be used for production
nloodin
parents:
9520
diff
changeset
|
33 |
|
ed7db6a12c2a
7067811: Update demo/sample code to state it should not be used for production
nloodin
parents:
9520
diff
changeset
|
34 |
|
2 | 35 |
package com.sun.tools.example.debug.tty; |
36 |
||
37 |
import com.sun.jdi.*; |
|
38 |
import com.sun.jdi.request.EventRequestManager; |
|
39 |
import com.sun.jdi.request.EventRequest; |
|
40 |
||
41 |
class ModificationWatchpointSpec extends WatchpointSpec { |
|
42 |
ModificationWatchpointSpec(ReferenceTypeSpec refSpec, String fieldId) |
|
43 |
throws MalformedMemberNameException { |
|
44 |
super(refSpec, fieldId); |
|
45 |
} |
|
46 |
||
47 |
/** |
|
48 |
* The 'refType' is known to match, return the EventRequest. |
|
49 |
*/ |
|
9520 | 50 |
@Override |
2 | 51 |
EventRequest resolveEventRequest(ReferenceType refType) |
52 |
throws NoSuchFieldException { |
|
53 |
Field field = refType.fieldByName(fieldId); |
|
54 |
EventRequestManager em = refType.virtualMachine().eventRequestManager(); |
|
55 |
EventRequest wp = em.createModificationWatchpointRequest(field); |
|
56 |
wp.setSuspendPolicy(suspendPolicy); |
|
57 |
wp.enable(); |
|
58 |
return wp; |
|
59 |
} |
|
60 |
||
9520 | 61 |
@Override |
2 | 62 |
public String toString() { |
63 |
return MessageOutput.format("watch modification of", |
|
64 |
new Object [] {refSpec.toString(), |
|
65 |
fieldId}); |
|
66 |
} |
|
67 |
} |