|
dex++ 0.3.1
C++ and C API reference
|
Whole-program inheritance and interface-implementation graph. More...
#include <analysis/class_hierarchy.hpp>
Public Member Functions | |
| ClassHierarchy ()=default | |
| ClassHierarchy (const ClassHierarchy &)=delete | |
| ClassHierarchy & | operator= (const ClassHierarchy &)=delete |
| ClassHierarchy (ClassHierarchy &&)=default | |
| ClassHierarchy & | operator= (ClassHierarchy &&)=default |
| std::vector< std::string_view > | supertypes (std::string_view descriptor) const |
| Direct supertypes: at most one superclass plus any directly implemented interfaces, in that order. | |
| std::optional< std::string_view > | superclass_of (std::string_view descriptor) const |
| The direct superclass descriptor, or nullopt when none is recorded — for Object, for descriptors not in the graph, and for unloaded placeholder nodes (the chain is unknown past a framework boundary; the three cases are not distinguished). | |
| std::vector< std::string_view > | direct_interfaces (std::string_view descriptor) const |
| Directly implemented (or, for an interface, directly extended) interface descriptors, in declaration order. | |
| std::vector< std::string_view > | subclasses (std::string_view descriptor) const |
Direct subclasses: classes whose extends clause names descriptor. | |
| std::vector< std::string_view > | implementers (std::string_view descriptor) const |
Direct implementers: classes whose implements clause names descriptor. | |
| std::vector< std::string_view > | all_supertypes (std::string_view descriptor) const |
| Transitive supertypes (BFS). | |
| std::vector< std::string_view > | all_descendants (std::string_view descriptor) const |
Transitive descendants: every class that extends descriptor (directly or transitively) plus every class that implements descriptor (if it's an interface), recursively. | |
| bool | is_subtype_of (std::string_view sub, std::string_view super) const |
True iff super == sub (reflexive) or super appears in all_supertypes(@p sub). | |
| bool | is_loaded (std::string_view descriptor) const |
| True iff a class with this descriptor is defined in some loaded DEX. | |
| bool | is_interface (std::string_view descriptor) const |
| True iff the descriptor is loaded AND has the Interface access flag. | |
| bool | empty () const |
Whole-program inheritance and interface-implementation graph.
Built lazily on first AnalysisContext::class_hierarchy() access and cached on the underlying impl. Every class descriptor referenced as a superclass or interface is represented, even if the class is not defined in any loaded DEX file (e.g. Ljava/lang/Object;) — those nodes have is_loaded() == false and no direct supertypes recorded, but participate in subtype queries initiated from loaded descendants.
A class defined in more than one loaded DEX file takes its superclass, interfaces and interface flag from its first definition only: the one AnalysisContext::find_class() returns, and the one Android loads.
All query results return std::string_view views into the hierarchy's internal storage; valid for the lifetime of the AnalysisContext.
Move-only: copying would deep-copy the entire descriptor index.
|
default |
|
delete |
|
default |
|
delete |
|
default |
| std::vector< std::string_view > dex::ClassHierarchy::supertypes | ( | std::string_view | descriptor | ) | const |
Direct supertypes: at most one superclass plus any directly implemented interfaces, in that order.
Empty if descriptor is not in the graph.
| std::optional< std::string_view > dex::ClassHierarchy::superclass_of | ( | std::string_view | descriptor | ) | const |
The direct superclass descriptor, or nullopt when none is recorded — for Object, for descriptors not in the graph, and for unloaded placeholder nodes (the chain is unknown past a framework boundary; the three cases are not distinguished).
The view points into the hierarchy's storage, valid for the AnalysisContext's lifetime.
| std::vector< std::string_view > dex::ClassHierarchy::direct_interfaces | ( | std::string_view | descriptor | ) | const |
Directly implemented (or, for an interface, directly extended) interface descriptors, in declaration order.
Empty for unknown or unloaded descriptors.
| std::vector< std::string_view > dex::ClassHierarchy::subclasses | ( | std::string_view | descriptor | ) | const |
Direct subclasses: classes whose extends clause names descriptor.
| std::vector< std::string_view > dex::ClassHierarchy::implementers | ( | std::string_view | descriptor | ) | const |
Direct implementers: classes whose implements clause names descriptor.
Only meaningful when descriptor is an interface.
| std::vector< std::string_view > dex::ClassHierarchy::all_supertypes | ( | std::string_view | descriptor | ) | const |
Transitive supertypes (BFS).
Includes both class ancestors and all ancestor interfaces. Does NOT include descriptor itself.
| std::vector< std::string_view > dex::ClassHierarchy::all_descendants | ( | std::string_view | descriptor | ) | const |
Transitive descendants: every class that extends descriptor (directly or transitively) plus every class that implements descriptor (if it's an interface), recursively.
Does NOT include descriptor itself.
| bool dex::ClassHierarchy::is_subtype_of | ( | std::string_view | sub, |
| std::string_view | super | ||
| ) | const |
True iff super == sub (reflexive) or super appears in all_supertypes(@p sub).
Returns false if sub is not in the graph.
| bool dex::ClassHierarchy::is_loaded | ( | std::string_view | descriptor | ) | const |
True iff a class with this descriptor is defined in some loaded DEX.
Descriptor-only nodes (referenced but not loaded) return false.
| bool dex::ClassHierarchy::is_interface | ( | std::string_view | descriptor | ) | const |
True iff the descriptor is loaded AND has the Interface access flag.
Returns false for unloaded descriptors (we cannot know without bytecode).
|
inline |