Home | History | Annotate | Download | only in stacks
      1 /*
      2  * Copyright (C) 2016 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 com.android.bugreport.stacks;
     18 
     19 import java.util.ArrayList;
     20 
     21 /**
     22  * A java stack frame within a thread.
     23  *
     24  * This includes both java and jni, which are indicated by the language
     25  * field being set to either LANGUAGE_JAVA or LANGUAGE_JNI.
     26  */
     27 public class JavaStackFrameSnapshot extends StackFrameSnapshot {
     28     public static final int LANGUAGE_JAVA = 0;
     29     public static final int LANGUAGE_JNI = 1;
     30 
     31     public String packageName;
     32     public String className;
     33     public String methodName;
     34     public String sourceFile;
     35     public int sourceLine;
     36     public int language;
     37     public ArrayList<LockSnapshot> locks = new ArrayList<LockSnapshot>();
     38 
     39     public JavaStackFrameSnapshot() {
     40         super(FRAME_TYPE_JAVA);
     41     }
     42 
     43     public JavaStackFrameSnapshot(JavaStackFrameSnapshot that) {
     44         super(that);
     45         this.packageName = that.packageName;
     46         this.className = that.className;
     47         this.methodName = that.methodName;
     48         this.sourceFile = that.sourceFile;
     49         this.sourceLine = that.sourceLine;
     50         this.language = that.language;
     51         final int N = that.locks.size();
     52         for (int i=0; i<N; i++) {
     53             this.locks.add(that.locks.get(i).clone());
     54         }
     55     }
     56 
     57     @Override
     58     public JavaStackFrameSnapshot clone() {
     59         return new JavaStackFrameSnapshot(this);
     60     }
     61 
     62 }
     63 
     64