ActualMatchingReferenceReaderFactory.kt
TLDR
The file ActualMatchingReferenceReaderFactory.kt
contains a class ActualMatchingReferenceReaderFactory
that creates instances of ReferenceReader
to follow references from HeapObject
s using matching rules provided by referenceMatchers
. It implements the ReferenceReader.Factory
interface.
Classes
ActualMatchingReferenceReaderFactory
This class is responsible for creating instances of ReferenceReader
that follow references from HeapObject
s using matching rules provided by referenceMatchers
. It implements the ReferenceReader.Factory<HeapObject>
interface. The createFor
method creates and returns a DelegatingObjectReferenceReader
instance, which internally uses various implementations of ReferenceReader
to handle different types of references (class references, instance references, object array references).
package shark
/**
* Creates [ReferenceReader] instances that will follow references from all [HeapObject]s,
* applying matching rules provided by [referenceMatchers], and not creating any virtual reference.
*/
class ActualMatchingReferenceReaderFactory(
private val referenceMatchers: List<ReferenceMatcher>
) : ReferenceReader.Factory<HeapObject> {
override fun createFor(heapGraph: HeapGraph): ReferenceReader<HeapObject> {
return DelegatingObjectReferenceReader(
classReferenceReader = ClassReferenceReader(heapGraph, referenceMatchers),
instanceReferenceReader = ChainingInstanceReferenceReader(
listOf(JavaLocalReferenceReader(heapGraph, referenceMatchers)),
FieldInstanceReferenceReader(heapGraph, referenceMatchers)
), objectArrayReferenceReader = ObjectArrayReferenceReader()
)
}
}