jdk/src/share/classes/com/sun/tools/example/debug/tty/ModificationWatchpointSpec.java
author alanb
Fri, 02 Nov 2012 15:50:11 +0000
changeset 14342 8435a30053c1
parent 10292 ed7db6a12c2a
permissions -rw-r--r--
7197491: update copyright year to match last edit in jdk8 jdk repository Reviewed-by: chegar, ksrini
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     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
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    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
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
package com.sun.tools.example.debug.tty;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
import com.sun.jdi.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
import com.sun.jdi.request.EventRequestManager;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
import com.sun.jdi.request.EventRequest;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
class ModificationWatchpointSpec extends WatchpointSpec {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
    ModificationWatchpointSpec(ReferenceTypeSpec refSpec, String fieldId)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
                                  throws MalformedMemberNameException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
        super(refSpec, fieldId);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
     * The 'refType' is known to match, return the EventRequest.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
     */
9520
99d378796e54 7029383: Refresh of non-client demos
nloodin
parents: 5506
diff changeset
    50
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
    EventRequest resolveEventRequest(ReferenceType refType)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
                                      throws NoSuchFieldException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
        Field field = refType.fieldByName(fieldId);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
        EventRequestManager em = refType.virtualMachine().eventRequestManager();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
        EventRequest wp = em.createModificationWatchpointRequest(field);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
        wp.setSuspendPolicy(suspendPolicy);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
        wp.enable();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
        return wp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
9520
99d378796e54 7029383: Refresh of non-client demos
nloodin
parents: 5506
diff changeset
    61
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
    public String toString() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
        return MessageOutput.format("watch modification of",
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
                                    new Object [] {refSpec.toString(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
                                                   fieldId});
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
}