• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 package shark.internal
2 
3 import shark.LibraryLeakReferenceMatcher
4 import shark.internal.Reference.LazyDetails.Resolver
5 
6 internal class Reference(
7   /**
8    * The value of the reference, i.e. the object the reference is pointing to.
9    */
10   val valueObjectId: Long,
11 
12   /**
13    * Low priority references are references that should be explored after any non low priority
14    * reference has been explored. This ensures that such references are not on the shortest best
15    * path if there is any other path that doesn't include any low priority reference.
16    *
17    * This is useful to highlight references that most likely exist due to known leaks (which means
18    * we can potentially find unknown leaks instead) as well as references which are harder to
19    * interpret for developers (such as java locals).
20    */
21   val isLowPriority: Boolean,
22 
23   val lazyDetailsResolver: Resolver
24 ) {
25   class LazyDetails(
26     val name: String,
27     val locationClassObjectId: Long,
28     val locationType: ReferenceLocationType,
29     /**
30      * Non null if this reference matches a known library leak pattern, null otherwise.
31      *
32      * Usually associated  with [Reference.isLowPriority] being true, so that the shortest path
33      * finder will only go through matching references after it has exhausted references that don't
34      * match, prioritizing finding an application leak over a known library leak.
35      */
36     val matchedLibraryLeak: LibraryLeakReferenceMatcher?,
37     // TODO Better name
38     val isVirtual: Boolean
39   ) {
40     /**
41      * Implementations should keep the minimal state they need and if needed rehydrate the objects
42      * when resolving.
43      */
interfacenull44     fun interface Resolver {
45       fun resolve(): LazyDetails
46     }
47   }
48 }
49