hotspot/agent/test/jdi/sagtest.java
author jjg
Wed, 20 May 2009 13:36:23 -0700
changeset 2982 090c71af18f6
parent 1 489c9b5090e2
child 5547 f4b087cbb361
permissions -rw-r--r--
6827026: Change javac source and target default to 7 Reviewed-by: darcy, ohair
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
489c9b5090e2 Initial load
duke
parents:
diff changeset
     2
 * Copyright 2002-2004 Sun Microsystems, Inc.  All Rights Reserved.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     4
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
489c9b5090e2 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
489c9b5090e2 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     8
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
489c9b5090e2 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
489c9b5090e2 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    14
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
489c9b5090e2 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    18
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    19
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    20
 * CA 95054 USA or visit www.sun.com if you need additional information or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    21
 * have any questions.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
489c9b5090e2 Initial load
duke
parents:
diff changeset
    25
/**
489c9b5090e2 Initial load
duke
parents:
diff changeset
    26
 *  @test *  @bug 0000000
489c9b5090e2 Initial load
duke
parents:
diff changeset
    27
 *  @summary This is just an exercise of various JDI elements for use in
489c9b5090e2 Initial load
duke
parents:
diff changeset
    28
 *           testing the SA/JDI client
489c9b5090e2 Initial load
duke
parents:
diff changeset
    29
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    30
 *  @author jjh
489c9b5090e2 Initial load
duke
parents:
diff changeset
    31
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
 *  @run build TestScaffold VMConnection TargetListener TargetAdapter sagdoit
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
 *  @run compile -g -source 1.5 sagtarg.java
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
 *  @run main sagtest
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
import com.sun.jdi.*;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
import com.sun.jdi.event.*;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
import com.sun.jdi.request.*;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
import java.util.*;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
    /********** target program **********/
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
// The target program is sagtarg.java
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
    /********** test program **********/
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
public class sagtest extends TestScaffold {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
    ReferenceType targetClass;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
    ThreadReference mainThread;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
    sagtest (String args[]) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
        super(args);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
    public static void main(String[] args)      throws Exception {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
        new sagtest(args).startTests();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
    /********** event handlers **********/
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
    /********** test core **********/
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
    protected void runTests() throws Exception {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
        /*
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
         * Get to the top of main()
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
         * to determine targetClass and mainThread
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
         */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
        BreakpointEvent bpe = startToMain("sagtarg");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
        targetClass = bpe.location().declaringType();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
        mainThread = bpe.thread();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
        EventRequestManager erm = vm().eventRequestManager();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
        stepOverLine(mainThread);  //stop on 18
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
        stepOverLine(mainThread);  //stop on 19
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
        stepOverLine(mainThread);  //stop on 20
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
        stepOverLine(mainThread);  //stop on 21
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
        stepOverLine(mainThread);  //stop on 22
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
        sagdoit mine = new sagdoit(vm());
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
        mine.doAll();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
        if (!testFailed) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
            println("sagtest: passed");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
        } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
            throw new Exception("sagtest: failed");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
}