// The `ImageClassMap` maps a `TypeReference` to the maximum needed array dimension. // // Note: There can be identical descriptors in different dex files. // These are treated as different types as they may be loaded by different // class loaders, for example when `DelegateLastClassLoader` is involved. class ImageClassMap { public: // Add an image class with the required maximum array dimensions if not yet present. // All lower dimensions are implicitly added. For example, if `type_ref` represents // `LCls;` and `array_dim` is 2, this effectively adds `[[LCls;`, `[LCls;` and `LCls;`. // Pass `array_dim = 0` to add only the non-array class. // // The `type_ref` should reference a class that has a class definition in the dex file, // or a primitive type descriptor for the `core-oj` component of the primary boot image. void Add(TypeReference type_ref, size_t array_dim);
// Remove an image class. The `type_ref` should reference a non-array class and all // its array classes are implicitly removed. // // Note: This can be used to remove primitive types but we should never need to do that. // For `core-oj`, we should include all primitive types and for other dex files, we // should never add primitive types at all. void Remove(TypeReference type_ref);
// Check if the class referenced by `type_ref` is present with at least `array_dim` dimensions. // The `type_ref` should reference a non-array class, see `Add()`. bool Contains(TypeReference type_ref, size_t array_dim) const;
// Check if the class referenced by `dex_file` and `descriptor` is present with at least // `array_dim` dimensions. The `descriptor` should be a non-array descriptor. // Lookup by descriptor is supported to avoid searching for the `TypeId` in the dex file. bool Contains(const DexFile* dex_file, std::string_view descriptor, size_t array_dim) const;
// Visit each entry, passing the `TypeReference type_ref` and `size_t array_dim` to `visitor`. template <typename Visitor> void ForEach(Visitor&& visitor) const;
size_t size() const { return map_.size();
}
bool empty() const { return map_.empty();
}
private: // Using local version of `TypeReference` that can be default-constructed. struct TypeRef {
TypeRef() : dex_file(nullptr), type_index(0u) {} explicit TypeRef(TypeReference type_ref)
: dex_file(type_ref.dex_file), type_index(type_ref.TypeIndex()) {}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.