1 /*
2  * Copyright (C) 2017 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package dalvik.system;
18 
19 /**
20  * A class encapsulating a StackTraceElement and lock state. This adds
21  * critical thread state to the standard stack trace information, which
22  * can be used to detect deadlocks at the Java level.
23  *
24  * @hide
25  */
26 @libcore.api.CorePlatformApi
27 public class AnnotatedStackTraceElement {
28     /**
29      * The traditional StackTraceElement describing the Java stack frame.
30      */
31     private StackTraceElement stackTraceElement;
32 
33     /**
34      * An array containing objects that are locked in this frame. May be null.
35      */
36     private Object[] heldLocks;
37 
38     /**
39      * If this frame denotes the top of stack, <code>blockedOn<code> will hold
40      * the object this thread is waiting to lock, or waiting on, if any. May be
41      * null.
42      */
43     private Object blockedOn;
44 
45     // Internal allocation, only.
AnnotatedStackTraceElement()46     private AnnotatedStackTraceElement() {
47     }
48 
49     @libcore.api.CorePlatformApi
getStackTraceElement()50     public StackTraceElement getStackTraceElement() {
51         return stackTraceElement;
52     }
53 
54     @libcore.api.CorePlatformApi
getHeldLocks()55     public Object[] getHeldLocks() {
56         return heldLocks;
57     }
58 
59     @libcore.api.CorePlatformApi
getBlockedOn()60     public Object getBlockedOn() {
61         return blockedOn;
62     }
63 }
64