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.ahat.heapdump; 18 19 /** 20 * A single element along a reference path from a GC root to an instance in 21 * the heap dump. 22 * <p> 23 * For example, assuming object A is a root a path to some object X might look 24 * like: 25 * <pre> 26 * A.x --> B.y --> C.z --> X 27 * </pre> 28 * 29 * A path element is a single node of that path, such as <code>B.y</code>. 30 * @see AhatInstance#getPathFromGcRoot 31 */ 32 public class PathElement implements Diffable<PathElement> { 33 /** 34 * The instance along the reference path that this PathElement is associated 35 * with. 36 */ 37 public final AhatInstance instance; 38 39 /** 40 * A human readable description of which field in <code>instance</code> is 41 * followed to reach the next element in the path. 42 * Some examples: 43 * <ul> 44 * <li> "mBlah" for a class instance 45 * <li> "[4]" for an array instance 46 * <li> "" for the last element of the path 47 * </ul> 48 */ 49 public final String field; 50 51 /** 52 * True if <code>instance</code> is a (not necessarily immediate) dominator 53 * of the final object in the path. 54 */ 55 public boolean isDominator; 56 57 /** 58 * Constructs a PathElement object. 59 * <code>isDominator</code> is set to false. 60 * 61 * @param instance the path element instance 62 * @param field the path element field 63 */ PathElement(AhatInstance instance, String field)64 public PathElement(AhatInstance instance, String field) { 65 this.instance = instance; 66 this.field = field; 67 this.isDominator = false; 68 } 69 getBaseline()70 @Override public PathElement getBaseline() { 71 return this; 72 } 73 isPlaceHolder()74 @Override public boolean isPlaceHolder() { 75 return false; 76 } 77 } 78