test/jdk/com/sun/jdi/MonitorFrameInfo.java
changeset 58681 5f14a659a8cb
parent 47216 71c04702a3d5
equal deleted inserted replaced
58676:92e7d617897e 58681:5f14a659a8cb
     1 /*
     1 /*
     2  * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     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
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     7  * published by the Free Software Foundation.
    31  *
    31  *
    32  * @run build TestScaffold VMConnection TargetListener TargetAdapter
    32  * @run build TestScaffold VMConnection TargetListener TargetAdapter
    33  * @run compile -g MonitorFrameInfo.java
    33  * @run compile -g MonitorFrameInfo.java
    34  * @run driver MonitorFrameInfo
    34  * @run driver MonitorFrameInfo
    35  */
    35  */
    36 import com.sun.jdi.*;
    36 import java.util.List;
    37 import com.sun.jdi.event.*;
       
    38 import com.sun.jdi.request.*;
       
    39 
    37 
    40 import java.util.*;
    38 import com.sun.jdi.InvalidStackFrameException;
       
    39 import com.sun.jdi.MonitorInfo;
       
    40 import com.sun.jdi.ReferenceType;
       
    41 import com.sun.jdi.ThreadReference;
       
    42 import com.sun.jdi.event.BreakpointEvent;
    41 
    43 
    42     /********** target program **********/
    44     /********** target program **********/
    43 
    45 
    44 class MonitorTestTarg {
    46 class MonitorFrameInfoTarg {
    45     static void foo3() {
    47     static void foo3() {
    46         System.out.println("executing foo3");
    48         System.out.println("executing foo3");
    47 
    49 
    48     }
    50     }
    49     static void foo2() {
    51     static void foo2() {
    69     /********** test program **********/
    71     /********** test program **********/
    70 
    72 
    71 public class MonitorFrameInfo extends TestScaffold {
    73 public class MonitorFrameInfo extends TestScaffold {
    72     ReferenceType targetClass;
    74     ReferenceType targetClass;
    73     ThreadReference mainThread;
    75     ThreadReference mainThread;
    74     List monitors;
    76     List<MonitorInfo> monitors;
    75 
    77 
    76     static int expectedCount = 2;
    78     static int expectedCount = 2;
    77     static int[] expectedDepth = { 1, 3 };
    79     static int[] expectedDepth = { 1, 3 };
    78 
    80 
    79     static String[] expectedNames = {"foo3", "foo2", "foo1", "main"};
    81     static String[] expectedNames = {"foo3", "foo2", "foo1", "main"};
    91     protected void runTests() throws Exception {
    93     protected void runTests() throws Exception {
    92         /*
    94         /*
    93          * Get to the top of main()
    95          * Get to the top of main()
    94          * to determine targetClass and mainThread
    96          * to determine targetClass and mainThread
    95          */
    97          */
    96         BreakpointEvent bpe = startToMain("MonitorTestTarg");
    98         BreakpointEvent bpe = startToMain("MonitorFrameInfoTarg");
    97         targetClass = bpe.location().declaringType();
    99         targetClass = bpe.location().declaringType();
    98         mainThread = bpe.thread();
   100         mainThread = bpe.thread();
    99 
   101 
   100         int initialSize = mainThread.frames().size();
   102         int initialSize = mainThread.frames().size();
   101 
   103 
   102         resumeTo("MonitorTestTarg", "foo3", "()V");
   104         resumeTo("MonitorFrameInfoTarg", "foo3", "()V");
   103 
   105 
   104         if (!mainThread.frame(0).location().method().name()
   106         if (!mainThread.frame(0).location().method().name()
   105                         .equals("foo3")) {
   107                         .equals("foo3")) {
   106             failure("FAILED: frame failed");
   108             failure("FAILED: frame failed");
   107         }
   109         }