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

A lightweight handle to a single DEX field. More...

#include <analysis/field.hpp>

Public Member Functions

std::string_view name () const
 Simple name of the field (e.g. "out", "TAG").
 
ClassRef declaring_class () const
 ClassRef for the class that declares this field.
 
std::string_view type () const
 Descriptor of the field's declared type, such as "I" or "Ljava/lang/String;".
 
FieldId id () const
 The field's identity: its class, name and type.
 
AccessFlags access_flags () const
 
bool is_public () const
 
bool is_static () const
 
bool is_final () const
 
std::vector< Annotation > annotations () const
 Annotations attached to this field, resolved.
 
std::optional< AnnotationValue > initial_value () const
 The recorded initial value of a static field, from the class's static_values encoded array.
 
bool operator== (const Field &) const =default
 Two handles are equal when they come from the same analysis (one AnalysisContext, or copies of it) and point at the same field of the same DEX file.
 

Friends

struct std::hash< Field >
 
class Class
 

Detailed Description

A lightweight handle to a single DEX field.

Get one from Class::fields(). The handle keeps shared ownership of the analysis, so it remains valid after every AnalysisContext wrapper has been destroyed. It stores the absolute field_ids index and the access flags from the EncodedField entry in class_data_item.

Member Function Documentation

◆ name()

std::string_view dex::Field::name ( ) const

Simple name of the field (e.g. "out", "TAG").

◆ declaring_class()

ClassRef dex::Field::declaring_class ( ) const

ClassRef for the class that declares this field.

◆ type()

std::string_view dex::Field::type ( ) const

Descriptor of the field's declared type, such as "I" or "Ljava/lang/String;".

The view stays valid for the lifetime of the AnalysisContext.

◆ id()

FieldId dex::Field::id ( ) const

The field's identity: its class, name and type.

It is the identity the cross-references use, so a Field can be looked up in them with it.

◆ access_flags()

AccessFlags dex::Field::access_flags ( ) const
inline

◆ is_public()

bool dex::Field::is_public ( ) const
inline

◆ is_static()

bool dex::Field::is_static ( ) const
inline

◆ is_final()

bool dex::Field::is_final ( ) const
inline

◆ annotations()

std::vector< Annotation > dex::Field::annotations ( ) const

Annotations attached to this field, resolved.

Parsed on demand.

◆ initial_value()

std::optional< AnnotationValue > dex::Field::initial_value ( ) const

The recorded initial value of a static field, from the class's static_values encoded array.

nullopt when the field is not static, has no recorded value, or sits past the array's prefix — all of which mean "the type's default value" (0 / null) at runtime.

◆ operator==()

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

Two handles are equal when they come from the same analysis (one AnalysisContext, or copies of it) and point at the same field of the same DEX file.

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

Friends And Related Symbol Documentation

◆ std::hash< Field >

friend struct std::hash< Field >
friend

◆ Class

friend class Class
friend

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