dex++ 0.3.1
C++ and C API reference
Loading...
Searching...
No Matches
dex::ClassRef Class Reference

A reference to a class by its type descriptor, which may or may not be defined in the loaded DEX files: the superclass, the interfaces and the declaring class of a member are ClassRefs, because they can name a class from outside the app, such as "Ljava/lang/Object;". More...

#include <analysis/class_ref.hpp>

Public Member Functions

std::string_view descriptor () const
 The 'L...;' type descriptor string (e.g. "Ljava/lang/Object;").
 
std::optional< Class > resolve () const
 Looks up the class in the analysis it came from, the same way AnalysisContext::find_class() does.
 
bool is_resolved () const
 True when resolve() would find the class.
 
bool operator== (const ClassRef &) const =default
 Two references are equal when they come from the same analysis (one AnalysisContext, or copies of it) and name the same descriptor.
 

Friends

struct std::hash< ClassRef >
 
class Class
 
class Method
 
class Field
 

Detailed Description

A reference to a class by its type descriptor, which may or may not be defined in the loaded DEX files: the superclass, the interfaces and the declaring class of a member are ClassRefs, because they can name a class from outside the app, such as "Ljava/lang/Object;".

Get one from Class::superclass(), Class::interfaces(), Method::declaring_class() or Field::declaring_class(). ClassRef keeps shared ownership of the analysis, so it stays valid after every AnalysisContext wrapper has been destroyed, and it owns its descriptor. To look a class up by a descriptor you have, use AnalysisContext::find_class().

Member Function Documentation

◆ descriptor()

std::string_view dex::ClassRef::descriptor ( ) const
inline

The 'L...;' type descriptor string (e.g. "Ljava/lang/Object;").

The returned view is valid for this ClassRef's lifetime.

◆ resolve()

std::optional< Class > dex::ClassRef::resolve ( ) const

Looks up the class in the analysis it came from, the same way AnalysisContext::find_class() does.

Returns
the Class, or std::nullopt if no loaded DEX file defines it.

◆ is_resolved()

bool dex::ClassRef::is_resolved ( ) const

True when resolve() would find the class.

◆ operator==()

bool dex::ClassRef::operator== ( const ClassRef &  ) const
default

Two references are equal when they come from the same analysis (one AnalysisContext, or copies of it) and name the same descriptor.

References from two contexts that loaded the same file are not equal. std::hash<ClassRef> is consistent with it.

Friends And Related Symbol Documentation

◆ std::hash< ClassRef >

friend struct std::hash< ClassRef >
friend

◆ Class

friend class Class
friend

◆ Method

friend class Method
friend

◆ Field

friend class Field
friend

The documentation for this class was generated from the following file: