summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Gampe <agampe@google.com>2018-12-28 09:39:56 -0800
committerAndreas Gampe <agampe@google.com>2019-01-02 10:32:25 -0800
commit3f1dcd39e134d994ac88dcc4f30ec8cabcd8decf (patch)
tree365d20ad6b68ff1dbd4903764b63880324136e4d
parent0f0a4e40667c87fbd4ae5480eddbfd701bfabfa2 (diff)
downloadart-3f1dcd39e134d994ac88dcc4f30ec8cabcd8decf.tar.gz
art-3f1dcd39e134d994ac88dcc4f30ec8cabcd8decf.tar.bz2
art-3f1dcd39e134d994ac88dcc4f30ec8cabcd8decf.zip
ART: Move dex structs into own header
Separating out the structs from DexFile allows them to be forward- declared, which reduces the need to include the dex_file header. Bug: 119869270 Test: m Change-Id: I32dde5a632884bca7435cd584b4a81883de2e7b4
-rw-r--r--compiler/common_compiler_test.cc2
-rw-r--r--compiler/compiler.cc3
-rw-r--r--compiler/compiler.h10
-rw-r--r--compiler/debug/elf_debug_info_writer.h6
-rw-r--r--compiler/debug/elf_debug_writer.cc2
-rw-r--r--compiler/debug/method_debug_info.h2
-rw-r--r--compiler/dex/dex_to_dex_compiler.cc8
-rw-r--r--compiler/dex/dex_to_dex_compiler.h12
-rw-r--r--compiler/dex/inline_method_analyser.cc2
-rw-r--r--compiler/driver/compiler_driver-inl.h2
-rw-r--r--compiler/driver/compiler_driver.cc38
-rw-r--r--compiler/driver/compiler_driver.h8
-rw-r--r--compiler/driver/compiler_driver_test.cc2
-rw-r--r--compiler/driver/dex_compilation_unit.cc2
-rw-r--r--compiler/driver/dex_compilation_unit.h10
-rw-r--r--compiler/exception_test.cc4
-rw-r--r--compiler/optimizing/block_builder.cc16
-rw-r--r--compiler/optimizing/code_generator.cc4
-rw-r--r--compiler/optimizing/code_generator.h2
-rw-r--r--compiler/optimizing/graph_visualizer.cc2
-rw-r--r--compiler/optimizing/inliner.cc6
-rw-r--r--compiler/optimizing/inliner.h2
-rw-r--r--compiler/optimizing/instruction_builder.cc10
-rw-r--r--compiler/optimizing/nodes.cc2
-rw-r--r--compiler/optimizing/optimizing_compiler.cc12
-rw-r--r--compiler/optimizing/optimizing_unit_test.h2
-rw-r--r--compiler/verifier_deps_test.cc10
-rw-r--r--dex2oat/dex2oat_test.cc6
-rw-r--r--dex2oat/linker/image_test.h2
-rw-r--r--dex2oat/linker/image_writer.cc8
-rw-r--r--dex2oat/linker/oat_writer.cc6
-rw-r--r--dexdump/dexdump.cc76
-rw-r--r--dexlayout/dex_ir_builder.cc86
-rw-r--r--dexlayout/dex_writer.cc6
-rw-r--r--dexlayout/dexlayout.h2
-rw-r--r--dexlayout/dexlayout_test.cc6
-rw-r--r--dexlist/dexlist.cc6
-rw-r--r--libdexfile/dex/art_dex_file_loader_test.cc44
-rw-r--r--libdexfile/dex/class_accessor-inl.h8
-rw-r--r--libdexfile/dex/class_accessor.h8
-rw-r--r--libdexfile/dex/class_accessor_test.cc2
-rw-r--r--libdexfile/dex/code_item_accessors-inl.h18
-rw-r--r--libdexfile/dex/code_item_accessors.h25
-rw-r--r--libdexfile/dex/code_item_accessors_test.cc2
-rw-r--r--libdexfile/dex/compact_dex_file.cc2
-rw-r--r--libdexfile/dex/compact_dex_file.h4
-rw-r--r--libdexfile/dex/dex_file-inl.h66
-rw-r--r--libdexfile/dex/dex_file.cc74
-rw-r--r--libdexfile/dex/dex_file.h487
-rw-r--r--libdexfile/dex/dex_file_exception_helpers.cc7
-rw-r--r--libdexfile/dex/dex_file_exception_helpers.h10
-rw-r--r--libdexfile/dex/dex_file_loader_test.cc5
-rw-r--r--libdexfile/dex/dex_file_structs.h298
-rw-r--r--libdexfile/dex/dex_file_tracking_registrar.cc18
-rw-r--r--libdexfile/dex/dex_file_verifier.cc268
-rw-r--r--libdexfile/dex/dex_file_verifier.h18
-rw-r--r--libdexfile/dex/dex_file_verifier_test.cc14
-rw-r--r--libdexfile/dex/method_reference.h14
-rw-r--r--libdexfile/dex/standard_dex_file.cc2
-rw-r--r--libdexfile/dex/standard_dex_file.h4
-rw-r--r--libdexfile/dex/test_dex_file_builder.h24
-rw-r--r--libdexfile/dex/type_lookup_table.cc12
-rw-r--r--libprofile/profile/profile_compilation_info.cc2
-rw-r--r--oatdump/oatdump.cc14
-rw-r--r--openjdkjvmti/ti_class.cc4
-rw-r--r--openjdkjvmti/ti_redefine.cc37
-rw-r--r--openjdkjvmti/ti_redefine.h10
-rw-r--r--profman/profman.cc14
-rw-r--r--runtime/art_field-inl.h4
-rw-r--r--runtime/art_method-inl.h16
-rw-r--r--runtime/art_method.cc22
-rw-r--r--runtime/art_method.h11
-rw-r--r--runtime/class_linker-inl.h6
-rw-r--r--runtime/class_linker.cc67
-rw-r--r--runtime/class_linker.h22
-rw-r--r--runtime/class_linker_test.cc12
-rw-r--r--runtime/common_dex_operations.h3
-rw-r--r--runtime/debugger.cc2
-rw-r--r--runtime/dex/dex_file_annotations.cc203
-rw-r--r--runtime/dex/dex_file_annotations.h5
-rw-r--r--runtime/dex_to_dex_decompiler.cc4
-rw-r--r--runtime/dex_to_dex_decompiler.h10
-rw-r--r--runtime/hidden_api.cc12
-rw-r--r--runtime/imtable-inl.h8
-rw-r--r--runtime/interpreter/interpreter_common.cc6
-rw-r--r--runtime/interpreter/interpreter_common.h2
-rw-r--r--runtime/mirror/class-inl.h4
-rw-r--r--runtime/mirror/class.cc18
-rw-r--r--runtime/mirror/class.h7
-rw-r--r--runtime/mirror/dex_cache_test.cc4
-rw-r--r--runtime/mirror/object_test.cc8
-rw-r--r--runtime/native/dalvik_system_DexFile.cc4
-rw-r--r--runtime/native/dalvik_system_VMRuntime.cc4
-rw-r--r--runtime/native/java_lang_Class.cc2
-rw-r--r--runtime/native/java_lang_reflect_Executable.cc12
-rw-r--r--runtime/oat_file.cc14
-rw-r--r--runtime/oat_file.h12
-rw-r--r--runtime/oat_file_manager.cc2
-rw-r--r--runtime/reflection.cc6
-rw-r--r--runtime/runtime_callbacks.cc8
-rw-r--r--runtime/runtime_callbacks.h10
-rw-r--r--runtime/runtime_callbacks_test.cc4
-rw-r--r--runtime/transaction_test.cc2
-rw-r--r--runtime/vdex_file.cc4
-rw-r--r--runtime/verifier/method_verifier.cc58
-rw-r--r--runtime/verifier/method_verifier.h23
-rw-r--r--runtime/verifier/method_verifier_test.cc2
-rw-r--r--runtime/verifier/verifier_deps.cc22
-rw-r--r--tools/dexanalyze/dexanalyze_bytecode.cc2
-rw-r--r--tools/hiddenapi/hiddenapi.cc24
-rw-r--r--tools/hiddenapi/hiddenapi_test.cc14
-rw-r--r--tools/veridex/flow_analysis.cc8
-rw-r--r--tools/veridex/hidden_api.cc4
-rw-r--r--tools/veridex/resolver.cc18
-rw-r--r--tools/veridex/veridex.h11
115 files changed, 1377 insertions, 1249 deletions
diff --git a/compiler/common_compiler_test.cc b/compiler/common_compiler_test.cc
index 72afb985c0..07c73c9a20 100644
--- a/compiler/common_compiler_test.cc
+++ b/compiler/common_compiler_test.cc
@@ -264,7 +264,7 @@ void CommonCompilerTest::CompileMethod(ArtMethod* method) {
Handle<mirror::DexCache> dex_cache(hs.NewHandle(method->GetDexCache()));
Handle<mirror::ClassLoader> h_class_loader = hs.NewHandle(
self->DecodeJObject(class_loader)->AsClassLoader());
- const DexFile::CodeItem* code_item = dex_file->GetCodeItem(method->GetCodeItemOffset());
+ const dex::CodeItem* code_item = dex_file->GetCodeItem(method->GetCodeItemOffset());
std::vector<const DexFile*> dex_files;
dex_files.push_back(dex_file);
diff --git a/compiler/compiler.cc b/compiler/compiler.cc
index 646040fd9d..54da446e6d 100644
--- a/compiler/compiler.cc
+++ b/compiler/compiler.cc
@@ -21,6 +21,7 @@
#include "base/macros.h"
#include "base/utils.h"
#include "dex/code_item_accessors-inl.h"
+#include "dex/dex_file.h"
#include "driver/compiler_driver.h"
#include "optimizing/optimizing_compiler.h"
@@ -39,7 +40,7 @@ Compiler* Compiler::Create(CompilerDriver* driver, Compiler::Kind kind) {
}
}
-bool Compiler::IsPathologicalCase(const DexFile::CodeItem& code_item,
+bool Compiler::IsPathologicalCase(const dex::CodeItem& code_item,
uint32_t method_idx,
const DexFile& dex_file) {
/*
diff --git a/compiler/compiler.h b/compiler/compiler.h
index 8c07773f4c..8a67724de0 100644
--- a/compiler/compiler.h
+++ b/compiler/compiler.h
@@ -19,10 +19,13 @@
#include "base/mutex.h"
#include "base/os.h"
-#include "dex/dex_file.h"
+#include "dex/invoke_type.h"
namespace art {
+namespace dex {
+struct CodeItem;
+} // namespace dex
namespace jit {
class JitCodeCache;
class JitLogger;
@@ -35,6 +38,7 @@ class DexCache;
class ArtMethod;
class CompilerDriver;
class CompiledMethod;
+class DexFile;
template<class T> class Handle;
class OatWriter;
class Thread;
@@ -54,7 +58,7 @@ class Compiler {
virtual bool CanCompileMethod(uint32_t method_idx, const DexFile& dex_file) const = 0;
- virtual CompiledMethod* Compile(const DexFile::CodeItem* code_item,
+ virtual CompiledMethod* Compile(const dex::CodeItem* code_item,
uint32_t access_flags,
InvokeType invoke_type,
uint16_t class_def_idx,
@@ -102,7 +106,7 @@ class Compiler {
// Returns whether the method to compile is such a pathological case that
// it's not worth compiling.
- static bool IsPathologicalCase(const DexFile::CodeItem& code_item,
+ static bool IsPathologicalCase(const dex::CodeItem& code_item,
uint32_t method_idx,
const DexFile& dex_file);
diff --git a/compiler/debug/elf_debug_info_writer.h b/compiler/debug/elf_debug_info_writer.h
index bb550b3060..a63f241f53 100644
--- a/compiler/debug/elf_debug_info_writer.h
+++ b/compiler/debug/elf_debug_info_writer.h
@@ -152,9 +152,9 @@ class ElfCompilationUnitWriter {
DCHECK(mi->dex_file != nullptr);
const DexFile* dex = mi->dex_file;
CodeItemDebugInfoAccessor accessor(*dex, mi->code_item, mi->dex_method_index);
- const DexFile::MethodId& dex_method = dex->GetMethodId(mi->dex_method_index);
- const DexFile::ProtoId& dex_proto = dex->GetMethodPrototype(dex_method);
- const DexFile::TypeList* dex_params = dex->GetProtoParameters(dex_proto);
+ const dex::MethodId& dex_method = dex->GetMethodId(mi->dex_method_index);
+ const dex::ProtoId& dex_proto = dex->GetMethodPrototype(dex_method);
+ const dex::TypeList* dex_params = dex->GetProtoParameters(dex_proto);
const char* dex_class_desc = dex->GetMethodDeclaringClassDescriptor(dex_method);
const bool is_static = (mi->access_flags & kAccStatic) != 0;
diff --git a/compiler/debug/elf_debug_writer.cc b/compiler/debug/elf_debug_writer.cc
index 0f2d73e5aa..16f163b085 100644
--- a/compiler/debug/elf_debug_writer.cc
+++ b/compiler/debug/elf_debug_writer.cc
@@ -54,7 +54,7 @@ void WriteDebugInfo(linker::ElfBuilder<ElfTypes>* builder,
WriteCFISection(builder, debug_info.compiled_methods, cfi_format, write_oat_patches);
// Group the methods into compilation units based on class.
- std::unordered_map<const DexFile::ClassDef*, ElfCompilationUnit> class_to_compilation_unit;
+ std::unordered_map<const dex::ClassDef*, ElfCompilationUnit> class_to_compilation_unit;
for (const MethodDebugInfo& mi : debug_info.compiled_methods) {
if (mi.dex_file != nullptr) {
auto& dex_class_def = mi.dex_file->GetClassDef(mi.class_def_index);
diff --git a/compiler/debug/method_debug_info.h b/compiler/debug/method_debug_info.h
index 729c403f00..152db6eaf0 100644
--- a/compiler/debug/method_debug_info.h
+++ b/compiler/debug/method_debug_info.h
@@ -32,7 +32,7 @@ struct MethodDebugInfo {
size_t class_def_index;
uint32_t dex_method_index;
uint32_t access_flags;
- const DexFile::CodeItem* code_item;
+ const dex::CodeItem* code_item;
InstructionSet isa;
bool deduped;
bool is_native_debuggable;
diff --git a/compiler/dex/dex_to_dex_compiler.cc b/compiler/dex/dex_to_dex_compiler.cc
index cf52dd9cf3..23ce37ef1a 100644
--- a/compiler/dex/dex_to_dex_compiler.cc
+++ b/compiler/dex/dex_to_dex_compiler.cc
@@ -505,7 +505,7 @@ void DexToDexCompiler::CompilationState::CompileInvokeVirtual(Instruction* inst,
}
CompiledMethod* DexToDexCompiler::CompileMethod(
- const DexFile::CodeItem* code_item,
+ const dex::CodeItem* code_item,
uint32_t access_flags,
InvokeType invoke_type ATTRIBUTE_UNUSED,
uint16_t class_def_idx,
@@ -627,11 +627,11 @@ CompiledMethod* DexToDexCompiler::CompileMethod(
void DexToDexCompiler::SetDexFiles(const std::vector<const DexFile*>& dex_files) {
// Record what code items are already seen to detect when multiple methods have the same code
// item.
- std::unordered_set<const DexFile::CodeItem*> seen_code_items;
+ std::unordered_set<const dex::CodeItem*> seen_code_items;
for (const DexFile* dex_file : dex_files) {
for (ClassAccessor accessor : dex_file->GetClasses()) {
for (const ClassAccessor::Method& method : accessor.GetMethods()) {
- const DexFile::CodeItem* code_item = method.GetCodeItem();
+ const dex::CodeItem* code_item = method.GetCodeItem();
// Detect the shared code items.
if (!seen_code_items.insert(code_item).second) {
shared_code_items_.insert(code_item);
@@ -646,7 +646,7 @@ void DexToDexCompiler::UnquickenConflictingMethods() {
MutexLock mu(Thread::Current(), lock_);
size_t unquicken_count = 0;
for (const auto& pair : shared_code_item_quicken_info_) {
- const DexFile::CodeItem* code_item = pair.first;
+ const dex::CodeItem* code_item = pair.first;
const QuickenState& state = pair.second;
CHECK_GE(state.methods_.size(), 1u);
if (state.conflict_) {
diff --git a/compiler/dex/dex_to_dex_compiler.h b/compiler/dex/dex_to_dex_compiler.h
index 7253488f79..78309ae7ac 100644
--- a/compiler/dex/dex_to_dex_compiler.h
+++ b/compiler/dex/dex_to_dex_compiler.h
@@ -23,7 +23,6 @@
#include "base/bit_vector.h"
#include "base/mutex.h"
-#include "dex/dex_file.h"
#include "dex/invoke_type.h"
#include "dex/method_reference.h"
#include "handle.h"
@@ -34,6 +33,11 @@ namespace art {
class CompiledMethod;
class CompilerDriver;
class DexCompilationUnit;
+class DexFile;
+
+namespace dex {
+struct CodeItem;
+} // namespace dex
namespace mirror {
class ClassLoader;
@@ -50,7 +54,7 @@ class DexToDexCompiler {
explicit DexToDexCompiler(CompilerDriver* driver);
- CompiledMethod* CompileMethod(const DexFile::CodeItem* code_item,
+ CompiledMethod* CompileMethod(const dex::CodeItem* code_item,
uint32_t access_flags,
InvokeType invoke_type,
uint16_t class_def_idx,
@@ -105,9 +109,9 @@ class DexToDexCompiler {
std::unordered_map<const DexFile*, BitVector> should_quicken_;
// Guarded by lock_ during writing, accessed without a lock during quickening.
// This is safe because no thread is adding to the shared code items during the quickening phase.
- std::unordered_set<const DexFile::CodeItem*> shared_code_items_;
+ std::unordered_set<const dex::CodeItem*> shared_code_items_;
// Blacklisted code items are unquickened in UnquickenConflictingMethods.
- std::unordered_map<const DexFile::CodeItem*, QuickenState> shared_code_item_quicken_info_
+ std::unordered_map<const dex::CodeItem*, QuickenState> shared_code_item_quicken_info_
GUARDED_BY(lock_);
// Number of added code items.
size_t num_code_items_ GUARDED_BY(lock_) = 0u;
diff --git a/compiler/dex/inline_method_analyser.cc b/compiler/dex/inline_method_analyser.cc
index ba2ebd99a0..b0f025d092 100644
--- a/compiler/dex/inline_method_analyser.cc
+++ b/compiler/dex/inline_method_analyser.cc
@@ -511,7 +511,7 @@ bool InlineMethodAnalyser::AnalyseMethodCode(const CodeItemDataAccessor* code_it
}
bool InlineMethodAnalyser::IsSyntheticAccessor(MethodReference ref) {
- const DexFile::MethodId& method_id = ref.dex_file->GetMethodId(ref.index);
+ const dex::MethodId& method_id = ref.dex_file->GetMethodId(ref.index);
const char* method_name = ref.dex_file->GetMethodName(method_id);
// javac names synthetic accessors "access$nnn",
// jack names them "-getN", "-putN", "-wrapN".
diff --git a/compiler/driver/compiler_driver-inl.h b/compiler/driver/compiler_driver-inl.h
index 63dcb4664c..ec2e38bc7f 100644
--- a/compiler/driver/compiler_driver-inl.h
+++ b/compiler/driver/compiler_driver-inl.h
@@ -57,7 +57,7 @@ inline ObjPtr<mirror::Class> CompilerDriver::ResolveCompilingMethodsClass(
const DexCompilationUnit* mUnit) {
DCHECK_EQ(dex_cache->GetDexFile(), mUnit->GetDexFile());
DCHECK_EQ(class_loader.Get(), mUnit->GetClassLoader().Get());
- const DexFile::MethodId& referrer_method_id =
+ const dex::MethodId& referrer_method_id =
mUnit->GetDexFile()->GetMethodId(mUnit->GetDexMethodIndex());
return ResolveClass(soa, dex_cache, class_loader, referrer_method_id.class_idx_, mUnit);
}
diff --git a/compiler/driver/compiler_driver.cc b/compiler/driver/compiler_driver.cc
index 36beb5927a..e440eec735 100644
--- a/compiler/driver/compiler_driver.cc
+++ b/compiler/driver/compiler_driver.cc
@@ -344,7 +344,7 @@ void CompilerDriver::CompileAll(jobject class_loader,
static optimizer::DexToDexCompiler::CompilationLevel GetDexToDexCompilationLevel(
Thread* self, const CompilerDriver& driver, Handle<mirror::ClassLoader> class_loader,
- const DexFile& dex_file, const DexFile::ClassDef& class_def)
+ const DexFile& dex_file, const dex::ClassDef& class_def)
REQUIRES_SHARED(Locks::mutator_lock_) {
// When the dex file is uncompressed in the APK, we do not generate a copy in the .vdex
// file. As a result, dex2oat will map the dex file read-only, and we only need to check
@@ -389,7 +389,7 @@ static optimizer::DexToDexCompiler::CompilationLevel GetDexToDexCompilationLevel
const CompilerDriver& driver,
jobject jclass_loader,
const DexFile& dex_file,
- const DexFile::ClassDef& class_def) {
+ const dex::ClassDef& class_def) {
ScopedObjectAccess soa(self);
StackHandleScope<1> hs(soa.Self());
Handle<mirror::ClassLoader> class_loader(
@@ -416,7 +416,7 @@ template <typename CompileFn>
static void CompileMethodHarness(
Thread* self,
CompilerDriver* driver,
- const DexFile::CodeItem* code_item,
+ const dex::CodeItem* code_item,
uint32_t access_flags,
InvokeType invoke_type,
uint16_t class_def_idx,
@@ -465,7 +465,7 @@ static void CompileMethodHarness(
static void CompileMethodDex2Dex(
Thread* self,
CompilerDriver* driver,
- const DexFile::CodeItem* code_item,
+ const dex::CodeItem* code_item,
uint32_t access_flags,
InvokeType invoke_type,
uint16_t class_def_idx,
@@ -476,7 +476,7 @@ static void CompileMethodDex2Dex(
Handle<mirror::DexCache> dex_cache) {
auto dex_2_dex_fn = [](Thread* self ATTRIBUTE_UNUSED,
CompilerDriver* driver,
- const DexFile::CodeItem* code_item,
+ const dex::CodeItem* code_item,
uint32_t access_flags,
InvokeType invoke_type,
uint16_t class_def_idx,
@@ -527,7 +527,7 @@ static void CompileMethodDex2Dex(
static void CompileMethodQuick(
Thread* self,
CompilerDriver* driver,
- const DexFile::CodeItem* code_item,
+ const dex::CodeItem* code_item,
uint32_t access_flags,
InvokeType invoke_type,
uint16_t class_def_idx,
@@ -539,7 +539,7 @@ static void CompileMethodQuick(
auto quick_fn = [](
Thread* self,
CompilerDriver* driver,
- const DexFile::CodeItem* code_item,
+ const dex::CodeItem* code_item,
uint32_t access_flags,
InvokeType invoke_type,
uint16_t class_def_idx,
@@ -650,7 +650,7 @@ void CompilerDriver::CompileOne(Thread* self,
uint32_t method_idx,
uint32_t access_flags,
InvokeType invoke_type,
- const DexFile::CodeItem* code_item,
+ const dex::CodeItem* code_item,
Handle<mirror::DexCache> dex_cache,
Handle<mirror::ClassLoader> h_class_loader) {
// Can we run DEX-to-DEX compiler on this class ?
@@ -1125,7 +1125,7 @@ void CompilerDriver::LoadImageClasses(TimingLogger* timings,
ScopedNullHandle<mirror::ClassLoader>())
: nullptr;
if (klass == nullptr) {
- const DexFile::TypeId& type_id = dex_file->GetTypeId(exception_type_idx);
+ const dex::TypeId& type_id = dex_file->GetTypeId(exception_type_idx);
const char* descriptor = dex_file->GetTypeDescriptor(type_id);
LOG(FATAL) << "Failed to resolve class " << descriptor;
}
@@ -1596,7 +1596,7 @@ class ResolveClassFieldsAndMethodsVisitor : public CompilationVisitor {
// needs it, here we try to resolve fields and methods used in class
// definitions, since many of them many never be referenced by
// generated code.
- const DexFile::ClassDef& class_def = dex_file.GetClassDef(class_def_index);
+ const dex::ClassDef& class_def = dex_file.GetClassDef(class_def_index);
ScopedObjectAccess soa(self);
StackHandleScope<2> hs(soa.Self());
Handle<mirror::ClassLoader> class_loader(
@@ -1898,7 +1898,7 @@ class VerifyClassVisitor : public CompilationVisitor {
ScopedTrace trace(__FUNCTION__);
ScopedObjectAccess soa(Thread::Current());
const DexFile& dex_file = *manager_->GetDexFile();
- const DexFile::ClassDef& class_def = dex_file.GetClassDef(class_def_index);
+ const dex::ClassDef& class_def = dex_file.GetClassDef(class_def_index);
const char* descriptor = dex_file.GetClassDescriptor(class_def);
ClassLinker* class_linker = manager_->GetClassLinker();
jobject jclass_loader = manager_->GetClassLoader();
@@ -2032,7 +2032,7 @@ class SetVerifiedClassVisitor : public CompilationVisitor {
ScopedTrace trace(__FUNCTION__);
ScopedObjectAccess soa(Thread::Current());
const DexFile& dex_file = *manager_->GetDexFile();
- const DexFile::ClassDef& class_def = dex_file.GetClassDef(class_def_index);
+ const dex::ClassDef& class_def = dex_file.GetClassDef(class_def_index);
const char* descriptor = dex_file.GetClassDescriptor(class_def);
ClassLinker* class_linker = manager_->GetClassLinker();
jobject jclass_loader = manager_->GetClassLoader();
@@ -2097,8 +2097,8 @@ class InitializeClassVisitor : public CompilationVisitor {
ScopedTrace trace(__FUNCTION__);
jobject jclass_loader = manager_->GetClassLoader();
const DexFile& dex_file = *manager_->GetDexFile();
- const DexFile::ClassDef& class_def = dex_file.GetClassDef(class_def_index);
- const DexFile::TypeId& class_type_id = dex_file.GetTypeId(class_def.class_idx_);
+ const dex::ClassDef& class_def = dex_file.GetClassDef(class_def_index);
+ const dex::TypeId& class_type_id = dex_file.GetTypeId(class_def.class_idx_);
const char* descriptor = dex_file.StringDataByIdx(class_type_id.descriptor_idx_);
ScopedObjectAccess soa(Thread::Current());
@@ -2122,8 +2122,8 @@ class InitializeClassVisitor : public CompilationVisitor {
void TryInitializeClass(Handle<mirror::Class> klass, Handle<mirror::ClassLoader>& class_loader)
REQUIRES_SHARED(Locks::mutator_lock_) {
const DexFile& dex_file = klass->GetDexFile();
- const DexFile::ClassDef* class_def = klass->GetClassDef();
- const DexFile::TypeId& class_type_id = dex_file.GetTypeId(class_def->class_idx_);
+ const dex::ClassDef* class_def = klass->GetClassDef();
+ const dex::TypeId& class_type_id = dex_file.GetTypeId(class_def->class_idx_);
const char* descriptor = dex_file.StringDataByIdx(class_type_id.descriptor_idx_);
ScopedObjectAccessUnchecked soa(Thread::Current());
StackHandleScope<3> hs(soa.Self());
@@ -2278,7 +2278,7 @@ class InitializeClassVisitor : public CompilationVisitor {
StackHandleScope<1> hs(Thread::Current());
Handle<mirror::DexCache> dex_cache = hs.NewHandle(klass->GetDexCache());
- const DexFile::ClassDef* class_def = klass->GetClassDef();
+ const dex::ClassDef* class_def = klass->GetClassDef();
ClassLinker* class_linker = manager_->GetClassLinker();
// Check encoded final field values for strings and intern.
@@ -2320,7 +2320,7 @@ class InitializeClassVisitor : public CompilationVisitor {
self->ClearException();
return false;
}
- const DexFile::TypeList* types = m->GetParameterTypeList();
+ const dex::TypeList* types = m->GetParameterTypeList();
if (types != nullptr) {
for (uint32_t i = 0; i < types->Size(); ++i) {
dex::TypeIndex param_type_idx = types->GetTypeItem(i).type_idx_;
@@ -2575,7 +2575,7 @@ static void CompileDexFile(CompilerDriver* driver,
ClassLinker* class_linker = context.GetClassLinker();
jobject jclass_loader = context.GetClassLoader();
ClassReference ref(&dex_file, class_def_index);
- const DexFile::ClassDef& class_def = dex_file.GetClassDef(class_def_index);
+ const dex::ClassDef& class_def = dex_file.GetClassDef(class_def_index);
ClassAccessor accessor(dex_file, class_def_index);
CompilerDriver* const driver = context.GetCompiler();
// Skip compiling classes with generic verifier failures since they will still fail at runtime
diff --git a/compiler/driver/compiler_driver.h b/compiler/driver/compiler_driver.h
index 025a632a8e..6f8ec125bc 100644
--- a/compiler/driver/compiler_driver.h
+++ b/compiler/driver/compiler_driver.h
@@ -36,7 +36,6 @@
#include "class_status.h"
#include "compiler.h"
#include "dex/class_reference.h"
-#include "dex/dex_file.h"
#include "dex/dex_file_types.h"
#include "dex/dex_to_dex_compiler.h"
#include "dex/method_reference.h"
@@ -47,6 +46,10 @@
namespace art {
+namespace dex {
+struct CodeItem;
+} // namespace dex
+
namespace mirror {
class Class;
class DexCache;
@@ -62,6 +65,7 @@ class BitVector;
class CompiledMethod;
class CompilerOptions;
class DexCompilationUnit;
+class DexFile;
template<class T> class Handle;
struct InlineIGetIPutData;
class InstructionSetFeatures;
@@ -127,7 +131,7 @@ class CompilerDriver {
uint32_t method_idx,
uint32_t access_flags,
InvokeType invoke_type,
- const DexFile::CodeItem* code_item,
+ const dex::CodeItem* code_item,
Handle<mirror::DexCache> dex_cache,
Handle<mirror::ClassLoader> h_class_loader)
REQUIRES(!Locks::mutator_lock_);
diff --git a/compiler/driver/compiler_driver_test.cc b/compiler/driver/compiler_driver_test.cc
index b9241292ee..e73d0724c9 100644
--- a/compiler/driver/compiler_driver_test.cc
+++ b/compiler/driver/compiler_driver_test.cc
@@ -80,7 +80,7 @@ class CompilerDriverTest : public CommonCompilerTest {
void MakeDexFileExecutable(jobject class_loader, const DexFile& dex_file) {
ClassLinker* class_linker = Runtime::Current()->GetClassLinker();
for (size_t i = 0; i < dex_file.NumClassDefs(); i++) {
- const DexFile::ClassDef& class_def = dex_file.GetClassDef(i);
+ const dex::ClassDef& class_def = dex_file.GetClassDef(i);
const char* descriptor = dex_file.GetClassDescriptor(class_def);
ScopedObjectAccess soa(Thread::Current());
StackHandleScope<1> hs(soa.Self());
diff --git a/compiler/driver/dex_compilation_unit.cc b/compiler/driver/dex_compilation_unit.cc
index e5a6f0e177..0d0f074917 100644
--- a/compiler/driver/dex_compilation_unit.cc
+++ b/compiler/driver/dex_compilation_unit.cc
@@ -30,7 +30,7 @@ namespace art {
DexCompilationUnit::DexCompilationUnit(Handle<mirror::ClassLoader> class_loader,
ClassLinker* class_linker,
const DexFile& dex_file,
- const DexFile::CodeItem* code_item,
+ const dex::CodeItem* code_item,
uint16_t class_def_idx,
uint32_t method_idx,
uint32_t access_flags,
diff --git a/compiler/driver/dex_compilation_unit.h b/compiler/driver/dex_compilation_unit.h
index 757f0e7695..f68d93f0cb 100644
--- a/compiler/driver/dex_compilation_unit.h
+++ b/compiler/driver/dex_compilation_unit.h
@@ -39,7 +39,7 @@ class DexCompilationUnit : public DeletableArenaObject<kArenaAllocMisc> {
DexCompilationUnit(Handle<mirror::ClassLoader> class_loader,
ClassLinker* class_linker,
const DexFile& dex_file,
- const DexFile::CodeItem* code_item,
+ const dex::CodeItem* code_item,
uint16_t class_def_idx,
uint32_t method_idx,
uint32_t access_flags,
@@ -67,17 +67,17 @@ class DexCompilationUnit : public DeletableArenaObject<kArenaAllocMisc> {
return dex_method_idx_;
}
- const DexFile::CodeItem* GetCodeItem() const {
+ const dex::CodeItem* GetCodeItem() const {
return code_item_;
}
const char* GetShorty() const {
- const DexFile::MethodId& method_id = dex_file_->GetMethodId(dex_method_idx_);
+ const dex::MethodId& method_id = dex_file_->GetMethodId(dex_method_idx_);
return dex_file_->GetMethodShorty(method_id);
}
const char* GetShorty(uint32_t* shorty_len) const {
- const DexFile::MethodId& method_id = dex_file_->GetMethodId(dex_method_idx_);
+ const dex::MethodId& method_id = dex_file_->GetMethodId(dex_method_idx_);
return dex_file_->GetMethodShorty(method_id, shorty_len);
}
@@ -165,7 +165,7 @@ class DexCompilationUnit : public DeletableArenaObject<kArenaAllocMisc> {
const DexFile* const dex_file_;
- const DexFile::CodeItem* const code_item_;
+ const dex::CodeItem* const code_item_;
const uint16_t class_def_idx_;
const uint32_t dex_method_idx_;
const uint32_t access_flags_;
diff --git a/compiler/exception_test.cc b/compiler/exception_test.cc
index f0f179ca14..d5ceafeac9 100644
--- a/compiler/exception_test.cc
+++ b/compiler/exception_test.cc
@@ -135,8 +135,8 @@ TEST_F(ExceptionTest, FindCatchHandler) {
ASSERT_EQ(2u, accessor.TriesSize());
ASSERT_NE(0u, accessor.InsnsSizeInCodeUnits());
- const DexFile::TryItem& t0 = accessor.TryItems().begin()[0];
- const DexFile::TryItem& t1 = accessor.TryItems().begin()[1];
+ const dex::TryItem& t0 = accessor.TryItems().begin()[0];
+ const dex::TryItem& t1 = accessor.TryItems().begin()[1];
EXPECT_LE(t0.start_addr_, t1.start_addr_);
{
CatchHandlerIterator iter(accessor, 4 /* Dex PC in the first try block */);
diff --git a/compiler/optimizing/block_builder.cc b/compiler/optimizing/block_builder.cc
index d1ccbee5f5..3672cce4c5 100644
--- a/compiler/optimizing/block_builder.cc
+++ b/compiler/optimizing/block_builder.cc
@@ -68,7 +68,7 @@ bool HBasicBlockBuilder::CreateBranchTargets() {
// places where the program might fall through into/out of the a block and
// where TryBoundary instructions will be inserted later. Other edges which
// enter/exit the try blocks are a result of branches/switches.
- for (const DexFile::TryItem& try_item : code_item_accessor_.TryItems()) {
+ for (const dex::TryItem& try_item : code_item_accessor_.TryItems()) {
uint32_t dex_pc_start = try_item.start_addr_;
uint32_t dex_pc_end = dex_pc_start + try_item.insn_count_;
MaybeCreateBlockAt(dex_pc_start);
@@ -222,9 +222,9 @@ void HBasicBlockBuilder::ConnectBasicBlocks() {
}
// Returns the TryItem stored for `block` or nullptr if there is no info for it.
-static const DexFile::TryItem* GetTryItem(
+static const dex::TryItem* GetTryItem(
HBasicBlock* block,
- const ScopedArenaSafeMap<uint32_t, const DexFile::TryItem*>& try_block_info) {
+ const ScopedArenaSafeMap<uint32_t, const dex::TryItem*>& try_block_info) {
auto iterator = try_block_info.find(block->GetBlockId());
return (iterator == try_block_info.end()) ? nullptr : iterator->second;
}
@@ -235,7 +235,7 @@ static const DexFile::TryItem* GetTryItem(
// for a handler.
static void LinkToCatchBlocks(HTryBoundary* try_boundary,
const CodeItemDataAccessor& accessor,
- const DexFile::TryItem* try_item,
+ const dex::TryItem* try_item,
const ScopedArenaSafeMap<uint32_t, HBasicBlock*>& catch_blocks) {
for (CatchHandlerIterator it(accessor.GetCatchHandlerData(try_item->handler_off_));
it.HasNext();
@@ -279,7 +279,7 @@ void HBasicBlockBuilder::InsertTryBoundaryBlocks() {
// Keep a map of all try blocks and their respective TryItems. We do not use
// the block's pointer but rather its id to ensure deterministic iteration.
- ScopedArenaSafeMap<uint32_t, const DexFile::TryItem*> try_block_info(
+ ScopedArenaSafeMap<uint32_t, const dex::TryItem*> try_block_info(
std::less<uint32_t>(), local_allocator_->Adapter(kArenaAllocGraphBuilder));
// Obtain TryItem information for blocks with throwing instructions, and split
@@ -295,7 +295,7 @@ void HBasicBlockBuilder::InsertTryBoundaryBlocks() {
// loop for synchronized blocks.
if (ContainsElement(throwing_blocks_, block)) {
// Try to find a TryItem covering the block.
- const DexFile::TryItem* try_item = code_item_accessor_.FindTryItem(block->GetDexPc());
+ const dex::TryItem* try_item = code_item_accessor_.FindTryItem(block->GetDexPc());
if (try_item != nullptr) {
// Block throwing and in a TryItem. Store the try block information.
try_block_info.Put(block->GetBlockId(), try_item);
@@ -348,7 +348,7 @@ void HBasicBlockBuilder::InsertTryBoundaryBlocks() {
// that all predecessors are relinked to. This preserves loop headers (b/23895756).
for (const auto& entry : try_block_info) {
uint32_t block_id = entry.first;
- const DexFile::TryItem* try_item = entry.second;
+ const dex::TryItem* try_item = entry.second;
HBasicBlock* try_block = graph_->GetBlocks()[block_id];
for (HBasicBlock* predecessor : try_block->GetPredecessors()) {
if (GetTryItem(predecessor, try_block_info) != try_item) {
@@ -367,7 +367,7 @@ void HBasicBlockBuilder::InsertTryBoundaryBlocks() {
// the successor is not in the same TryItem.
for (const auto& entry : try_block_info) {
uint32_t block_id = entry.first;
- const DexFile::TryItem* try_item = entry.second;
+ const dex::TryItem* try_item = entry.second;
HBasicBlock* try_block = graph_->GetBlocks()[block_id];
// NOTE: Do not use iterators because SplitEdge would invalidate them.
for (size_t i = 0, e = try_block->GetSuccessors().size(); i < e; ++i) {
diff --git a/compiler/optimizing/code_generator.cc b/compiler/optimizing/code_generator.cc
index 04e0cc4bdd..9e2f5cd508 100644
--- a/compiler/optimizing/code_generator.cc
+++ b/compiler/optimizing/code_generator.cc
@@ -987,7 +987,7 @@ static void CheckCovers(uint32_t dex_pc,
// dex branch instructions.
static void CheckLoopEntriesCanBeUsedForOsr(const HGraph& graph,
const CodeInfo& code_info,
- const DexFile::CodeItem& code_item) {
+ const dex::CodeItem& code_item) {
if (graph.HasTryCatch()) {
// One can write loops through try/catch, which we do not support for OSR anyway.
return;
@@ -1029,7 +1029,7 @@ static void CheckLoopEntriesCanBeUsedForOsr(const HGraph& graph,
}
}
-ScopedArenaVector<uint8_t> CodeGenerator::BuildStackMaps(const DexFile::CodeItem* code_item) {
+ScopedArenaVector<uint8_t> CodeGenerator::BuildStackMaps(const dex::CodeItem* code_item) {
ScopedArenaVector<uint8_t> stack_map = GetStackMapStream()->Encode();
if (kIsDebugBuild && code_item != nullptr) {
CheckLoopEntriesCanBeUsedForOsr(*graph_, CodeInfo(stack_map.data()), *code_item);
diff --git a/compiler/optimizing/code_generator.h b/compiler/optimizing/code_generator.h
index 39966ff8ea..f70ecb612d 100644
--- a/compiler/optimizing/code_generator.h
+++ b/compiler/optimizing/code_generator.h
@@ -349,7 +349,7 @@ class CodeGenerator : public DeletableArenaObject<kArenaAllocCodeGenerator> {
void AddSlowPath(SlowPathCode* slow_path);
- ScopedArenaVector<uint8_t> BuildStackMaps(const DexFile::CodeItem* code_item_for_osr_check);
+ ScopedArenaVector<uint8_t> BuildStackMaps(const dex::CodeItem* code_item_for_osr_check);
size_t GetNumberOfJitRoots() const;
// Fills the `literals` array with literals collected during code generation.
diff --git a/compiler/optimizing/graph_visualizer.cc b/compiler/optimizing/graph_visualizer.cc
index 07966207f7..2a7bbcb72f 100644
--- a/compiler/optimizing/graph_visualizer.cc
+++ b/compiler/optimizing/graph_visualizer.cc
@@ -393,7 +393,7 @@ class HGraphVisualizerPrinter : public HGraphDelegateVisitor {
void VisitLoadMethodType(HLoadMethodType* load_method_type) override {
StartAttributeStream("load_kind") << "RuntimeCall";
const DexFile& dex_file = load_method_type->GetDexFile();
- const DexFile::ProtoId& proto_id = dex_file.GetProtoId(load_method_type->GetProtoIndex());
+ const dex::ProtoId& proto_id = dex_file.GetProtoId(load_method_type->GetProtoIndex());
StartAttributeStream("method_type") << dex_file.GetProtoSignature(proto_id);
}
diff --git a/compiler/optimizing/inliner.cc b/compiler/optimizing/inliner.cc
index 854228beb9..8440e9aa4c 100644
--- a/compiler/optimizing/inliner.cc
+++ b/compiler/optimizing/inliner.cc
@@ -1756,7 +1756,7 @@ bool HInliner::TryBuildAndInlineHelper(HInvoke* invoke_instruction,
HInstruction** return_replacement) {
DCHECK(!(resolved_method->IsStatic() && receiver_type.IsValid()));
ScopedObjectAccess soa(Thread::Current());
- const DexFile::CodeItem* code_item = resolved_method->GetCodeItem();
+ const dex::CodeItem* code_item = resolved_method->GetCodeItem();
const DexFile& callee_dex_file = *resolved_method->GetDexFile();
uint32_t method_index = resolved_method->GetDexMethodIndex();
CodeItemDebugInfoAccessor code_item_accessor(resolved_method->DexInstructionDebugInfo());
@@ -2027,7 +2027,7 @@ bool HInliner::TryBuildAndInlineHelper(HInvoke* invoke_instruction,
}
void HInliner::RunOptimizations(HGraph* callee_graph,
- const DexFile::CodeItem* code_item,
+ const dex::CodeItem* code_item,
const DexCompilationUnit& dex_compilation_unit) {
// Note: if the outermost_graph_ is being compiled OSR, we should not run any
// optimization that could lead to a HDeoptimize. The following optimizations do not.
@@ -2112,7 +2112,7 @@ bool HInliner::ArgumentTypesMoreSpecific(HInvoke* invoke_instruction, ArtMethod*
// Iterate over the list of parameter types and test whether any of the
// actual inputs has a more specific reference type than the type declared in
// the signature.
- const DexFile::TypeList* param_list = resolved_method->GetParameterTypeList();
+ const dex::TypeList* param_list = resolved_method->GetParameterTypeList();
for (size_t param_idx = 0,
input_idx = resolved_method->IsStatic() ? 0 : 1,
e = (param_list == nullptr ? 0 : param_list->Size());
diff --git a/compiler/optimizing/inliner.h b/compiler/optimizing/inliner.h
index 8ac2163a94..efd4c74079 100644
--- a/compiler/optimizing/inliner.h
+++ b/compiler/optimizing/inliner.h
@@ -99,7 +99,7 @@ class HInliner : public HOptimization {
// Run simple optimizations on `callee_graph`.
void RunOptimizations(HGraph* callee_graph,
- const DexFile::CodeItem* code_item,
+ const dex::CodeItem* code_item,
const DexCompilationUnit& dex_compilation_unit)
REQUIRES_SHARED(Locks::mutator_lock_);
diff --git a/compiler/optimizing/instruction_builder.cc b/compiler/optimizing/instruction_builder.cc
index b6ef2b614f..5e7b57523f 100644
--- a/compiler/optimizing/instruction_builder.cc
+++ b/compiler/optimizing/instruction_builder.cc
@@ -559,7 +559,7 @@ void HInstructionBuilder::InitializeParameters() {
uint16_t locals_index = graph_->GetNumberOfLocalVRegs();
uint16_t parameter_index = 0;
- const DexFile::MethodId& referrer_method_id =
+ const dex::MethodId& referrer_method_id =
dex_file_->GetMethodId(dex_compilation_unit_->GetDexMethodIndex());
if (!dex_compilation_unit_->IsStatic()) {
// Add the implicit 'this' argument, not expressed in the signature.
@@ -576,8 +576,8 @@ void HInstructionBuilder::InitializeParameters() {
DCHECK(current_this_parameter_ == nullptr);
}
- const DexFile::ProtoId& proto = dex_file_->GetMethodPrototype(referrer_method_id);
- const DexFile::TypeList* arg_types = dex_file_->GetProtoParameters(proto);
+ const dex::ProtoId& proto = dex_file_->GetMethodPrototype(referrer_method_id);
+ const dex::TypeList* arg_types = dex_file_->GetProtoParameters(proto);
for (int i = 0, shorty_pos = 1; i < number_of_parameters; i++) {
HParameterValue* parameter = new (allocator_) HParameterValue(
*dex_file_,
@@ -1515,7 +1515,7 @@ bool HInstructionBuilder::HandleStringInit(HInvoke* invoke,
}
static DataType::Type GetFieldAccessType(const DexFile& dex_file, uint16_t field_index) {
- const DexFile::FieldId& field_id = dex_file.GetFieldId(field_index);
+ const dex::FieldId& field_id = dex_file.GetFieldId(field_index);
const char* type = dex_file.GetFieldTypeDescriptor(field_id);
return DataType::FromShorty(type[0]);
}
@@ -3143,7 +3143,7 @@ ObjPtr<mirror::Class> HInstructionBuilder::LookupResolvedType(
ObjPtr<mirror::Class> HInstructionBuilder::LookupReferrerClass() const {
// TODO: Cache the result in a Handle<mirror::Class>.
- const DexFile::MethodId& method_id =
+ const dex::MethodId& method_id =
dex_compilation_unit_->GetDexFile()->GetMethodId(dex_compilation_unit_->GetDexMethodIndex());
return LookupResolvedType(method_id.class_idx_, *dex_compilation_unit_);
}
diff --git a/compiler/optimizing/nodes.cc b/compiler/optimizing/nodes.cc
index e9a2f96798..f7c16d1d02 100644
--- a/compiler/optimizing/nodes.cc
+++ b/compiler/optimizing/nodes.cc
@@ -689,7 +689,7 @@ HCurrentMethod* HGraph::GetCurrentMethod() {
}
const char* HGraph::GetMethodName() const {
- const DexFile::MethodId& method_id = dex_file_.GetMethodId(method_idx_);
+ const dex::MethodId& method_id = dex_file_.GetMethodId(method_idx_);
return dex_file_.GetMethodName(method_id);
}
diff --git a/compiler/optimizing/optimizing_compiler.cc b/compiler/optimizing/optimizing_compiler.cc
index a8fa370993..3b34e8d0f6 100644
--- a/compiler/optimizing/optimizing_compiler.cc
+++ b/compiler/optimizing/optimizing_compiler.cc
@@ -272,7 +272,7 @@ class OptimizingCompiler final : public Compiler {
bool CanCompileMethod(uint32_t method_idx, const DexFile& dex_file) const override;
- CompiledMethod* Compile(const DexFile::CodeItem* code_item,
+ CompiledMethod* Compile(const dex::CodeItem* code_item,
uint32_t access_flags,
InvokeType invoke_type,
uint16_t class_def_idx,
@@ -370,7 +370,7 @@ class OptimizingCompiler final : public Compiler {
CompiledMethod* Emit(ArenaAllocator* allocator,
CodeVectorAllocator* code_allocator,
CodeGenerator* codegen,
- const DexFile::CodeItem* item) const;
+ const dex::CodeItem* item) const;
// Try compiling a method and return the code generator used for
// compiling it.
@@ -760,7 +760,7 @@ static ArenaVector<linker::LinkerPatch> EmitAndSortLinkerPatches(CodeGenerator*
CompiledMethod* OptimizingCompiler::Emit(ArenaAllocator* allocator,
CodeVectorAllocator* code_allocator,
CodeGenerator* codegen,
- const DexFile::CodeItem* code_item_for_osr_check) const {
+ const dex::CodeItem* code_item_for_osr_check) const {
ArenaVector<linker::LinkerPatch> linker_patches = EmitAndSortLinkerPatches(codegen);
ScopedArenaVector<uint8_t> stack_map = codegen->BuildStackMaps(code_item_for_osr_check);
@@ -799,7 +799,7 @@ CodeGenerator* OptimizingCompiler::TryCompile(ArenaAllocator* allocator,
InstructionSet instruction_set = compiler_options.GetInstructionSet();
const DexFile& dex_file = *dex_compilation_unit.GetDexFile();
uint32_t method_idx = dex_compilation_unit.GetDexMethodIndex();
- const DexFile::CodeItem* code_item = dex_compilation_unit.GetCodeItem();
+ const dex::CodeItem* code_item = dex_compilation_unit.GetCodeItem();
// Always use the Thumb-2 assembler: some runtime functionality
// (like implicit stack overflow checks) assume Thumb-2.
@@ -1033,7 +1033,7 @@ CodeGenerator* OptimizingCompiler::TryCompileIntrinsic(
return codegen.release();
}
-CompiledMethod* OptimizingCompiler::Compile(const DexFile::CodeItem* code_item,
+CompiledMethod* OptimizingCompiler::Compile(const dex::CodeItem* code_item,
uint32_t access_flags,
InvokeType invoke_type,
uint16_t class_def_idx,
@@ -1254,7 +1254,7 @@ bool OptimizingCompiler::JitCompile(Thread* self,
const DexFile* dex_file = method->GetDexFile();
const uint16_t class_def_idx = method->GetClassDefIndex();
- const DexFile::CodeItem* code_item = dex_file->GetCodeItem(method->GetCodeItemOffset());
+ const dex::CodeItem* code_item = dex_file->GetCodeItem(method->GetCodeItemOffset());
const uint32_t method_idx = method->GetDexMethodIndex();
const uint32_t access_flags = method->GetAccessFlags();
diff --git a/compiler/optimizing/optimizing_unit_test.h b/compiler/optimizing/optimizing_unit_test.h
index 4e376b1c57..e5f694109a 100644
--- a/compiler/optimizing/optimizing_unit_test.h
+++ b/compiler/optimizing/optimizing_unit_test.h
@@ -155,7 +155,7 @@ class OptimizingUnitTestHelper {
void* aligned_data = GetAllocator()->Alloc(code_item_size);
memcpy(aligned_data, &data[0], code_item_size);
CHECK_ALIGNED(aligned_data, StandardDexFile::CodeItem::kAlignment);
- const DexFile::CodeItem* code_item = reinterpret_cast<const DexFile::CodeItem*>(aligned_data);
+ const dex::CodeItem* code_item = reinterpret_cast<const dex::CodeItem*>(aligned_data);
{
ScopedObjectAccess soa(Thread::Current());
diff --git a/compiler/verifier_deps_test.cc b/compiler/verifier_deps_test.cc
index c00f848f3a..092e931944 100644
--- a/compiler/verifier_deps_test.cc
+++ b/compiler/verifier_deps_test.cc
@@ -147,7 +147,7 @@ class VerifierDepsTest : public CommonCompilerTest {
hs.NewHandle(soa.Decode<mirror::ClassLoader>(class_loader_)));
Handle<mirror::DexCache> dex_cache_handle(hs.NewHandle(klass_Main_->GetDexCache()));
- const DexFile::ClassDef* class_def = klass_Main_->GetClassDef();
+ const dex::ClassDef* class_def = klass_Main_->GetClassDef();
ClassAccessor accessor(*primary_dex_file_, *class_def);
bool has_failures = true;
@@ -228,7 +228,7 @@ class VerifierDepsTest : public CommonCompilerTest {
for (const DexFile* dex_file : dex_files_) {
const std::set<dex::TypeIndex>& unverified_classes = deps.GetUnverifiedClasses(*dex_file);
for (uint32_t i = 0; i < dex_file->NumClassDefs(); ++i) {
- const DexFile::ClassDef& class_def = dex_file->GetClassDef(i);
+ const dex::ClassDef& class_def = dex_file->GetClassDef(i);
const char* descriptor = dex_file->GetClassDescriptor(class_def);
cls.Assign(class_linker_->FindClass(soa.Self(), descriptor, class_loader_handle));
if (cls == nullptr) {
@@ -250,7 +250,7 @@ class VerifierDepsTest : public CommonCompilerTest {
}
bool HasUnverifiedClass(const std::string& cls, const DexFile& dex_file) {
- const DexFile::TypeId* type_id = dex_file.FindTypeId(cls.c_str());
+ const dex::TypeId* type_id = dex_file.FindTypeId(cls.c_str());
DCHECK(type_id != nullptr);
dex::TypeIndex index = dex_file.GetIndexForTypeId(*type_id);
for (const auto& dex_dep : verifier_deps_->dex_deps_) {
@@ -329,7 +329,7 @@ class VerifierDepsTest : public CommonCompilerTest {
continue;
}
- const DexFile::FieldId& field_id = dex_dep.first->GetFieldId(entry.GetDexFieldIndex());
+ const dex::FieldId& field_id = dex_dep.first->GetFieldId(entry.GetDexFieldIndex());
std::string actual_klass = dex_dep.first->StringByTypeIdx(field_id.class_idx_);
if (expected_klass != actual_klass) {
@@ -381,7 +381,7 @@ class VerifierDepsTest : public CommonCompilerTest {
continue;
}
- const DexFile::MethodId& method_id = dex_dep.first->GetMethodId(entry.GetDexMethodIndex());
+ const dex::MethodId& method_id = dex_dep.first->GetMethodId(entry.GetDexMethodIndex());
std::string actual_klass = dex_dep.first->StringByTypeIdx(method_id.class_idx_);
if (expected_klass != actual_klass) {
diff --git a/dex2oat/dex2oat_test.cc b/dex2oat/dex2oat_test.cc
index 92dd9328b3..fd454f050b 100644
--- a/dex2oat/dex2oat_test.cc
+++ b/dex2oat/dex2oat_test.cc
@@ -1331,7 +1331,7 @@ TEST_F(Dex2oatTest, LayoutSections) {
// first.
std::vector<uint16_t> methods;
{
- const DexFile::TypeId* type_id = dex->FindTypeId("LManyMethods;");
+ const dex::TypeId* type_id = dex->FindTypeId("LManyMethods;");
dex::TypeIndex type_idx = dex->GetIndexForTypeId(*type_id);
ClassAccessor accessor(*dex, *dex->FindClassDef(type_idx));
std::set<size_t> code_item_offsets;
@@ -1431,10 +1431,10 @@ TEST_F(Dex2oatTest, LayoutSections) {
// we expect.
std::unique_ptr<const DexFile> dex_file(oat_dex->OpenDexFile(&error_msg));
ASSERT_TRUE(dex_file != nullptr) << error_msg;
- const DexFile::TypeId* type_id = dex_file->FindTypeId("LManyMethods;");
+ const dex::TypeId* type_id = dex_file->FindTypeId("LManyMethods;");
ASSERT_TRUE(type_id != nullptr);
dex::TypeIndex type_idx = dex_file->GetIndexForTypeId(*type_id);
- const DexFile::ClassDef* class_def = dex_file->FindClassDef(type_idx);
+ const dex::ClassDef* class_def = dex_file->FindClassDef(type_idx);
ASSERT_TRUE(class_def != nullptr);
// Count how many code items are for each category, there should be at least one per category.
diff --git a/dex2oat/linker/image_test.h b/dex2oat/linker/image_test.h
index fa0a3d4ac9..70a22b5077 100644
--- a/dex2oat/linker/image_test.h
+++ b/dex2oat/linker/image_test.h
@@ -492,7 +492,7 @@ inline void ImageTest::TestWriteRead(ImageHeader::StorageMode storage_mode,
CHECK_EQ(kRequestedImageBase, reinterpret_cast<uintptr_t>(image_begin));
}
for (size_t j = 0; j < dex->NumClassDefs(); ++j) {
- const DexFile::ClassDef& class_def = dex->GetClassDef(j);
+ const dex::ClassDef& class_def = dex->GetClassDef(j);
const char* descriptor = dex->GetClassDescriptor(class_def);
ObjPtr<mirror::Class> klass = class_linker_->FindSystemClass(soa.Self(), descriptor);
EXPECT_TRUE(klass != nullptr) << descriptor;
diff --git a/dex2oat/linker/image_writer.cc b/dex2oat/linker/image_writer.cc
index e4e4b13458..1331fc3bac 100644
--- a/dex2oat/linker/image_writer.cc
+++ b/dex2oat/linker/image_writer.cc
@@ -1586,7 +1586,7 @@ void ImageWriter::PruneDexCache(ObjPtr<mirror::DexCache> dex_cache,
// Check if the referenced class is in the image. Note that we want to check the referenced
// class rather than the declaring class to preserve the semantics, i.e. using a MethodId
// results in resolving the referenced class and that can for example throw OOME.
- const DexFile::MethodId& method_id = dex_file.GetMethodId(stored_index);
+ const dex::MethodId& method_id = dex_file.GetMethodId(stored_index);
if (method_id.class_idx_ != last_class_idx) {
last_class_idx = method_id.class_idx_;
last_class = class_linker->LookupResolvedType(last_class_idx, dex_cache, class_loader);
@@ -1612,7 +1612,7 @@ void ImageWriter::PruneDexCache(ObjPtr<mirror::DexCache> dex_cache,
// Check if the referenced class is in the image. Note that we want to check the referenced
// class rather than the declaring class to preserve the semantics, i.e. using a FieldId
// results in resolving the referenced class and that can for example throw OOME.
- const DexFile::FieldId& field_id = dex_file.GetFieldId(stored_index);
+ const dex::FieldId& field_id = dex_file.GetFieldId(stored_index);
if (field_id.class_idx_ != last_class_idx) {
last_class_idx = field_id.class_idx_;
last_class = class_linker->LookupResolvedType(last_class_idx, dex_cache, class_loader);
@@ -1663,7 +1663,7 @@ void ImageWriter::PreloadDexCache(ObjPtr<mirror::DexCache> dex_cache,
// Check if the referenced class is in the image. Note that we want to check the referenced
// class rather than the declaring class to preserve the semantics, i.e. using a MethodId
// results in resolving the referenced class and that can for example throw OOME.
- const DexFile::MethodId& method_id = dex_file.GetMethodId(i);
+ const dex::MethodId& method_id = dex_file.GetMethodId(i);
if (method_id.class_idx_ != last_class_idx) {
last_class_idx = method_id.class_idx_;
last_class = class_linker->LookupResolvedType(last_class_idx, dex_cache, class_loader);
@@ -1695,7 +1695,7 @@ void ImageWriter::PreloadDexCache(ObjPtr<mirror::DexCache> dex_cache,
// Check if the referenced class is in the image. Note that we want to check the referenced
// class rather than the declaring class to preserve the semantics, i.e. using a FieldId
// results in resolving the referenced class and that can for example throw OOME.
- const DexFile::FieldId& field_id = dex_file.GetFieldId(i);
+ const dex::FieldId& field_id = dex_file.GetFieldId(i);
if (field_id.class_idx_ != last_class_idx) {
last_class_idx = field_id.class_idx_;
last_class = class_linker->LookupResolvedType(last_class_idx, dex_cache, class_loader);
diff --git a/dex2oat/linker/oat_writer.cc b/dex2oat/linker/oat_writer.cc
index e2a9ac2a8f..be9a0cb0a2 100644
--- a/dex2oat/linker/oat_writer.cc
+++ b/dex2oat/linker/oat_writer.cc
@@ -1011,7 +1011,7 @@ struct OatWriter::OrderedMethodData {
size_t class_def_index;
uint32_t access_flags;
- const DexFile::CodeItem* code_item;
+ const dex::CodeItem* code_item;
// A value of -1 denotes missing debug info
static constexpr size_t kDebugInfoIdxInvalid = static_cast<size_t>(-1);
@@ -1506,7 +1506,7 @@ class OatWriter::InitImageMethodVisitor : public OatDexMethodVisitor {
return true;
}
ObjPtr<mirror::DexCache> dex_cache = class_linker_->FindDexCache(Thread::Current(), *dex_file);
- const DexFile::ClassDef& class_def = dex_file->GetClassDef(class_def_index);
+ const dex::ClassDef& class_def = dex_file->GetClassDef(class_def_index);
ObjPtr<mirror::Class> klass =
class_linker_->LookupResolvedType(class_def.class_idx_, dex_cache, class_loader_);
if (klass != nullptr) {
@@ -1585,7 +1585,7 @@ class OatWriter::InitImageMethodVisitor : public OatDexMethodVisitor {
// Check whether current class is image class
bool IsImageClass() {
- const DexFile::TypeId& type_id =
+ const dex::TypeId& type_id =
dex_file_->GetTypeId(dex_file_->GetClassDef(class_def_index_).class_idx_);
const char* class_descriptor = dex_file_->GetTypeDescriptor(type_id);
return writer_->GetCompilerOptions().IsImageClass(class_descriptor);
diff --git a/dexdump/dexdump.cc b/dexdump/dexdump.cc
index 2b59342158..c23524a0e0 100644
--- a/dexdump/dexdump.cc
+++ b/dexdump/dexdump.cc
@@ -492,13 +492,13 @@ static void dumpEncodedValue(const DexFile* pDexFile, const u1** data, u1 type,
case DexFile::kDexAnnotationField:
case DexFile::kDexAnnotationEnum: {
const u4 field_idx = static_cast<u4>(readVarWidth(data, arg, false));
- const DexFile::FieldId& pFieldId = pDexFile->GetFieldId(field_idx);
+ const dex::FieldId& pFieldId = pDexFile->GetFieldId(field_idx);
fputs(pDexFile->StringDataByIdx(pFieldId.name_idx_), gOutFile);
break;
}
case DexFile::kDexAnnotationMethod: {
const u4 method_idx = static_cast<u4>(readVarWidth(data, arg, false));
- const DexFile::MethodId& pMethodId = pDexFile->GetMethodId(method_idx);
+ const dex::MethodId& pMethodId = pDexFile->GetMethodId(method_idx);
fputs(pDexFile->StringDataByIdx(pMethodId.name_idx_), gOutFile);
break;
}
@@ -594,7 +594,7 @@ static void dumpFileHeader(const DexFile* pDexFile) {
*/
static void dumpClassDef(const DexFile* pDexFile, int idx) {
// General class information.
- const DexFile::ClassDef& pClassDef = pDexFile->GetClassDef(idx);
+ const dex::ClassDef& pClassDef = pDexFile->GetClassDef(idx);
fprintf(gOutFile, "Class #%d header:\n", idx);
fprintf(gOutFile, "class_idx : %d\n", pClassDef.class_idx_.index_);
fprintf(gOutFile, "access_flags : %d (0x%04x)\n",
@@ -620,13 +620,13 @@ static void dumpClassDef(const DexFile* pDexFile, int idx) {
/**
* Dumps an annotation set item.
*/
-static void dumpAnnotationSetItem(const DexFile* pDexFile, const DexFile::AnnotationSetItem* set_item) {
+static void dumpAnnotationSetItem(const DexFile* pDexFile, const dex::AnnotationSetItem* set_item) {
if (set_item == nullptr || set_item->size_ == 0) {
fputs(" empty-annotation-set\n", gOutFile);
return;
}
for (u4 i = 0; i < set_item->size_; i++) {
- const DexFile::AnnotationItem* annotation = pDexFile->GetAnnotationItem(set_item, i);
+ const dex::AnnotationItem* annotation = pDexFile->GetAnnotationItem(set_item, i);
if (annotation == nullptr) {
continue;
}
@@ -648,18 +648,18 @@ static void dumpAnnotationSetItem(const DexFile* pDexFile, const DexFile::Annota
* Dumps class annotations.
*/
static void dumpClassAnnotations(const DexFile* pDexFile, int idx) {
- const DexFile::ClassDef& pClassDef = pDexFile->GetClassDef(idx);
- const DexFile::AnnotationsDirectoryItem* dir = pDexFile->GetAnnotationsDirectory(pClassDef);
+ const dex::ClassDef& pClassDef = pDexFile->GetClassDef(idx);
+ const dex::AnnotationsDirectoryItem* dir = pDexFile->GetAnnotationsDirectory(pClassDef);
if (dir == nullptr) {
return; // none
}
fprintf(gOutFile, "Class #%d annotations:\n", idx);
- const DexFile::AnnotationSetItem* class_set_item = pDexFile->GetClassAnnotationSet(dir);
- const DexFile::FieldAnnotationsItem* fields = pDexFile->GetFieldAnnotations(dir);
- const DexFile::MethodAnnotationsItem* methods = pDexFile->GetMethodAnnotations(dir);
- const DexFile::ParameterAnnotationsItem* pars = pDexFile->GetParameterAnnotations(dir);
+ const dex::AnnotationSetItem* class_set_item = pDexFile->GetClassAnnotationSet(dir);
+ const dex::FieldAnnotationsItem* fields = pDexFile->GetFieldAnnotations(dir);
+ const dex::MethodAnnotationsItem* methods = pDexFile->GetMethodAnnotations(dir);
+ const dex::ParameterAnnotationsItem* pars = pDexFile->GetParameterAnnotations(dir);
// Annotations on the class itself.
if (class_set_item != nullptr) {
@@ -671,7 +671,7 @@ static void dumpClassAnnotations(const DexFile* pDexFile, int idx) {
if (fields != nullptr) {
for (u4 i = 0; i < dir->fields_size_; i++) {
const u4 field_idx = fields[i].field_idx_;
- const DexFile::FieldId& pFieldId = pDexFile->GetFieldId(field_idx);
+ const dex::FieldId& pFieldId = pDexFile->GetFieldId(field_idx);
const char* field_name = pDexFile->StringDataByIdx(pFieldId.name_idx_);
fprintf(gOutFile, "Annotations on field #%u '%s'\n", field_idx, field_name);
dumpAnnotationSetItem(pDexFile, pDexFile->GetFieldAnnotationSetItem(fields[i]));
@@ -682,7 +682,7 @@ static void dumpClassAnnotations(const DexFile* pDexFile, int idx) {
if (methods != nullptr) {
for (u4 i = 0; i < dir->methods_size_; i++) {
const u4 method_idx = methods[i].method_idx_;
- const DexFile::MethodId& pMethodId = pDexFile->GetMethodId(method_idx);
+ const dex::MethodId& pMethodId = pDexFile->GetMethodId(method_idx);
const char* method_name = pDexFile->StringDataByIdx(pMethodId.name_idx_);
fprintf(gOutFile, "Annotations on method #%u '%s'\n", method_idx, method_name);
dumpAnnotationSetItem(pDexFile, pDexFile->GetMethodAnnotationSetItem(methods[i]));
@@ -693,10 +693,10 @@ static void dumpClassAnnotations(const DexFile* pDexFile, int idx) {
if (pars != nullptr) {
for (u4 i = 0; i < dir->parameters_size_; i++) {
const u4 method_idx = pars[i].method_idx_;
- const DexFile::MethodId& pMethodId = pDexFile->GetMethodId(method_idx);
+ const dex::MethodId& pMethodId = pDexFile->GetMethodId(method_idx);
const char* method_name = pDexFile->StringDataByIdx(pMethodId.name_idx_);
fprintf(gOutFile, "Annotations on method #%u '%s' parameters\n", method_idx, method_name);
- const DexFile::AnnotationSetRefList*
+ const dex::AnnotationSetRefList*
list = pDexFile->GetParameterAnnotationSetRefList(&pars[i]);
if (list != nullptr) {
for (u4 j = 0; j < list->size_; j++) {
@@ -713,7 +713,7 @@ static void dumpClassAnnotations(const DexFile* pDexFile, int idx) {
/*
* Dumps an interface that a class declares to implement.
*/
-static void dumpInterface(const DexFile* pDexFile, const DexFile::TypeItem& pTypeItem, int i) {
+static void dumpInterface(const DexFile* pDexFile, const dex::TypeItem& pTypeItem, int i) {
const char* interfaceName = pDexFile->StringByTypeIdx(pTypeItem.type_idx_);
if (gOptions.outputFormat == OUTPUT_PLAIN) {
fprintf(gOutFile, " #%d : '%s'\n", i, interfaceName);
@@ -726,7 +726,7 @@ static void dumpInterface(const DexFile* pDexFile, const DexFile::TypeItem& pTyp
/*
* Dumps the catches table associated with the code.
*/
-static void dumpCatches(const DexFile* pDexFile, const DexFile::CodeItem* pCode) {
+static void dumpCatches(const DexFile* pDexFile, const dex::CodeItem* pCode) {
CodeItemDataAccessor accessor(*pDexFile, pCode);
const u4 triesSize = accessor.TriesSize();
@@ -738,7 +738,7 @@ static void dumpCatches(const DexFile* pDexFile, const DexFile::CodeItem* pCode)
// Dump all table entries.
fprintf(gOutFile, " catches : %d\n", triesSize);
- for (const DexFile::TryItem& try_item : accessor.TryItems()) {
+ for (const dex::TryItem& try_item : accessor.TryItems()) {
const u4 start = try_item.start_addr_;
const u4 end = start + try_item.insn_count_;
fprintf(gOutFile, " 0x%04x - 0x%04x\n", start, end);
@@ -826,7 +826,7 @@ static std::unique_ptr<char[]> indexString(const DexFile* pDexFile,
break;
case Instruction::kIndexMethodRef:
if (index < pDexFile->GetHeader().method_ids_size_) {
- const DexFile::MethodId& pMethodId = pDexFile->GetMethodId(index);
+ const dex::MethodId& pMethodId = pDexFile->GetMethodId(index);
const char* name = pDexFile->StringDataByIdx(pMethodId.name_idx_);
const Signature signature = pDexFile->GetMethodSignature(pMethodId);
const char* backDescriptor = pDexFile->StringByTypeIdx(pMethodId.class_idx_);
@@ -838,7 +838,7 @@ static std::unique_ptr<char[]> indexString(const DexFile* pDexFile,
break;
case Instruction::kIndexFieldRef:
if (index < pDexFile->GetHeader().field_ids_size_) {
- const DexFile::FieldId& pFieldId = pDexFile->GetFieldId(index);
+ const dex::FieldId& pFieldId = pDexFile->GetFieldId(index);
const char* name = pDexFile->StringDataByIdx(pFieldId.name_idx_);
const char* typeDescriptor = pDexFile->StringByTypeIdx(pFieldId.type_idx_);
const char* backDescriptor = pDexFile->StringByTypeIdx(pFieldId.class_idx_);
@@ -859,7 +859,7 @@ static std::unique_ptr<char[]> indexString(const DexFile* pDexFile,
std::string method("<method?>");
std::string proto("<proto?>");
if (index < pDexFile->GetHeader().method_ids_size_) {
- const DexFile::MethodId& pMethodId = pDexFile->GetMethodId(index);
+ const dex::MethodId& pMethodId = pDexFile->GetMethodId(index);
const char* name = pDexFile->StringDataByIdx(pMethodId.name_idx_);
const Signature signature = pDexFile->GetMethodSignature(pMethodId);
const char* backDescriptor = pDexFile->StringByTypeIdx(pMethodId.class_idx_);
@@ -869,7 +869,7 @@ static std::unique_ptr<char[]> indexString(const DexFile* pDexFile,
signature.ToString().c_str());
}
if (secondary_index < pDexFile->GetHeader().proto_ids_size_) {
- const DexFile::ProtoId& protoId = pDexFile->GetProtoId(dex::ProtoIndex(secondary_index));
+ const dex::ProtoId& protoId = pDexFile->GetProtoId(dex::ProtoIndex(secondary_index));
const Signature signature = pDexFile->GetProtoSignature(protoId);
proto = signature.ToString();
}
@@ -887,7 +887,7 @@ static std::unique_ptr<char[]> indexString(const DexFile* pDexFile,
break;
case Instruction::kIndexProtoRef:
if (index < pDexFile->GetHeader().proto_ids_size_) {
- const DexFile::ProtoId& protoId = pDexFile->GetProtoId(dex::ProtoIndex(index));
+ const dex::ProtoId& protoId = pDexFile->GetProtoId(dex::ProtoIndex(index));
const Signature signature = pDexFile->GetProtoSignature(protoId);
const std::string& proto = signature.ToString();
outSize = snprintf(buf.get(), bufSize, "%s // proto@%0*x", proto.c_str(), width, index);
@@ -916,7 +916,7 @@ static std::unique_ptr<char[]> indexString(const DexFile* pDexFile,
* Dumps a single instruction.
*/
static void dumpInstruction(const DexFile* pDexFile,
- const DexFile::CodeItem* pCode,
+ const dex::CodeItem* pCode,
u4 codeOffset, u4 insnIdx, u4 insnWidth,
const Instruction* pDecInsn) {
// Address of instruction (expressed as byte offset).
@@ -1129,8 +1129,8 @@ static void dumpInstruction(const DexFile* pDexFile,
* Dumps a bytecode disassembly.
*/
static void dumpBytecodes(const DexFile* pDexFile, u4 idx,
- const DexFile::CodeItem* pCode, u4 codeOffset) {
- const DexFile::MethodId& pMethodId = pDexFile->GetMethodId(idx);
+ const dex::CodeItem* pCode, u4 codeOffset) {
+ const dex::MethodId& pMethodId = pDexFile->GetMethodId(idx);
const char* name = pDexFile->StringDataByIdx(pMethodId.name_idx_);
const Signature signature = pDexFile->GetMethodSignature(pMethodId);
const char* backDescriptor = pDexFile->StringByTypeIdx(pMethodId.class_idx_);
@@ -1163,7 +1163,7 @@ static void dumpBytecodes(const DexFile* pDexFile, u4 idx,
* Dumps code of a method.
*/
static void dumpCode(const DexFile* pDexFile, u4 idx, u4 flags,
- const DexFile::CodeItem* pCode, u4 codeOffset) {
+ const dex::CodeItem* pCode, u4 codeOffset) {
CodeItemDebugInfoAccessor accessor(*pDexFile, pCode, idx);
fprintf(gOutFile, " registers : %d\n", accessor.RegistersSize());
@@ -1214,7 +1214,7 @@ static void dumpMethod(const ClassAccessor::Method& method, int i) {
}
const DexFile& dex_file = method.GetDexFile();
- const DexFile::MethodId& pMethodId = dex_file.GetMethodId(method.GetIndex());
+ const dex::MethodId& pMethodId = dex_file.GetMethodId(method.GetIndex());
const char* name = dex_file.StringDataByIdx(pMethodId.name_idx_);
const Signature signature = dex_file.GetMethodSignature(pMethodId);
char* typeDescriptor = strdup(signature.ToString().c_str());
@@ -1325,7 +1325,7 @@ static void dumpField(const ClassAccessor::Field& field, int i, const u1** data
}
const DexFile& dex_file = field.GetDexFile();
- const DexFile::FieldId& field_id = dex_file.GetFieldId(field.GetIndex());
+ const dex::FieldId& field_id = dex_file.GetFieldId(field.GetIndex());
const char* name = dex_file.StringDataByIdx(field_id.name_idx_);
const char* typeDescriptor = dex_file.StringByTypeIdx(field_id.type_idx_);
const char* backDescriptor = dex_file.StringByTypeIdx(field_id.class_idx_);
@@ -1386,7 +1386,7 @@ static void dumpCfg(const DexFile* dex_file, int idx) {
* the value will be replaced with a newly-allocated string.
*/
static void dumpClass(const DexFile* pDexFile, int idx, char** pLastPackage) {
- const DexFile::ClassDef& pClassDef = pDexFile->GetClassDef(idx);
+ const dex::ClassDef& pClassDef = pDexFile->GetClassDef(idx);
// Omitting non-public class.
if (gOptions.exportsOnly && (pClassDef.access_flags_ & kAccPublic) == 0) {
@@ -1480,7 +1480,7 @@ static void dumpClass(const DexFile* pDexFile, int idx, char** pLastPackage) {
}
// Interfaces.
- const DexFile::TypeList* pInterfaces = pDexFile->GetInterfacesList(pClassDef);
+ const dex::TypeList* pInterfaces = pDexFile->GetInterfacesList(pClassDef);
if (pInterfaces != nullptr) {
for (u4 i = 0; i < pInterfaces->Size(); i++) {
dumpInterface(pDexFile, pInterfaces->GetTypeItem(i), i);
@@ -1552,7 +1552,7 @@ static void dumpClass(const DexFile* pDexFile, int idx, char** pLastPackage) {
}
static void dumpMethodHandle(const DexFile* pDexFile, u4 idx) {
- const DexFile::MethodHandleItem& mh = pDexFile->GetMethodHandle(idx);
+ const dex::MethodHandleItem& mh = pDexFile->GetMethodHandle(idx);
const char* type = nullptr;
bool is_instance = false;
bool is_invoke = false;
@@ -1609,12 +1609,12 @@ static void dumpMethodHandle(const DexFile* pDexFile, u4 idx) {
std::string member_type;
if (type != nullptr) {
if (is_invoke) {
- const DexFile::MethodId& method_id = pDexFile->GetMethodId(mh.field_or_method_idx_);
+ const dex::MethodId& method_id = pDexFile->GetMethodId(mh.field_or_method_idx_);
declaring_class = pDexFile->GetMethodDeclaringClassDescriptor(method_id);
member = pDexFile->GetMethodName(method_id);
member_type = pDexFile->GetMethodSignature(method_id).ToString();
} else {
- const DexFile::FieldId& field_id = pDexFile->GetFieldId(mh.field_or_method_idx_);
+ const dex::FieldId& field_id = pDexFile->GetFieldId(mh.field_or_method_idx_);
declaring_class = pDexFile->GetFieldDeclaringClassDescriptor(field_id);
member = pDexFile->GetFieldName(field_id);
member_type = pDexFile->GetFieldTypeDescriptor(field_id);
@@ -1646,7 +1646,7 @@ static void dumpMethodHandle(const DexFile* pDexFile, u4 idx) {
}
static void dumpCallSite(const DexFile* pDexFile, u4 idx) {
- const DexFile::CallSiteIdItem& call_site_id = pDexFile->GetCallSiteId(idx);
+ const dex::CallSiteIdItem& call_site_id = pDexFile->GetCallSiteId(idx);
CallSiteArrayValueIterator it(*pDexFile, call_site_id);
if (it.Size() < 3) {
LOG(ERROR) << "ERROR: Call site " << idx << " has too few values.";
@@ -1659,7 +1659,7 @@ static void dumpCallSite(const DexFile* pDexFile, u4 idx) {
const char* method_name = pDexFile->StringDataByIdx(method_name_idx);
it.Next();
dex::ProtoIndex method_type_idx = static_cast<dex::ProtoIndex>(it.GetJavaValue().i);
- const DexFile::ProtoId& method_type_id = pDexFile->GetProtoId(method_type_idx);
+ const dex::ProtoId& method_type_id = pDexFile->GetProtoId(method_type_idx);
std::string method_type = pDexFile->GetProtoSignature(method_type_id).ToString();
it.Next();
@@ -1717,7 +1717,7 @@ static void dumpCallSite(const DexFile* pDexFile, u4 idx) {
case EncodedArrayValueIterator::ValueType::kMethodType: {
type = "MethodType";
dex::ProtoIndex proto_idx = static_cast<dex::ProtoIndex>(it.GetJavaValue().i);
- const DexFile::ProtoId& proto_id = pDexFile->GetProtoId(proto_idx);
+ const dex::ProtoId& proto_id = pDexFile->GetProtoId(proto_idx);
value = pDexFile->GetProtoSignature(proto_id).ToString();
break;
}
@@ -1734,7 +1734,7 @@ static void dumpCallSite(const DexFile* pDexFile, u4 idx) {
case EncodedArrayValueIterator::ValueType::kType: {
type = "Class";
dex::TypeIndex type_idx = static_cast<dex::TypeIndex>(it.GetJavaValue().i);
- const DexFile::TypeId& type_id = pDexFile->GetTypeId(type_idx);
+ const dex::TypeId& type_id = pDexFile->GetTypeId(type_idx);
value = pDexFile->GetTypeDescriptor(type_id);
break;
}
diff --git a/dexlayout/dex_ir_builder.cc b/dexlayout/dex_ir_builder.cc
index 92e438c8a5..f4195b257d 100644
--- a/dexlayout/dex_ir_builder.cc
+++ b/dexlayout/dex_ir_builder.cc
@@ -152,21 +152,21 @@ class BuilderMaps {
void CreateCallSitesAndMethodHandles(const DexFile& dex_file);
- TypeList* CreateTypeList(const DexFile::TypeList* type_list, uint32_t offset);
+ TypeList* CreateTypeList(const dex::TypeList* type_list, uint32_t offset);
EncodedArrayItem* CreateEncodedArrayItem(const DexFile& dex_file,
const uint8_t* static_data,
uint32_t offset);
AnnotationItem* CreateAnnotationItem(const DexFile& dex_file,
- const DexFile::AnnotationItem* annotation);
+ const dex::AnnotationItem* annotation);
AnnotationSetItem* CreateAnnotationSetItem(const DexFile& dex_file,
- const DexFile::AnnotationSetItem* disk_annotations_item, uint32_t offset);
+ const dex::AnnotationSetItem* disk_annotations_item, uint32_t offset);
AnnotationsDirectoryItem* CreateAnnotationsDirectoryItem(const DexFile& dex_file,
- const DexFile::AnnotationsDirectoryItem* disk_annotations_item, uint32_t offset);
+ const dex::AnnotationsDirectoryItem* disk_annotations_item, uint32_t offset);
CodeItem* DedupeOrCreateCodeItem(const DexFile& dex_file,
- const DexFile::CodeItem* disk_code_item,
+ const dex::CodeItem* disk_code_item,
uint32_t offset,
uint32_t dex_method_index);
- ClassData* CreateClassData(const DexFile& dex_file, const DexFile::ClassDef& class_def);
+ ClassData* CreateClassData(const DexFile& dex_file, const dex::ClassDef& class_def);
void AddAnnotationsFromMapListSection(const DexFile& dex_file,
uint32_t start_offset,
@@ -207,7 +207,7 @@ class BuilderMaps {
ParameterAnnotation* GenerateParameterAnnotation(
const DexFile& dex_file,
MethodId* method_id,
- const DexFile::AnnotationSetRefList* annotation_set_ref_list,
+ const dex::AnnotationSetRefList* annotation_set_ref_list,
uint32_t offset);
template <typename Type, class... Args>
@@ -300,7 +300,7 @@ Header* DexIrBuilder(const DexFile& dex_file,
if (!options.class_filter_.empty()) {
// If the filter is enabled (not empty), filter out classes that don't have a matching
// descriptor.
- const DexFile::ClassDef& class_def = dex_file.GetClassDef(i);
+ const dex::ClassDef& class_def = dex_file.GetClassDef(i);
const char* descriptor = dex_file.GetClassDescriptor(class_def);
if (options.class_filter_.find(descriptor) == options.class_filter_.end()) {
continue;
@@ -331,10 +331,10 @@ Header* DexIrBuilder(const DexFile& dex_file,
void BuilderMaps::CheckAndSetRemainingOffsets(const DexFile& dex_file, const Options& options) {
const DexFile::Header& disk_header = dex_file.GetHeader();
// Read MapItems and validate/set remaining offsets.
- const DexFile::MapList* map = dex_file.GetMapList();
+ const dex::MapList* map = dex_file.GetMapList();
const uint32_t count = map->size_;
for (uint32_t i = 0; i < count; ++i) {
- const DexFile::MapItem* item = map->list_ + i;
+ const dex::MapItem* item = map->list_ + i;
switch (item->type_) {
case DexFile::kDexTypeHeaderItem:
CHECK_EQ(item->size_, 1u);
@@ -421,7 +421,7 @@ void BuilderMaps::CheckAndSetRemainingOffsets(const DexFile& dex_file, const Opt
}
void BuilderMaps::CreateStringId(const DexFile& dex_file, uint32_t i) {
- const DexFile::StringId& disk_string_id = dex_file.GetStringId(dex::StringIndex(i));
+ const dex::StringId& disk_string_id = dex_file.GetStringId(dex::StringIndex(i));
StringData* string_data =
string_datas_map_.CreateAndAddItem(header_->StringDatas(),
eagerly_assign_offsets_,
@@ -434,7 +434,7 @@ void BuilderMaps::CreateStringId(const DexFile& dex_file, uint32_t i) {
}
void BuilderMaps::CreateTypeId(const DexFile& dex_file, uint32_t i) {
- const DexFile::TypeId& disk_type_id = dex_file.GetTypeId(dex::TypeIndex(i));
+ const dex::TypeId& disk_type_id = dex_file.GetTypeId(dex::TypeIndex(i));
CreateAndAddIndexedItem(header_->TypeIds(),
header_->TypeIds().GetOffset() + i * TypeId::ItemSize(),
i,
@@ -442,8 +442,8 @@ void BuilderMaps::CreateTypeId(const DexFile& dex_file, uint32_t i) {
}
void BuilderMaps::CreateProtoId(const DexFile& dex_file, uint32_t i) {
- const DexFile::ProtoId& disk_proto_id = dex_file.GetProtoId(dex::ProtoIndex(i));
- const DexFile::TypeList* type_list = dex_file.GetProtoParameters(disk_proto_id);
+ const dex::ProtoId& disk_proto_id = dex_file.GetProtoId(dex::ProtoIndex(i));
+ const dex::TypeList* type_list = dex_file.GetProtoParameters(disk_proto_id);
TypeList* parameter_type_list = CreateTypeList(type_list, disk_proto_id.parameters_off_);
CreateAndAddIndexedItem(header_->ProtoIds(),
@@ -455,7 +455,7 @@ void BuilderMaps::CreateProtoId(const DexFile& dex_file, uint32_t i) {
}
void BuilderMaps::CreateFieldId(const DexFile& dex_file, uint32_t i) {
- const DexFile::FieldId& disk_field_id = dex_file.GetFieldId(i);
+ const dex::FieldId& disk_field_id = dex_file.GetFieldId(i);
CreateAndAddIndexedItem(header_->FieldIds(),
header_->FieldIds().GetOffset() + i * FieldId::ItemSize(),
i,
@@ -465,7 +465,7 @@ void BuilderMaps::CreateFieldId(const DexFile& dex_file, uint32_t i) {
}
void BuilderMaps::CreateMethodId(const DexFile& dex_file, uint32_t i) {
- const DexFile::MethodId& disk_method_id = dex_file.GetMethodId(i);
+ const dex::MethodId& disk_method_id = dex_file.GetMethodId(i);
CreateAndAddIndexedItem(header_->MethodIds(),
header_->MethodIds().GetOffset() + i * MethodId::ItemSize(),
i,
@@ -475,19 +475,19 @@ void BuilderMaps::CreateMethodId(const DexFile& dex_file, uint32_t i) {
}
void BuilderMaps::CreateClassDef(const DexFile& dex_file, uint32_t i) {
- const DexFile::ClassDef& disk_class_def = dex_file.GetClassDef(i);
+ const dex::ClassDef& disk_class_def = dex_file.GetClassDef(i);
const TypeId* class_type = header_->TypeIds()[disk_class_def.class_idx_.index_];
uint32_t access_flags = disk_class_def.access_flags_;
const TypeId* superclass = header_->GetTypeIdOrNullPtr(disk_class_def.superclass_idx_.index_);
- const DexFile::TypeList* type_list = dex_file.GetInterfacesList(disk_class_def);
+ const dex::TypeList* type_list = dex_file.GetInterfacesList(disk_class_def);
TypeList* interfaces_type_list = CreateTypeList(type_list, disk_class_def.interfaces_off_);
const StringId* source_file =
header_->GetStringIdOrNullPtr(disk_class_def.source_file_idx_.index_);
// Annotations.
AnnotationsDirectoryItem* annotations = nullptr;
- const DexFile::AnnotationsDirectoryItem* disk_annotations_directory_item =
+ const dex::AnnotationsDirectoryItem* disk_annotations_directory_item =
dex_file.GetAnnotationsDirectory(disk_class_def);
if (disk_annotations_directory_item != nullptr) {
annotations = CreateAnnotationsDirectoryItem(
@@ -512,7 +512,7 @@ void BuilderMaps::CreateClassDef(const DexFile& dex_file, uint32_t i) {
}
void BuilderMaps::CreateCallSiteId(const DexFile& dex_file, uint32_t i) {
- const DexFile::CallSiteIdItem& disk_call_site_id = dex_file.GetCallSiteId(i);
+ const dex::CallSiteIdItem& disk_call_site_id = dex_file.GetCallSiteId(i);
const uint8_t* disk_call_item_ptr = dex_file.DataBegin() + disk_call_site_id.data_off_;
EncodedArrayItem* call_site_item =
CreateEncodedArrayItem(dex_file, disk_call_item_ptr, disk_call_site_id.data_off_);
@@ -524,7 +524,7 @@ void BuilderMaps::CreateCallSiteId(const DexFile& dex_file, uint32_t i) {
}
void BuilderMaps::CreateMethodHandleItem(const DexFile& dex_file, uint32_t i) {
- const DexFile::MethodHandleItem& disk_method_handle = dex_file.GetMethodHandle(i);
+ const dex::MethodHandleItem& disk_method_handle = dex_file.GetMethodHandle(i);
uint16_t index = disk_method_handle.field_or_method_idx_;
DexFile::MethodHandleType type =
static_cast<DexFile::MethodHandleType>(disk_method_handle.method_handle_type_);
@@ -551,9 +551,9 @@ void BuilderMaps::CreateMethodHandleItem(const DexFile& dex_file, uint32_t i) {
void BuilderMaps::CreateCallSitesAndMethodHandles(const DexFile& dex_file) {
// Iterate through the map list and set the offset of the CallSiteIds and MethodHandleItems.
- const DexFile::MapList* map = dex_file.GetMapList();
+ const dex::MapList* map = dex_file.GetMapList();
for (uint32_t i = 0; i < map->size_; ++i) {
- const DexFile::MapItem* item = map->list_ + i;
+ const dex::MapItem* item = map->list_ + i;
switch (item->type_) {
case DexFile::kDexTypeCallSiteIdItem:
header_->CallSiteIds().SetOffset(item->offset_);
@@ -575,7 +575,7 @@ void BuilderMaps::CreateCallSitesAndMethodHandles(const DexFile& dex_file) {
}
}
-TypeList* BuilderMaps::CreateTypeList(const DexFile::TypeList* dex_type_list, uint32_t offset) {
+TypeList* BuilderMaps::CreateTypeList(const dex::TypeList* dex_type_list, uint32_t offset) {
if (dex_type_list == nullptr) {
return nullptr;
}
@@ -623,7 +623,7 @@ void BuilderMaps::AddAnnotationsFromMapListSection(const DexFile& dex_file,
uint32_t current_offset = start_offset;
for (size_t i = 0; i < count; ++i) {
// Annotation that we didn't process already, add it to the set.
- const DexFile::AnnotationItem* annotation = dex_file.GetAnnotationItemAtOffset(current_offset);
+ const dex::AnnotationItem* annotation = dex_file.GetAnnotationItemAtOffset(current_offset);
AnnotationItem* annotation_item = CreateAnnotationItem(dex_file, annotation);
DCHECK(annotation_item != nullptr);
current_offset += annotation_item->GetSize();
@@ -632,7 +632,7 @@ void BuilderMaps::AddAnnotationsFromMapListSection(const DexFile& dex_file,
void BuilderMaps::AddHiddenapiClassDataFromMapListSection(const DexFile& dex_file,
uint32_t offset) {
- const DexFile::HiddenapiClassData* hiddenapi_class_data =
+ const dex::HiddenapiClassData* hiddenapi_class_data =
dex_file.GetHiddenapiClassDataAtOffset(offset);
DCHECK(hiddenapi_class_data == dex_file.GetHiddenapiClassData());
@@ -669,7 +669,7 @@ void BuilderMaps::AddHiddenapiClassDataFromMapListSection(const DexFile& dex_fil
}
AnnotationItem* BuilderMaps::CreateAnnotationItem(const DexFile& dex_file,
- const DexFile::AnnotationItem* annotation) {
+ const dex::AnnotationItem* annotation) {
const uint8_t* const start_data = reinterpret_cast<const uint8_t*>(annotation);
const uint32_t offset = start_data - dex_file.DataBegin();
AnnotationItem* annotation_item = annotation_items_map_.GetExistingObject(offset);
@@ -691,7 +691,7 @@ AnnotationItem* BuilderMaps::CreateAnnotationItem(const DexFile& dex_file,
AnnotationSetItem* BuilderMaps::CreateAnnotationSetItem(const DexFile& dex_file,
- const DexFile::AnnotationSetItem* disk_annotations_item, uint32_t offset) {
+ const dex::AnnotationSetItem* disk_annotations_item, uint32_t offset) {
if (disk_annotations_item == nullptr || (disk_annotations_item->size_ == 0 && offset == 0)) {
return nullptr;
}
@@ -699,7 +699,7 @@ AnnotationSetItem* BuilderMaps::CreateAnnotationSetItem(const DexFile& dex_file,
if (annotation_set_item == nullptr) {
std::vector<AnnotationItem*>* items = new std::vector<AnnotationItem*>();
for (uint32_t i = 0; i < disk_annotations_item->size_; ++i) {
- const DexFile::AnnotationItem* annotation =
+ const dex::AnnotationItem* annotation =
dex_file.GetAnnotationItem(disk_annotations_item, i);
if (annotation == nullptr) {
continue;
@@ -717,27 +717,27 @@ AnnotationSetItem* BuilderMaps::CreateAnnotationSetItem(const DexFile& dex_file,
}
AnnotationsDirectoryItem* BuilderMaps::CreateAnnotationsDirectoryItem(const DexFile& dex_file,
- const DexFile::AnnotationsDirectoryItem* disk_annotations_item, uint32_t offset) {
+ const dex::AnnotationsDirectoryItem* disk_annotations_item, uint32_t offset) {
AnnotationsDirectoryItem* annotations_directory_item =
annotations_directory_items_map_.GetExistingObject(offset);
if (annotations_directory_item != nullptr) {
return annotations_directory_item;
}
- const DexFile::AnnotationSetItem* class_set_item =
+ const dex::AnnotationSetItem* class_set_item =
dex_file.GetClassAnnotationSet(disk_annotations_item);
AnnotationSetItem* class_annotation = nullptr;
if (class_set_item != nullptr) {
uint32_t item_offset = disk_annotations_item->class_annotations_off_;
class_annotation = CreateAnnotationSetItem(dex_file, class_set_item, item_offset);
}
- const DexFile::FieldAnnotationsItem* fields =
+ const dex::FieldAnnotationsItem* fields =
dex_file.GetFieldAnnotations(disk_annotations_item);
FieldAnnotationVector* field_annotations = nullptr;
if (fields != nullptr) {
field_annotations = new FieldAnnotationVector();
for (uint32_t i = 0; i < disk_annotations_item->fields_size_; ++i) {
FieldId* field_id = header_->FieldIds()[fields[i].field_idx_];
- const DexFile::AnnotationSetItem* field_set_item =
+ const dex::AnnotationSetItem* field_set_item =
dex_file.GetFieldAnnotationSetItem(fields[i]);
uint32_t annotation_set_offset = fields[i].annotations_off_;
AnnotationSetItem* annotation_set_item =
@@ -746,14 +746,14 @@ AnnotationsDirectoryItem* BuilderMaps::CreateAnnotationsDirectoryItem(const DexF
field_id, annotation_set_item));
}
}
- const DexFile::MethodAnnotationsItem* methods =
+ const dex::MethodAnnotationsItem* methods =
dex_file.GetMethodAnnotations(disk_annotations_item);
MethodAnnotationVector* method_annotations = nullptr;
if (methods != nullptr) {
method_annotations = new MethodAnnotationVector();
for (uint32_t i = 0; i < disk_annotations_item->methods_size_; ++i) {
MethodId* method_id = header_->MethodIds()[methods[i].method_idx_];
- const DexFile::AnnotationSetItem* method_set_item =
+ const dex::AnnotationSetItem* method_set_item =
dex_file.GetMethodAnnotationSetItem(methods[i]);
uint32_t annotation_set_offset = methods[i].annotations_off_;
AnnotationSetItem* annotation_set_item =
@@ -762,14 +762,14 @@ AnnotationsDirectoryItem* BuilderMaps::CreateAnnotationsDirectoryItem(const DexF
method_id, annotation_set_item));
}
}
- const DexFile::ParameterAnnotationsItem* parameters =
+ const dex::ParameterAnnotationsItem* parameters =
dex_file.GetParameterAnnotations(disk_annotations_item);
ParameterAnnotationVector* parameter_annotations = nullptr;
if (parameters != nullptr) {
parameter_annotations = new ParameterAnnotationVector();
for (uint32_t i = 0; i < disk_annotations_item->parameters_size_; ++i) {
MethodId* method_id = header_->MethodIds()[parameters[i].method_idx_];
- const DexFile::AnnotationSetRefList* list =
+ const dex::AnnotationSetRefList* list =
dex_file.GetParameterAnnotationSetRefList(&parameters[i]);
parameter_annotations->push_back(std::unique_ptr<ParameterAnnotation>(
GenerateParameterAnnotation(dex_file, method_id, list, parameters[i].annotations_off_)));
@@ -786,7 +786,7 @@ AnnotationsDirectoryItem* BuilderMaps::CreateAnnotationsDirectoryItem(const DexF
}
CodeItem* BuilderMaps::DedupeOrCreateCodeItem(const DexFile& dex_file,
- const DexFile::CodeItem* disk_code_item,
+ const dex::CodeItem* disk_code_item,
uint32_t offset,
uint32_t dex_method_index) {
if (disk_code_item == nullptr) {
@@ -827,7 +827,7 @@ CodeItem* BuilderMaps::DedupeOrCreateCodeItem(const DexFile& dex_file,
if (accessor.TriesSize() > 0) {
tries = new TryItemVector();
handler_list = new CatchHandlerVector();
- for (const DexFile::TryItem& disk_try_item : accessor.TryItems()) {
+ for (const dex::TryItem& disk_try_item : accessor.TryItems()) {
uint32_t start_addr = disk_try_item.start_addr_;
uint16_t insn_count = disk_try_item.insn_count_;
uint16_t handler_off = disk_try_item.handler_off_;
@@ -941,7 +941,7 @@ CodeItem* BuilderMaps::DedupeOrCreateCodeItem(const DexFile& dex_file,
}
ClassData* BuilderMaps::CreateClassData(const DexFile& dex_file,
- const DexFile::ClassDef& class_def) {
+ const dex::ClassDef& class_def) {
// Read the fields and methods defined by the class, resolving the circular reference from those
// to classes by setting class at the same time.
const uint32_t offset = class_def.class_data_off_;
@@ -1225,7 +1225,7 @@ MethodItem BuilderMaps::GenerateMethodItem(const DexFile& dex_file,
const ClassAccessor::Method& method) {
MethodId* method_id = header_->MethodIds()[method.GetIndex()];
uint32_t access_flags = method.GetAccessFlags();
- const DexFile::CodeItem* disk_code_item = method.GetCodeItem();
+ const dex::CodeItem* disk_code_item = method.GetCodeItem();
// Temporary hack to prevent incorrectly deduping code items if they have the same offset since
// they may have different debug info streams.
CodeItem* code_item = DedupeOrCreateCodeItem(dex_file,
@@ -1238,13 +1238,13 @@ MethodItem BuilderMaps::GenerateMethodItem(const DexFile& dex_file,
ParameterAnnotation* BuilderMaps::GenerateParameterAnnotation(
const DexFile& dex_file,
MethodId* method_id,
- const DexFile::AnnotationSetRefList* annotation_set_ref_list,
+ const dex::AnnotationSetRefList* annotation_set_ref_list,
uint32_t offset) {
AnnotationSetRefList* set_ref_list = annotation_set_ref_lists_map_.GetExistingObject(offset);
if (set_ref_list == nullptr) {
std::vector<AnnotationSetItem*>* annotations = new std::vector<AnnotationSetItem*>();
for (uint32_t i = 0; i < annotation_set_ref_list->size_; ++i) {
- const DexFile::AnnotationSetItem* annotation_set_item =
+ const dex::AnnotationSetItem* annotation_set_item =
dex_file.GetSetRefItemItem(&annotation_set_ref_list->list_[i]);
uint32_t set_offset = annotation_set_ref_list->list_[i].annotations_off_;
annotations->push_back(CreateAnnotationSetItem(dex_file, annotation_set_item, set_offset));
diff --git a/dexlayout/dex_writer.cc b/dexlayout/dex_writer.cc
index ef6ccf9304..143f5b05eb 100644
--- a/dexlayout/dex_writer.cc
+++ b/dexlayout/dex_writer.cc
@@ -535,10 +535,10 @@ void DexWriter::WriteCodeItemPostInstructionData(Stream* stream,
dex_ir::CodeItem* code_item,
bool reserve_only) {
if (code_item->TriesSize() != 0) {
- stream->AlignTo(DexFile::TryItem::kAlignment);
+ stream->AlignTo(dex::TryItem::kAlignment);
// Write try items.
for (std::unique_ptr<const dex_ir::TryItem>& try_item : *code_item->Tries()) {
- DexFile::TryItem disk_try_item;
+ dex::TryItem disk_try_item;
if (!reserve_only) {
disk_try_item.start_addr_ = try_item->StartAddr();
disk_try_item.insn_count_ = try_item->InsnCount();
@@ -712,7 +712,7 @@ void DexWriter::WriteMapItems(Stream* stream, MapItemQueue* queue) {
stream->Write(&map_list_size, sizeof(map_list_size));
while (!queue->empty()) {
const MapItem& item = queue->top();
- DexFile::MapItem map_item;
+ dex::MapItem map_item;
map_item.type_ = item.type_;
map_item.size_ = item.size_;
map_item.offset_ = item.offset_;
diff --git a/dexlayout/dexlayout.h b/dexlayout/dexlayout.h
index 6e006b7686..535f789f95 100644
--- a/dexlayout/dexlayout.h
+++ b/dexlayout/dexlayout.h
@@ -182,7 +182,7 @@ class DexLayout {
std::string* error_msg);
void DumpCFG(const DexFile* dex_file, int idx);
- void DumpCFG(const DexFile* dex_file, uint32_t dex_method_idx, const DexFile::CodeItem* code);
+ void DumpCFG(const DexFile* dex_file, uint32_t dex_method_idx, const dex::CodeItem* code);
Options& options_;
ProfileCompilationInfo* info_;
diff --git a/dexlayout/dexlayout_test.cc b/dexlayout/dexlayout_test.cc
index 54157d9e3a..b68449ebbe 100644
--- a/dexlayout/dexlayout_test.cc
+++ b/dexlayout/dexlayout_test.cc
@@ -687,7 +687,7 @@ TEST_F(DexLayoutTest, CodeItemOverrun) {
// Change the dex instructions to make an opcode that spans past the end of the code item.
for (ClassAccessor accessor : dex->GetClasses()) {
for (const ClassAccessor::Method& method : accessor.GetMethods()) {
- DexFile::CodeItem* item = const_cast<DexFile::CodeItem*>(method.GetCodeItem());
+ dex::CodeItem* item = const_cast<dex::CodeItem*>(method.GetCodeItem());
if (item != nullptr) {
CodeItemInstructionAccessor instructions(*dex, item);
if (instructions.begin() != instructions.end()) {
@@ -793,7 +793,7 @@ TEST_F(DexLayoutTest, ClassFilter) {
for (const std::unique_ptr<const DexFile>& dex_file : dex_files) {
EXPECT_GT(dex_file->NumClassDefs(), 1u);
for (uint32_t i = 0; i < dex_file->NumClassDefs(); ++i) {
- const DexFile::ClassDef& class_def = dex_file->GetClassDef(i);
+ const dex::ClassDef& class_def = dex_file->GetClassDef(i);
LOG(INFO) << dex_file->GetClassDescriptor(class_def);
}
Options options;
@@ -828,7 +828,7 @@ TEST_F(DexLayoutTest, ClassFilter) {
ASSERT_EQ(output_dex_file->NumClassDefs(), options.class_filter_.size());
for (uint32_t i = 0; i < output_dex_file->NumClassDefs(); ++i) {
// Check that every class in the output dex file is in the filter.
- const DexFile::ClassDef& class_def = output_dex_file->GetClassDef(i);
+ const dex::ClassDef& class_def = output_dex_file->GetClassDef(i);
ASSERT_TRUE(options.class_filter_.find(output_dex_file->GetClassDescriptor(class_def)) !=
options.class_filter_.end());
}
diff --git a/dexlist/dexlist.cc b/dexlist/dexlist.cc
index bdf3ca6f11..dd32fae395 100644
--- a/dexlist/dexlist.cc
+++ b/dexlist/dexlist.cc
@@ -84,7 +84,7 @@ static std::unique_ptr<char[]> descriptorToDot(const char* str) {
*/
static void dumpMethod(const DexFile* pDexFile,
const char* fileName, u4 idx, u4 flags ATTRIBUTE_UNUSED,
- const DexFile::CodeItem* pCode, u4 codeOffset) {
+ const dex::CodeItem* pCode, u4 codeOffset) {
// Abstract and native methods don't get listed.
if (pCode == nullptr || codeOffset == 0) {
return;
@@ -92,7 +92,7 @@ static void dumpMethod(const DexFile* pDexFile,
CodeItemDebugInfoAccessor accessor(*pDexFile, pCode, idx);
// Method information.
- const DexFile::MethodId& pMethodId = pDexFile->GetMethodId(idx);
+ const dex::MethodId& pMethodId = pDexFile->GetMethodId(idx);
const char* methodName = pDexFile->StringDataByIdx(pMethodId.name_idx_);
const char* classDescriptor = pDexFile->StringByTypeIdx(pMethodId.class_idx_);
std::unique_ptr<char[]> className(descriptorToDot(classDescriptor));
@@ -134,7 +134,7 @@ static void dumpMethod(const DexFile* pDexFile,
* Runs through all direct and virtual methods in the class.
*/
void dumpClass(const DexFile* pDexFile, u4 idx) {
- const DexFile::ClassDef& class_def = pDexFile->GetClassDef(idx);
+ const dex::ClassDef& class_def = pDexFile->GetClassDef(idx);
const char* fileName = nullptr;
if (class_def.source_file_idx_.IsValid()) {
diff --git a/libdexfile/dex/art_dex_file_loader_test.cc b/libdexfile/dex/art_dex_file_loader_test.cc
index f7a20629f5..f9516dbb89 100644
--- a/libdexfile/dex/art_dex_file_loader_test.cc
+++ b/libdexfile/dex/art_dex_file_loader_test.cc
@@ -107,13 +107,13 @@ TEST_F(ArtDexFileLoaderTest, ClassDefs) {
ASSERT_TRUE(raw.get() != nullptr);
EXPECT_EQ(3U, raw->NumClassDefs());
- const DexFile::ClassDef& c0 = raw->GetClassDef(0);
+ const dex::ClassDef& c0 = raw->GetClassDef(0);
EXPECT_STREQ("LNested$1;", raw->GetClassDescriptor(c0));
- const DexFile::ClassDef& c1 = raw->GetClassDef(1);
+ const dex::ClassDef& c1 = raw->GetClassDef(1);
EXPECT_STREQ("LNested$Inner;", raw->GetClassDescriptor(c1));
- const DexFile::ClassDef& c2 = raw->GetClassDef(2);
+ const dex::ClassDef& c2 = raw->GetClassDef(2);
EXPECT_STREQ("LNested;", raw->GetClassDescriptor(c2));
}
@@ -122,7 +122,7 @@ TEST_F(ArtDexFileLoaderTest, GetMethodSignature) {
ASSERT_TRUE(raw.get() != nullptr);
EXPECT_EQ(1U, raw->NumClassDefs());
- const DexFile::ClassDef& class_def = raw->GetClassDef(0);
+ const dex::ClassDef& class_def = raw->GetClassDef(0);
ASSERT_STREQ("LGetMethodSignature;", raw->GetClassDescriptor(class_def));
ClassAccessor accessor(*raw, class_def);
@@ -133,7 +133,7 @@ TEST_F(ArtDexFileLoaderTest, GetMethodSignature) {
// Check the signature for the static initializer.
{
ASSERT_EQ(1U, accessor.NumDirectMethods());
- const DexFile::MethodId& method_id = raw->GetMethodId(cur_method->GetIndex());
+ const dex::MethodId& method_id = raw->GetMethodId(cur_method->GetIndex());
const char* name = raw->StringDataByIdx(method_id.name_idx_);
ASSERT_STREQ("<init>", name);
std::string signature(raw->GetMethodSignature(method_id).ToString());
@@ -207,7 +207,7 @@ TEST_F(ArtDexFileLoaderTest, GetMethodSignature) {
for (const Result& r : results) {
++cur_method;
ASSERT_TRUE(cur_method != methods.end());
- const DexFile::MethodId& method_id = raw->GetMethodId(cur_method->GetIndex());
+ const dex::MethodId& method_id = raw->GetMethodId(cur_method->GetIndex());
const char* name = raw->StringDataByIdx(method_id.name_idx_);
ASSERT_STREQ(r.name, name);
@@ -232,7 +232,7 @@ TEST_F(ArtDexFileLoaderTest, FindStringId) {
"D", "I", "J", nullptr };
for (size_t i = 0; strings[i] != nullptr; i++) {
const char* str = strings[i];
- const DexFile::StringId* str_id = raw->FindStringId(str);
+ const dex::StringId* str_id = raw->FindStringId(str);
const char* dex_str = raw->GetStringData(*str_id);
EXPECT_STREQ(dex_str, str);
}
@@ -241,10 +241,10 @@ TEST_F(ArtDexFileLoaderTest, FindStringId) {
TEST_F(ArtDexFileLoaderTest, FindTypeId) {
for (size_t i = 0; i < java_lang_dex_file_->NumTypeIds(); i++) {
const char* type_str = java_lang_dex_file_->StringByTypeIdx(dex::TypeIndex(i));
- const DexFile::StringId* type_str_id = java_lang_dex_file_->FindStringId(type_str);
+ const dex::StringId* type_str_id = java_lang_dex_file_->FindStringId(type_str);
ASSERT_TRUE(type_str_id != nullptr);
dex::StringIndex type_str_idx = java_lang_dex_file_->GetIndexForStringId(*type_str_id);
- const DexFile::TypeId* type_id = java_lang_dex_file_->FindTypeId(type_str_idx);
+ const dex::TypeId* type_id = java_lang_dex_file_->FindTypeId(type_str_idx);
ASSERT_EQ(type_id, java_lang_dex_file_->FindTypeId(type_str));
ASSERT_TRUE(type_id != nullptr);
EXPECT_EQ(java_lang_dex_file_->GetIndexForTypeId(*type_id).index_, i);
@@ -253,15 +253,15 @@ TEST_F(ArtDexFileLoaderTest, FindTypeId) {
TEST_F(ArtDexFileLoaderTest, FindProtoId) {
for (size_t i = 0; i < java_lang_dex_file_->NumProtoIds(); i++) {
- const DexFile::ProtoId& to_find = java_lang_dex_file_->GetProtoId(dex::ProtoIndex(i));
- const DexFile::TypeList* to_find_tl = java_lang_dex_file_->GetProtoParameters(to_find);
+ const dex::ProtoId& to_find = java_lang_dex_file_->GetProtoId(dex::ProtoIndex(i));
+ const dex::TypeList* to_find_tl = java_lang_dex_file_->GetProtoParameters(to_find);
std::vector<dex::TypeIndex> to_find_types;
if (to_find_tl != nullptr) {
for (size_t j = 0; j < to_find_tl->Size(); j++) {
to_find_types.push_back(to_find_tl->GetTypeItem(j).type_idx_);
}
}
- const DexFile::ProtoId* found =
+ const dex::ProtoId* found =
java_lang_dex_file_->FindProtoId(to_find.return_type_idx_, to_find_types);
ASSERT_TRUE(found != nullptr);
EXPECT_EQ(java_lang_dex_file_->GetIndexForProtoId(*found), dex::ProtoIndex(i));
@@ -270,11 +270,11 @@ TEST_F(ArtDexFileLoaderTest, FindProtoId) {
TEST_F(ArtDexFileLoaderTest, FindMethodId) {
for (size_t i = 0; i < java_lang_dex_file_->NumMethodIds(); i++) {
- const DexFile::MethodId& to_find = java_lang_dex_file_->GetMethodId(i);
- const DexFile::TypeId& klass = java_lang_dex_file_->GetTypeId(to_find.class_idx_);
- const DexFile::StringId& name = java_lang_dex_file_->GetStringId(to_find.name_idx_);
- const DexFile::ProtoId& signature = java_lang_dex_file_->GetProtoId(to_find.proto_idx_);
- const DexFile::MethodId* found = java_lang_dex_file_->FindMethodId(klass, name, signature);
+ const dex::MethodId& to_find = java_lang_dex_file_->GetMethodId(i);
+ const dex::TypeId& klass = java_lang_dex_file_->GetTypeId(to_find.class_idx_);
+ const dex::StringId& name = java_lang_dex_file_->GetStringId(to_find.name_idx_);
+ const dex::ProtoId& signature = java_lang_dex_file_->GetProtoId(to_find.proto_idx_);
+ const dex::MethodId* found = java_lang_dex_file_->FindMethodId(klass, name, signature);
ASSERT_TRUE(found != nullptr) << "Didn't find method " << i << ": "
<< java_lang_dex_file_->StringByTypeIdx(to_find.class_idx_) << "."
<< java_lang_dex_file_->GetStringData(name)
@@ -285,11 +285,11 @@ TEST_F(ArtDexFileLoaderTest, FindMethodId) {
TEST_F(ArtDexFileLoaderTest, FindFieldId) {
for (size_t i = 0; i < java_lang_dex_file_->NumFieldIds(); i++) {
- const DexFile::FieldId& to_find = java_lang_dex_file_->GetFieldId(i);
- const DexFile::TypeId& klass = java_lang_dex_file_->GetTypeId(to_find.class_idx_);
- const DexFile::StringId& name = java_lang_dex_file_->GetStringId(to_find.name_idx_);
- const DexFile::TypeId& type = java_lang_dex_file_->GetTypeId(to_find.type_idx_);
- const DexFile::FieldId* found = java_lang_dex_file_->FindFieldId(klass, name, type);
+ const dex::FieldId& to_find = java_lang_dex_file_->GetFieldId(i);
+ const dex::TypeId& klass = java_lang_dex_file_->GetTypeId(to_find.class_idx_);
+ const dex::StringId& name = java_lang_dex_file_->GetStringId(to_find.name_idx_);
+ const dex::TypeId& type = java_lang_dex_file_->GetTypeId(to_find.type_idx_);
+ const dex::FieldId* found = java_lang_dex_file_->FindFieldId(klass, name, type);
ASSERT_TRUE(found != nullptr) << "Didn't find field " << i << ": "
<< java_lang_dex_file_->StringByTypeIdx(to_find.type_idx_) << " "
<< java_lang_dex_file_->StringByTypeIdx(to_find.class_idx_) << "."
diff --git a/libdexfile/dex/class_accessor-inl.h b/libdexfile/dex/class_accessor-inl.h
index 334b0720c9..c9e5360f31 100644
--- a/libdexfile/dex/class_accessor-inl.h
+++ b/libdexfile/dex/class_accessor-inl.h
@@ -31,7 +31,7 @@ inline ClassAccessor::ClassAccessor(const ClassIteratorData& data)
: ClassAccessor(data.dex_file_, data.class_def_idx_) {}
inline ClassAccessor::ClassAccessor(const DexFile& dex_file,
- const DexFile::ClassDef& class_def,
+ const dex::ClassDef& class_def,
bool parse_hiddenapi_class_data)
: ClassAccessor(dex_file,
dex_file.GetClassData(class_def),
@@ -54,7 +54,7 @@ inline ClassAccessor::ClassAccessor(const DexFile& dex_file,
num_direct_methods_(ptr_pos_ != nullptr ? DecodeUnsignedLeb128(&ptr_pos_) : 0u),
num_virtual_methods_(ptr_pos_ != nullptr ? DecodeUnsignedLeb128(&ptr_pos_) : 0u) {
if (parse_hiddenapi_class_data && class_def_index != DexFile::kDexNoIndex32) {
- const DexFile::HiddenapiClassData* hiddenapi_class_data = dex_file.GetHiddenapiClassData();
+ const dex::HiddenapiClassData* hiddenapi_class_data = dex_file.GetHiddenapiClassData();
if (hiddenapi_class_data != nullptr) {
hiddenapi_ptr_pos_ = hiddenapi_class_data->GetFlagsPointer(class_def_index);
}
@@ -131,7 +131,7 @@ inline void ClassAccessor::VisitFields(const StaticFieldVisitor& static_field_vi
VoidFunctor());
}
-inline const DexFile::CodeItem* ClassAccessor::GetCodeItem(const Method& method) const {
+inline const dex::CodeItem* ClassAccessor::GetCodeItem(const Method& method) const {
return dex_file_.GetCodeItem(method.GetCodeItemOffset());
}
@@ -147,7 +147,7 @@ inline const char* ClassAccessor::GetDescriptor() const {
return dex_file_.StringByTypeIdx(GetClassIdx());
}
-inline const DexFile::CodeItem* ClassAccessor::Method::GetCodeItem() const {
+inline const dex::CodeItem* ClassAccessor::Method::GetCodeItem() const {
return dex_file_.GetCodeItem(code_off_);
}
diff --git a/libdexfile/dex/class_accessor.h b/libdexfile/dex/class_accessor.h
index bd7b912cb4..cf6e5095d6 100644
--- a/libdexfile/dex/class_accessor.h
+++ b/libdexfile/dex/class_accessor.h
@@ -99,7 +99,7 @@ class ClassAccessor {
CodeItemInstructionAccessor GetInstructions() const;
CodeItemDataAccessor GetInstructionsAndData() const;
- const DexFile::CodeItem* GetCodeItem() const;
+ const dex::CodeItem* GetCodeItem() const;
bool IsStaticOrDirect() const {
return is_static_or_direct_;
@@ -266,7 +266,7 @@ class ClassAccessor {
ALWAYS_INLINE ClassAccessor(const ClassIteratorData& data); // NOLINT [runtime/explicit] [5]
ALWAYS_INLINE ClassAccessor(const DexFile& dex_file,
- const DexFile::ClassDef& class_def,
+ const dex::ClassDef& class_def,
bool parse_hiddenapi_class_data = false);
ALWAYS_INLINE ClassAccessor(const DexFile& dex_file, uint32_t class_def_index);
@@ -277,7 +277,7 @@ class ClassAccessor {
bool parse_hiddenapi_class_data = false);
// Return the code item for a method.
- const DexFile::CodeItem* GetCodeItem(const Method& method) const;
+ const dex::CodeItem* GetCodeItem(const Method& method) const;
// Iterator data is not very iterator friendly, use visitors to get around this.
template <typename StaticFieldVisitor,
@@ -361,7 +361,7 @@ class ClassAccessor {
return class_def_index_;
}
- const DexFile::ClassDef& GetClassDef() const {
+ const dex::ClassDef& GetClassDef() const {
return dex_file_.GetClassDef(GetClassDefIndex());
}
diff --git a/libdexfile/dex/class_accessor_test.cc b/libdexfile/dex/class_accessor_test.cc
index 1f30ae54d6..9f2ee23327 100644
--- a/libdexfile/dex/class_accessor_test.cc
+++ b/libdexfile/dex/class_accessor_test.cc
@@ -30,7 +30,7 @@ TEST_F(ClassAccessorTest, TestVisiting) {
uint32_t class_def_idx = 0u;
ASSERT_GT(dex_file->NumClassDefs(), 0u);
for (ClassAccessor accessor : dex_file->GetClasses()) {
- const DexFile::ClassDef& class_def = dex_file->GetClassDef(accessor.GetClassDefIndex());
+ const dex::ClassDef& class_def = dex_file->GetClassDef(accessor.GetClassDefIndex());
EXPECT_EQ(accessor.GetDescriptor(), dex_file->StringByTypeIdx(class_def.class_idx_));
EXPECT_EQ(class_def_idx, accessor.GetClassDefIndex());
++class_def_idx;
diff --git a/libdexfile/dex/code_item_accessors-inl.h b/libdexfile/dex/code_item_accessors-inl.h
index bbf2224b06..15e34b74be 100644
--- a/libdexfile/dex/code_item_accessors-inl.h
+++ b/libdexfile/dex/code_item_accessors-inl.h
@@ -48,7 +48,7 @@ inline void CodeItemInstructionAccessor::Init(const StandardDexFile::CodeItem& c
}
inline void CodeItemInstructionAccessor::Init(const DexFile& dex_file,
- const DexFile::CodeItem* code_item) {
+ const dex::CodeItem* code_item) {
if (code_item != nullptr) {
DCHECK(dex_file.IsInDataSection(code_item));
if (dex_file.IsCompactDexFile()) {
@@ -62,7 +62,7 @@ inline void CodeItemInstructionAccessor::Init(const DexFile& dex_file,
inline CodeItemInstructionAccessor::CodeItemInstructionAccessor(
const DexFile& dex_file,
- const DexFile::CodeItem* code_item) {
+ const dex::CodeItem* code_item) {
Init(dex_file, code_item);
}
@@ -101,7 +101,7 @@ inline void CodeItemDataAccessor::Init(const StandardDexFile::CodeItem& code_ite
}
inline void CodeItemDataAccessor::Init(const DexFile& dex_file,
- const DexFile::CodeItem* code_item) {
+ const dex::CodeItem* code_item) {
if (code_item != nullptr) {
if (dex_file.IsCompactDexFile()) {
CodeItemDataAccessor::Init(down_cast<const CompactDexFile::CodeItem&>(*code_item));
@@ -113,12 +113,12 @@ inline void CodeItemDataAccessor::Init(const DexFile& dex_file,
}
inline CodeItemDataAccessor::CodeItemDataAccessor(const DexFile& dex_file,
- const DexFile::CodeItem* code_item) {
+ const dex::CodeItem* code_item) {
Init(dex_file, code_item);
}
-inline IterationRange<const DexFile::TryItem*> CodeItemDataAccessor::TryItems() const {
- const DexFile::TryItem* try_items = DexFile::GetTryItems(end(), 0u);
+inline IterationRange<const dex::TryItem*> CodeItemDataAccessor::TryItems() const {
+ const dex::TryItem* try_items = DexFile::GetTryItems(end(), 0u);
return {
try_items,
try_items + TriesSize() };
@@ -128,8 +128,8 @@ inline const uint8_t* CodeItemDataAccessor::GetCatchHandlerData(size_t offset) c
return DexFile::GetCatchHandlerData(end(), TriesSize(), offset);
}
-inline const DexFile::TryItem* CodeItemDataAccessor::FindTryItem(uint32_t try_dex_pc) const {
- IterationRange<const DexFile::TryItem*> try_items(TryItems());
+inline const dex::TryItem* CodeItemDataAccessor::FindTryItem(uint32_t try_dex_pc) const {
+ IterationRange<const dex::TryItem*> try_items(TryItems());
int32_t index = DexFile::FindTryItem(try_items.begin(),
try_items.end() - try_items.begin(),
try_dex_pc);
@@ -158,7 +158,7 @@ inline const void* CodeItemDataAccessor::CodeItemDataEnd() const {
}
inline void CodeItemDebugInfoAccessor::Init(const DexFile& dex_file,
- const DexFile::CodeItem* code_item,
+ const dex::CodeItem* code_item,
uint32_t dex_method_index) {
if (code_item == nullptr) {
return;
diff --git a/libdexfile/dex/code_item_accessors.h b/libdexfile/dex/code_item_accessors.h
index c307c9f70b..0ae5905860 100644
--- a/libdexfile/dex/code_item_accessors.h
+++ b/libdexfile/dex/code_item_accessors.h
@@ -19,21 +19,28 @@
#ifndef ART_LIBDEXFILE_DEX_CODE_ITEM_ACCESSORS_H_
#define ART_LIBDEXFILE_DEX_CODE_ITEM_ACCESSORS_H_
+#include <android-base/logging.h>
+
#include "compact_dex_file.h"
-#include "dex_file.h"
#include "dex_instruction_iterator.h"
#include "standard_dex_file.h"
namespace art {
+namespace dex {
+struct CodeItem;
+struct TryItem;
+} // namespace dex
+
class ArtMethod;
+class DexFile;
// Abstracts accesses to the instruction fields of code items for CompactDexFile and
// StandardDexFile.
class CodeItemInstructionAccessor {
public:
ALWAYS_INLINE CodeItemInstructionAccessor(const DexFile& dex_file,
- const DexFile::CodeItem* code_item);
+ const dex::CodeItem* code_item);
ALWAYS_INLINE explicit CodeItemInstructionAccessor(ArtMethod* method);
@@ -73,7 +80,7 @@ class CodeItemInstructionAccessor {
ALWAYS_INLINE void Init(uint32_t insns_size_in_code_units, const uint16_t* insns);
ALWAYS_INLINE void Init(const CompactDexFile::CodeItem& code_item);
ALWAYS_INLINE void Init(const StandardDexFile::CodeItem& code_item);
- ALWAYS_INLINE void Init(const DexFile& dex_file, const DexFile::CodeItem* code_item);
+ ALWAYS_INLINE void Init(const DexFile& dex_file, const dex::CodeItem* code_item);
private:
// size of the insns array, in 2 byte code units. 0 if there is no code item.
@@ -87,7 +94,7 @@ class CodeItemInstructionAccessor {
// StandardDexFile.
class CodeItemDataAccessor : public CodeItemInstructionAccessor {
public:
- ALWAYS_INLINE CodeItemDataAccessor(const DexFile& dex_file, const DexFile::CodeItem* code_item);
+ ALWAYS_INLINE CodeItemDataAccessor(const DexFile& dex_file, const dex::CodeItem* code_item);
uint16_t RegistersSize() const {
return registers_size_;
@@ -105,11 +112,11 @@ class CodeItemDataAccessor : public CodeItemInstructionAccessor {
return tries_size_;
}
- IterationRange<const DexFile::TryItem*> TryItems() const;
+ IterationRange<const dex::TryItem*> TryItems() const;
const uint8_t* GetCatchHandlerData(size_t offset = 0) const;
- const DexFile::TryItem* FindTryItem(uint32_t try_dex_pc) const;
+ const dex::TryItem* FindTryItem(uint32_t try_dex_pc) const;
inline const void* CodeItemDataEnd() const;
@@ -118,7 +125,7 @@ class CodeItemDataAccessor : public CodeItemInstructionAccessor {
ALWAYS_INLINE void Init(const CompactDexFile::CodeItem& code_item);
ALWAYS_INLINE void Init(const StandardDexFile::CodeItem& code_item);
- ALWAYS_INLINE void Init(const DexFile& dex_file, const DexFile::CodeItem* code_item);
+ ALWAYS_INLINE void Init(const DexFile& dex_file, const dex::CodeItem* code_item);
private:
// Fields mirrored from the dex/cdex code item.
@@ -136,13 +143,13 @@ class CodeItemDebugInfoAccessor : public CodeItemDataAccessor {
// Initialize with an existing offset.
ALWAYS_INLINE CodeItemDebugInfoAccessor(const DexFile& dex_file,
- const DexFile::CodeItem* code_item,
+ const dex::CodeItem* code_item,
uint32_t dex_method_index) {
Init(dex_file, code_item, dex_method_index);
}
ALWAYS_INLINE void Init(const DexFile& dex_file,
- const DexFile::CodeItem* code_item,
+ const dex::CodeItem* code_item,
uint32_t dex_method_index);
ALWAYS_INLINE explicit CodeItemDebugInfoAccessor(ArtMethod* method);
diff --git a/libdexfile/dex/code_item_accessors_test.cc b/libdexfile/dex/code_item_accessors_test.cc
index 87f4bab672..c5891f9d46 100644
--- a/libdexfile/dex/code_item_accessors_test.cc
+++ b/libdexfile/dex/code_item_accessors_test.cc
@@ -71,7 +71,7 @@ TEST(CodeItemAccessorsTest, TestDexInstructionsAccessor) {
static constexpr size_t kInsnsSizeInCodeUnits = 5;
auto verify_code_item = [&](const DexFile* dex,
- const DexFile::CodeItem* item,
+ const dex::CodeItem* item,
const uint16_t* insns) {
CodeItemInstructionAccessor insns_accessor(*dex, item);
EXPECT_TRUE(insns_accessor.HasCodeItem());
diff --git a/libdexfile/dex/compact_dex_file.cc b/libdexfile/dex/compact_dex_file.cc
index 641c523158..a5044aad7e 100644
--- a/libdexfile/dex/compact_dex_file.cc
+++ b/libdexfile/dex/compact_dex_file.cc
@@ -55,7 +55,7 @@ bool CompactDexFile::SupportsDefaultMethods() const {
static_cast<uint32_t>(FeatureFlags::kDefaultMethods)) != 0;
}
-uint32_t CompactDexFile::GetCodeItemSize(const DexFile::CodeItem& item) const {
+uint32_t CompactDexFile::GetCodeItemSize(const dex::CodeItem& item) const {
DCHECK(IsInDataSection(&item));
return reinterpret_cast<uintptr_t>(CodeItemDataAccessor(*this, &item).CodeItemDataEnd()) -
reinterpret_cast<uintptr_t>(&item);
diff --git a/libdexfile/dex/compact_dex_file.h b/libdexfile/dex/compact_dex_file.h
index 8eade6dba8..47edd517fa 100644
--- a/libdexfile/dex/compact_dex_file.h
+++ b/libdexfile/dex/compact_dex_file.h
@@ -84,7 +84,7 @@ class CompactDexFile : public DexFile {
// Like the standard code item except without a debug info offset. Each code item may have a
// preheader to encode large methods. In 99% of cases, the preheader is not used. This enables
// smaller size with a good fast path case in the accessors.
- struct CodeItem : public DexFile::CodeItem {
+ struct CodeItem : public dex::CodeItem {
static constexpr size_t kAlignment = sizeof(uint16_t);
// Max preheader size in uint16_ts.
static constexpr size_t kMaxPreHeaderSize = 6;
@@ -271,7 +271,7 @@ class CompactDexFile : public DexFile {
bool SupportsDefaultMethods() const override;
- uint32_t GetCodeItemSize(const DexFile::CodeItem& item) const override;
+ uint32_t GetCodeItemSize(const dex::CodeItem& item) const override;
uint32_t GetDebugInfoOffset(uint32_t dex_method_index) const {
return debug_info_offsets_.GetOffset(dex_method_index);
diff --git a/libdexfile/dex/dex_file-inl.h b/libdexfile/dex/dex_file-inl.h
index c884eee88b..cacd7ddba1 100644
--- a/libdexfile/dex/dex_file-inl.h
+++ b/libdexfile/dex/dex_file-inl.h
@@ -31,12 +31,12 @@
namespace art {
-inline int32_t DexFile::GetStringLength(const StringId& string_id) const {
+inline int32_t DexFile::GetStringLength(const dex::StringId& string_id) const {
const uint8_t* ptr = DataBegin() + string_id.string_data_off_;
return DecodeUnsignedLeb128(&ptr);
}
-inline const char* DexFile::GetStringDataAndUtf16Length(const StringId& string_id,
+inline const char* DexFile::GetStringDataAndUtf16Length(const dex::StringId& string_id,
uint32_t* utf16_length) const {
DCHECK(utf16_length != nullptr) << GetLocation();
const uint8_t* ptr = DataBegin() + string_id.string_data_off_;
@@ -44,7 +44,7 @@ inline const char* DexFile::GetStringDataAndUtf16Length(const StringId& string_i
return reinterpret_cast<const char*>(ptr);
}
-inline const char* DexFile::GetStringData(const StringId& string_id) const {
+inline const char* DexFile::GetStringData(const dex::StringId& string_id) const {
uint32_t ignored;
return GetStringDataAndUtf16Length(string_id, &ignored);
}
@@ -55,7 +55,7 @@ inline const char* DexFile::StringDataAndUtf16LengthByIdx(dex::StringIndex idx,
*utf16_length = 0;
return nullptr;
}
- const StringId& string_id = GetStringId(idx);
+ const dex::StringId& string_id = GetStringId(idx);
return GetStringDataAndUtf16Length(string_id, utf16_length);
}
@@ -68,7 +68,7 @@ inline const char* DexFile::StringByTypeIdx(dex::TypeIndex idx, uint32_t* unicod
if (!idx.IsValid()) {
return nullptr;
}
- const TypeId& type_id = GetTypeId(idx);
+ const dex::TypeId& type_id = GetTypeId(idx);
return StringDataAndUtf16LengthByIdx(type_id.descriptor_idx_, unicode_length);
}
@@ -76,41 +76,43 @@ inline const char* DexFile::StringByTypeIdx(dex::TypeIndex idx) const {
if (!idx.IsValid()) {
return nullptr;
}
- const TypeId& type_id = GetTypeId(idx);
+ const dex::TypeId& type_id = GetTypeId(idx);
return StringDataByIdx(type_id.descriptor_idx_);
}
-inline const char* DexFile::GetTypeDescriptor(const TypeId& type_id) const {
+inline const char* DexFile::GetTypeDescriptor(const dex::TypeId& type_id) const {
return StringDataByIdx(type_id.descriptor_idx_);
}
-inline const char* DexFile::GetFieldTypeDescriptor(const FieldId& field_id) const {
- const DexFile::TypeId& type_id = GetTypeId(field_id.type_idx_);
+inline const char* DexFile::GetFieldTypeDescriptor(const dex::FieldId& field_id) const {
+ const dex::TypeId& type_id = GetTypeId(field_id.type_idx_);
return GetTypeDescriptor(type_id);
}
-inline const char* DexFile::GetFieldName(const FieldId& field_id) const {
+inline const char* DexFile::GetFieldName(const dex::FieldId& field_id) const {
return StringDataByIdx(field_id.name_idx_);
}
-inline const char* DexFile::GetMethodDeclaringClassDescriptor(const MethodId& method_id) const {
- const DexFile::TypeId& type_id = GetTypeId(method_id.class_idx_);
+inline const char* DexFile::GetMethodDeclaringClassDescriptor(const dex::MethodId& method_id)
+ const {
+ const dex::TypeId& type_id = GetTypeId(method_id.class_idx_);
return GetTypeDescriptor(type_id);
}
-inline const Signature DexFile::GetMethodSignature(const MethodId& method_id) const {
+inline const Signature DexFile::GetMethodSignature(const dex::MethodId& method_id) const {
return Signature(this, GetProtoId(method_id.proto_idx_));
}
-inline const Signature DexFile::GetProtoSignature(const ProtoId& proto_id) const {
+inline const Signature DexFile::GetProtoSignature(const dex::ProtoId& proto_id) const {
return Signature(this, proto_id);
}
-inline const char* DexFile::GetMethodName(const MethodId& method_id) const {
+inline const char* DexFile::GetMethodName(const dex::MethodId& method_id) const {
return StringDataByIdx(method_id.name_idx_);
}
-inline const char* DexFile::GetMethodName(const MethodId& method_id, uint32_t* utf_length) const {
+inline const char* DexFile::GetMethodName(const dex::MethodId& method_id, uint32_t* utf_length)
+ const {
return StringDataAndUtf16LengthByIdx(method_id.name_idx_, utf_length);
}
@@ -122,32 +124,34 @@ inline const char* DexFile::GetMethodShorty(uint32_t idx) const {
return StringDataByIdx(GetProtoId(GetMethodId(idx).proto_idx_).shorty_idx_);
}
-inline const char* DexFile::GetMethodShorty(const MethodId& method_id) const {
+inline const char* DexFile::GetMethodShorty(const dex::MethodId& method_id) const {
return StringDataByIdx(GetProtoId(method_id.proto_idx_).shorty_idx_);
}
-inline const char* DexFile::GetMethodShorty(const MethodId& method_id, uint32_t* length) const {
+inline const char* DexFile::GetMethodShorty(const dex::MethodId& method_id, uint32_t* length)
+ const {
// Using the UTF16 length is safe here as shorties are guaranteed to be ASCII characters.
return StringDataAndUtf16LengthByIdx(GetProtoId(method_id.proto_idx_).shorty_idx_, length);
}
-inline const char* DexFile::GetClassDescriptor(const ClassDef& class_def) const {
+inline const char* DexFile::GetClassDescriptor(const dex::ClassDef& class_def) const {
return StringByTypeIdx(class_def.class_idx_);
}
-inline const char* DexFile::GetReturnTypeDescriptor(const ProtoId& proto_id) const {
+inline const char* DexFile::GetReturnTypeDescriptor(const dex::ProtoId& proto_id) const {
return StringByTypeIdx(proto_id.return_type_idx_);
}
inline const char* DexFile::GetShorty(dex::ProtoIndex proto_idx) const {
- const ProtoId& proto_id = GetProtoId(proto_idx);
+ const dex::ProtoId& proto_id = GetProtoId(proto_idx);
return StringDataByIdx(proto_id.shorty_idx_);
}
-inline const DexFile::TryItem* DexFile::GetTryItems(const DexInstructionIterator& code_item_end,
- uint32_t offset) {
- return reinterpret_cast<const TryItem*>
- (RoundUp(reinterpret_cast<uintptr_t>(&code_item_end.Inst()), TryItem::kAlignment)) + offset;
+inline const dex::TryItem* DexFile::GetTryItems(const DexInstructionIterator& code_item_end,
+ uint32_t offset) {
+ return reinterpret_cast<const dex::TryItem*>
+ (RoundUp(reinterpret_cast<uintptr_t>(&code_item_end.Inst()), dex::TryItem::kAlignment)) +
+ offset;
}
static inline bool DexFileStringEquals(const DexFile* df1, dex::StringIndex sidx1,
@@ -184,8 +188,8 @@ inline bool Signature::operator==(const Signature& rhs) const {
}
}
if (lhs_shorty[0] == 'L') {
- const DexFile::TypeId& return_type_id = dex_file_->GetTypeId(proto_id_->return_type_idx_);
- const DexFile::TypeId& rhs_return_type_id =
+ const dex::TypeId& return_type_id = dex_file_->GetTypeId(proto_id_->return_type_idx_);
+ const dex::TypeId& rhs_return_type_id =
rhs.dex_file_->GetTypeId(rhs.proto_id_->return_type_idx_);
if (!DexFileStringEquals(dex_file_, return_type_id.descriptor_idx_,
rhs.dex_file_, rhs_return_type_id.descriptor_idx_)) {
@@ -193,16 +197,16 @@ inline bool Signature::operator==(const Signature& rhs) const {
}
}
if (lhs_shorty.find('L', 1) != StringPiece::npos) {
- const DexFile::TypeList* params = dex_file_->GetProtoParameters(*proto_id_);
- const DexFile::TypeList* rhs_params = rhs.dex_file_->GetProtoParameters(*rhs.proto_id_);
+ const dex::TypeList* params = dex_file_->GetProtoParameters(*proto_id_);
+ const dex::TypeList* rhs_params = rhs.dex_file_->GetProtoParameters(*rhs.proto_id_);
// We found a reference parameter in the matching shorty, so both lists must be non-empty.
DCHECK(params != nullptr);
DCHECK(rhs_params != nullptr);
uint32_t params_size = params->Size();
DCHECK_EQ(params_size, rhs_params->Size()); // Parameter list size must match.
for (uint32_t i = 0; i < params_size; ++i) {
- const DexFile::TypeId& param_id = dex_file_->GetTypeId(params->GetTypeItem(i).type_idx_);
- const DexFile::TypeId& rhs_param_id =
+ const dex::TypeId& param_id = dex_file_->GetTypeId(params->GetTypeItem(i).type_idx_);
+ const dex::TypeId& rhs_param_id =
rhs.dex_file_->GetTypeId(rhs_params->GetTypeItem(i).type_idx_);
if (!DexFileStringEquals(dex_file_, param_id.descriptor_idx_,
rhs.dex_file_, rhs_param_id.descriptor_idx_)) {
diff --git a/libdexfile/dex/dex_file.cc b/libdexfile/dex/dex_file.cc
index 7ccb9c0bad..ff519064f1 100644
--- a/libdexfile/dex/dex_file.cc
+++ b/libdexfile/dex/dex_file.cc
@@ -41,6 +41,19 @@ namespace art {
using android::base::StringPrintf;
+using dex::CallSiteIdItem;
+using dex::ClassDef;
+using dex::FieldId;
+using dex::MapList;
+using dex::MapItem;
+using dex::MethodHandleItem;
+using dex::MethodId;
+using dex::ProtoId;
+using dex::StringId;
+using dex::TryItem;
+using dex::TypeId;
+using dex::TypeList;
+
static_assert(sizeof(dex::StringIndex) == sizeof(uint32_t), "StringIndex size is wrong");
static_assert(std::is_trivially_copyable<dex::StringIndex>::value, "StringIndex not trivial");
static_assert(sizeof(dex::TypeIndex) == sizeof(uint16_t), "TypeIndex size is wrong");
@@ -195,7 +208,7 @@ uint32_t DexFile::Header::GetVersion() const {
return atoi(version);
}
-const DexFile::ClassDef* DexFile::FindClassDef(dex::TypeIndex type_idx) const {
+const ClassDef* DexFile::FindClassDef(dex::TypeIndex type_idx) const {
size_t num_class_defs = NumClassDefs();
// Fast path for rare no class defs case.
if (num_class_defs == 0) {
@@ -210,8 +223,7 @@ const DexFile::ClassDef* DexFile::FindClassDef(dex::TypeIndex type_idx) const {
return nullptr;
}
-uint32_t DexFile::FindCodeItemOffset(const DexFile::ClassDef& class_def,
- uint32_t method_idx) const {
+uint32_t DexFile::FindCodeItemOffset(const ClassDef& class_def, uint32_t method_idx) const {
ClassAccessor accessor(*this, class_def);
CHECK(accessor.HasClassData());
for (const ClassAccessor::Method& method : accessor.GetMethods()) {
@@ -223,9 +235,9 @@ uint32_t DexFile::FindCodeItemOffset(const DexFile::ClassDef& class_def,
UNREACHABLE();
}
-const DexFile::FieldId* DexFile::FindFieldId(const DexFile::TypeId& declaring_klass,
- const DexFile::StringId& name,
- const DexFile::TypeId& type) const {
+const FieldId* DexFile::FindFieldId(const TypeId& declaring_klass,
+ const StringId& name,
+ const TypeId& type) const {
// Binary search MethodIds knowing that they are sorted by class_idx, name_idx then proto_idx
const dex::TypeIndex class_idx = GetIndexForTypeId(declaring_klass);
const dex::StringIndex name_idx = GetIndexForStringId(name);
@@ -234,7 +246,7 @@ const DexFile::FieldId* DexFile::FindFieldId(const DexFile::TypeId& declaring_kl
int32_t hi = NumFieldIds() - 1;
while (hi >= lo) {
int32_t mid = (hi + lo) / 2;
- const DexFile::FieldId& field = GetFieldId(mid);
+ const FieldId& field = GetFieldId(mid);
if (class_idx > field.class_idx_) {
lo = mid + 1;
} else if (class_idx < field.class_idx_) {
@@ -258,9 +270,9 @@ const DexFile::FieldId* DexFile::FindFieldId(const DexFile::TypeId& declaring_kl
return nullptr;
}
-const DexFile::MethodId* DexFile::FindMethodId(const DexFile::TypeId& declaring_klass,
- const DexFile::StringId& name,
- const DexFile::ProtoId& signature) const {
+const MethodId* DexFile::FindMethodId(const TypeId& declaring_klass,
+ const StringId& name,
+ const ProtoId& signature) const {
// Binary search MethodIds knowing that they are sorted by class_idx, name_idx then proto_idx
const dex::TypeIndex class_idx = GetIndexForTypeId(declaring_klass);
const dex::StringIndex name_idx = GetIndexForStringId(name);
@@ -269,7 +281,7 @@ const DexFile::MethodId* DexFile::FindMethodId(const DexFile::TypeId& declaring_
int32_t hi = NumMethodIds() - 1;
while (hi >= lo) {
int32_t mid = (hi + lo) / 2;
- const DexFile::MethodId& method = GetMethodId(mid);
+ const MethodId& method = GetMethodId(mid);
if (class_idx > method.class_idx_) {
lo = mid + 1;
} else if (class_idx < method.class_idx_) {
@@ -293,12 +305,12 @@ const DexFile::MethodId* DexFile::FindMethodId(const DexFile::TypeId& declaring_
return nullptr;
}
-const DexFile::StringId* DexFile::FindStringId(const char* string) const {
+const StringId* DexFile::FindStringId(const char* string) const {
int32_t lo = 0;
int32_t hi = NumStringIds() - 1;
while (hi >= lo) {
int32_t mid = (hi + lo) / 2;
- const DexFile::StringId& str_id = GetStringId(dex::StringIndex(mid));
+ const StringId& str_id = GetStringId(dex::StringIndex(mid));
const char* str = GetStringData(str_id);
int compare = CompareModifiedUtf8ToModifiedUtf8AsUtf16CodePointValues(string, str);
if (compare > 0) {
@@ -312,13 +324,13 @@ const DexFile::StringId* DexFile::FindStringId(const char* string) const {
return nullptr;
}
-const DexFile::TypeId* DexFile::FindTypeId(const char* string) const {
+const TypeId* DexFile::FindTypeId(const char* string) const {
int32_t lo = 0;
int32_t hi = NumTypeIds() - 1;
while (hi >= lo) {
int32_t mid = (hi + lo) / 2;
const TypeId& type_id = GetTypeId(dex::TypeIndex(mid));
- const DexFile::StringId& str_id = GetStringId(type_id.descriptor_idx_);
+ const StringId& str_id = GetStringId(type_id.descriptor_idx_);
const char* str = GetStringData(str_id);
int compare = CompareModifiedUtf8ToModifiedUtf8AsUtf16CodePointValues(string, str);
if (compare > 0) {
@@ -332,7 +344,7 @@ const DexFile::TypeId* DexFile::FindTypeId(const char* string) const {
return nullptr;
}
-const DexFile::TypeId* DexFile::FindTypeId(dex::StringIndex string_idx) const {
+const TypeId* DexFile::FindTypeId(dex::StringIndex string_idx) const {
int32_t lo = 0;
int32_t hi = NumTypeIds() - 1;
while (hi >= lo) {
@@ -349,15 +361,15 @@ const DexFile::TypeId* DexFile::FindTypeId(dex::StringIndex string_idx) const {
return nullptr;
}
-const DexFile::ProtoId* DexFile::FindProtoId(dex::TypeIndex return_type_idx,
- const dex::TypeIndex* signature_type_idxs,
- uint32_t signature_length) const {
+const ProtoId* DexFile::FindProtoId(dex::TypeIndex return_type_idx,
+ const dex::TypeIndex* signature_type_idxs,
+ uint32_t signature_length) const {
int32_t lo = 0;
int32_t hi = NumProtoIds() - 1;
while (hi >= lo) {
int32_t mid = (hi + lo) / 2;
const dex::ProtoIndex proto_idx = static_cast<dex::ProtoIndex>(mid);
- const DexFile::ProtoId& proto = GetProtoId(proto_idx);
+ const ProtoId& proto = GetProtoId(proto_idx);
int compare = return_type_idx.index_ - proto.return_type_idx_.index_;
if (compare == 0) {
DexFileParameterIterator it(*this, proto);
@@ -422,7 +434,7 @@ bool DexFile::CreateTypeList(const StringPiece& signature,
}
// TODO: avoid creating a std::string just to get a 0-terminated char array
std::string descriptor(signature.data() + start_offset, offset - start_offset);
- const DexFile::TypeId* type_id = FindTypeId(descriptor.c_str());
+ const TypeId* type_id = FindTypeId(descriptor.c_str());
if (type_id == nullptr) {
return false;
}
@@ -457,7 +469,7 @@ int32_t DexFile::FindTryItem(const TryItem* try_items, uint32_t tries_size, uint
while (min < max) {
const uint32_t mid = (min + max) / 2;
- const art::DexFile::TryItem& ti = try_items[mid];
+ const TryItem& ti = try_items[mid];
const uint32_t start = ti.start_addr_;
const uint32_t end = start + ti.insn_count_;
@@ -523,9 +535,9 @@ std::string DexFile::PrettyMethod(uint32_t method_idx, bool with_signature) cons
if (method_idx >= NumMethodIds()) {
return StringPrintf("<<invalid-method-idx-%d>>", method_idx);
}
- const DexFile::MethodId& method_id = GetMethodId(method_idx);
+ const MethodId& method_id = GetMethodId(method_idx);
std::string result;
- const DexFile::ProtoId* proto_id = with_signature ? &GetProtoId(method_id.proto_idx_) : nullptr;
+ const ProtoId* proto_id = with_signature ? &GetProtoId(method_id.proto_idx_) : nullptr;
if (with_signature) {
AppendPrettyDescriptor(StringByTypeIdx(proto_id->return_type_idx_), &result);
result += ' ';
@@ -535,7 +547,7 @@ std::string DexFile::PrettyMethod(uint32_t method_idx, bool with_signature) cons
result += GetMethodName(method_id);
if (with_signature) {
result += '(';
- const DexFile::TypeList* params = GetProtoParameters(*proto_id);
+ const TypeList* params = GetProtoParameters(*proto_id);
if (params != nullptr) {
const char* separator = "";
for (uint32_t i = 0u, size = params->Size(); i != size; ++i) {
@@ -553,7 +565,7 @@ std::string DexFile::PrettyField(uint32_t field_idx, bool with_type) const {
if (field_idx >= NumFieldIds()) {
return StringPrintf("<<invalid-field-idx-%d>>", field_idx);
}
- const DexFile::FieldId& field_id = GetFieldId(field_idx);
+ const FieldId& field_id = GetFieldId(field_idx);
std::string result;
if (with_type) {
result += GetFieldTypeDescriptor(field_id);
@@ -569,12 +581,12 @@ std::string DexFile::PrettyType(dex::TypeIndex type_idx) const {
if (type_idx.index_ >= NumTypeIds()) {
return StringPrintf("<<invalid-type-idx-%d>>", type_idx.index_);
}
- const DexFile::TypeId& type_id = GetTypeId(type_idx);
+ const TypeId& type_id = GetTypeId(type_idx);
return PrettyDescriptor(GetTypeDescriptor(type_id));
}
dex::ProtoIndex DexFile::GetProtoIndexForCallSite(uint32_t call_site_idx) const {
- const DexFile::CallSiteIdItem& csi = GetCallSiteId(call_site_idx);
+ const CallSiteIdItem& csi = GetCallSiteId(call_site_idx);
CallSiteArrayValueIterator it(*this, csi);
it.Next();
it.Next();
@@ -597,7 +609,7 @@ std::string Signature::ToString() const {
CHECK(proto_id_ == nullptr);
return "<no signature>";
}
- const DexFile::TypeList* params = dex_file_->GetProtoParameters(*proto_id_);
+ const TypeList* params = dex_file_->GetProtoParameters(*proto_id_);
std::string result;
if (params == nullptr) {
result += "()";
@@ -613,7 +625,7 @@ std::string Signature::ToString() const {
}
uint32_t Signature::GetNumberOfParameters() const {
- const DexFile::TypeList* params = dex_file_->GetProtoParameters(*proto_id_);
+ const TypeList* params = dex_file_->GetProtoParameters(*proto_id_);
return (params != nullptr) ? params->Size() : 0;
}
@@ -631,7 +643,7 @@ bool Signature::operator==(const StringPiece& rhs) const {
return false; // Invalid signature
}
tail.remove_prefix(1); // "(";
- const DexFile::TypeList* params = dex_file_->GetProtoParameters(*proto_id_);
+ const TypeList* params = dex_file_->GetProtoParameters(*proto_id_);
if (params != nullptr) {
for (uint32_t i = 0; i < params->Size(); ++i) {
StringPiece param(dex_file_->StringByTypeIdx(params->GetTypeItem(i).type_idx_));
diff --git a/libdexfile/dex/dex_file.h b/libdexfile/dex/dex_file.h
index 83f47fec19..104c38de40 100644
--- a/libdexfile/dex/dex_file.h
+++ b/libdexfile/dex/dex_file.h
@@ -28,6 +28,7 @@
#include "base/macros.h"
#include "base/value_object.h"
#include "class_iterator.h"
+#include "dex_file_structs.h"
#include "dex_file_types.h"
#include "jni.h"
#include "modifiers.h"
@@ -136,150 +137,6 @@ class DexFile {
kDexTypeHiddenapiClassData = 0xF000,
};
- struct MapItem {
- uint16_t type_;
- uint16_t unused_;
- uint32_t size_;
- uint32_t offset_;
- };
-
- struct MapList {
- uint32_t size_;
- MapItem list_[1];
-
- size_t Size() const { return sizeof(uint32_t) + (size_ * sizeof(MapItem)); }
-
- private:
- DISALLOW_COPY_AND_ASSIGN(MapList);
- };
-
- // Raw string_id_item.
- struct StringId {
- uint32_t string_data_off_; // offset in bytes from the base address
-
- private:
- DISALLOW_COPY_AND_ASSIGN(StringId);
- };
-
- // Raw type_id_item.
- struct TypeId {
- dex::StringIndex descriptor_idx_; // index into string_ids
-
- private:
- DISALLOW_COPY_AND_ASSIGN(TypeId);
- };
-
- // Raw field_id_item.
- struct FieldId {
- dex::TypeIndex class_idx_; // index into type_ids_ array for defining class
- dex::TypeIndex type_idx_; // index into type_ids_ array for field type
- dex::StringIndex name_idx_; // index into string_ids_ array for field name
-
- private:
- DISALLOW_COPY_AND_ASSIGN(FieldId);
- };
-
- // Raw proto_id_item.
- struct ProtoId {
- dex::StringIndex shorty_idx_; // index into string_ids array for shorty descriptor
- dex::TypeIndex return_type_idx_; // index into type_ids array for return type
- uint16_t pad_; // padding = 0
- uint32_t parameters_off_; // file offset to type_list for parameter types
-
- private:
- DISALLOW_COPY_AND_ASSIGN(ProtoId);
- };
-
- // Raw method_id_item.
- struct MethodId {
- dex::TypeIndex class_idx_; // index into type_ids_ array for defining class
- dex::ProtoIndex proto_idx_; // index into proto_ids_ array for method prototype
- dex::StringIndex name_idx_; // index into string_ids_ array for method name
-
- private:
- DISALLOW_COPY_AND_ASSIGN(MethodId);
- };
-
- // Base code_item, compact dex and standard dex have different code item layouts.
- struct CodeItem {
- protected:
- CodeItem() = default;
-
- private:
- DISALLOW_COPY_AND_ASSIGN(CodeItem);
- };
-
- // Raw class_def_item.
- struct ClassDef {
- dex::TypeIndex class_idx_; // index into type_ids_ array for this class
- uint16_t pad1_; // padding = 0
- uint32_t access_flags_;
- dex::TypeIndex superclass_idx_; // index into type_ids_ array for superclass
- uint16_t pad2_; // padding = 0
- uint32_t interfaces_off_; // file offset to TypeList
- dex::StringIndex source_file_idx_; // index into string_ids_ for source file name
- uint32_t annotations_off_; // file offset to annotations_directory_item
- uint32_t class_data_off_; // file offset to class_data_item
- uint32_t static_values_off_; // file offset to EncodedArray
-
- // Returns the valid access flags, that is, Java modifier bits relevant to the ClassDef type
- // (class or interface). These are all in the lower 16b and do not contain runtime flags.
- uint32_t GetJavaAccessFlags() const {
- // Make sure that none of our runtime-only flags are set.
- static_assert((kAccValidClassFlags & kAccJavaFlagsMask) == kAccValidClassFlags,
- "Valid class flags not a subset of Java flags");
- static_assert((kAccValidInterfaceFlags & kAccJavaFlagsMask) == kAccValidInterfaceFlags,
- "Valid interface flags not a subset of Java flags");
-
- if ((access_flags_ & kAccInterface) != 0) {
- // Interface.
- return access_flags_ & kAccValidInterfaceFlags;
- } else {
- // Class.
- return access_flags_ & kAccValidClassFlags;
- }
- }
-
- private:
- DISALLOW_COPY_AND_ASSIGN(ClassDef);
- };
-
- // Raw type_item.
- struct TypeItem {
- dex::TypeIndex type_idx_; // index into type_ids section
-
- private:
- DISALLOW_COPY_AND_ASSIGN(TypeItem);
- };
-
- // Raw type_list.
- class TypeList {
- public:
- uint32_t Size() const {
- return size_;
- }
-
- const TypeItem& GetTypeItem(uint32_t idx) const {
- DCHECK_LT(idx, this->size_);
- return this->list_[idx];
- }
-
- // Size in bytes of the part of the list that is common.
- static constexpr size_t GetHeaderSize() {
- return 4U;
- }
-
- // Size in bytes of the whole type list including all the stored elements.
- static constexpr size_t GetListSize(size_t count) {
- return GetHeaderSize() + sizeof(TypeItem) * count;
- }
-
- private:
- uint32_t size_; // size of the list, in entries
- TypeItem list_[1]; // elements of the list
- DISALLOW_COPY_AND_ASSIGN(TypeList);
- };
-
// MethodHandle Types
enum class MethodHandleType : uint16_t { // private
kStaticPut = 0x0000, // a setter for a given static field.
@@ -296,37 +153,6 @@ class DexFile {
kLast = kInvokeInterface
};
- // raw method_handle_item
- struct MethodHandleItem {
- uint16_t method_handle_type_;
- uint16_t reserved1_; // Reserved for future use.
- uint16_t field_or_method_idx_; // Field index for accessors, method index otherwise.
- uint16_t reserved2_; // Reserved for future use.
- private:
- DISALLOW_COPY_AND_ASSIGN(MethodHandleItem);
- };
-
- // raw call_site_id_item
- struct CallSiteIdItem {
- uint32_t data_off_; // Offset into data section pointing to encoded array items.
- private:
- DISALLOW_COPY_AND_ASSIGN(CallSiteIdItem);
- };
-
- // Raw try_item.
- struct TryItem {
- static constexpr size_t kAlignment = sizeof(uint32_t);
-
- uint32_t start_addr_;
- uint16_t insn_count_;
- uint16_t handler_off_;
-
- private:
- TryItem() = default;
- friend class DexWriter;
- DISALLOW_COPY_AND_ASSIGN(TryItem);
- };
-
// Annotation constants.
enum {
kDexVisibilityBuild = 0x00, /* annotation visibility */
@@ -356,92 +182,6 @@ class DexFile {
kDexAnnotationValueArgShift = 5,
};
- struct AnnotationsDirectoryItem {
- uint32_t class_annotations_off_;
- uint32_t fields_size_;
- uint32_t methods_size_;
- uint32_t parameters_size_;
-
- private:
- DISALLOW_COPY_AND_ASSIGN(AnnotationsDirectoryItem);
- };
-
- struct FieldAnnotationsItem {
- uint32_t field_idx_;
- uint32_t annotations_off_;
-
- private:
- DISALLOW_COPY_AND_ASSIGN(FieldAnnotationsItem);
- };
-
- struct MethodAnnotationsItem {
- uint32_t method_idx_;
- uint32_t annotations_off_;
-
- private:
- DISALLOW_COPY_AND_ASSIGN(MethodAnnotationsItem);
- };
-
- struct ParameterAnnotationsItem {
- uint32_t method_idx_;
- uint32_t annotations_off_;
-
- private:
- DISALLOW_COPY_AND_ASSIGN(ParameterAnnotationsItem);
- };
-
- struct AnnotationSetRefItem {
- uint32_t annotations_off_;
-
- private:
- DISALLOW_COPY_AND_ASSIGN(AnnotationSetRefItem);
- };
-
- struct AnnotationSetRefList {
- uint32_t size_;
- AnnotationSetRefItem list_[1];
-
- private:
- DISALLOW_COPY_AND_ASSIGN(AnnotationSetRefList);
- };
-
- struct AnnotationSetItem {
- uint32_t size_;
- uint32_t entries_[1];
-
- private:
- DISALLOW_COPY_AND_ASSIGN(AnnotationSetItem);
- };
-
- struct AnnotationItem {
- uint8_t visibility_;
- uint8_t annotation_[1];
-
- private:
- DISALLOW_COPY_AND_ASSIGN(AnnotationItem);
- };
-
- struct HiddenapiClassData {
- uint32_t size_; // total size of the item
- uint32_t flags_offset_[1]; // array of offsets from the beginning of this item,
- // indexed by class def index
-
- // Returns a pointer to the beginning of a uleb128-stream of hiddenapi
- // flags for a class def of given index. Values are in the same order
- // as fields/methods in the class data. Returns null if the class does
- // not have class data.
- const uint8_t* GetFlagsPointer(uint32_t class_def_idx) const {
- if (flags_offset_[class_def_idx] == 0) {
- return nullptr;
- } else {
- return reinterpret_cast<const uint8_t*>(this) + flags_offset_[class_def_idx];
- }
- }
-
- private:
- DISALLOW_COPY_AND_ASSIGN(HiddenapiClassData);
- };
-
enum AnnotationResultStyle { // private
kAllObjects,
kPrimitivesOrObjects,
@@ -496,25 +236,26 @@ class DexFile {
}
// Returns the StringId at the specified index.
- const StringId& GetStringId(dex::StringIndex idx) const {
+ const dex::StringId& GetStringId(dex::StringIndex idx) const {
DCHECK_LT(idx.index_, NumStringIds()) << GetLocation();
return string_ids_[idx.index_];
}
- dex::StringIndex GetIndexForStringId(const StringId& string_id) const {
+ dex::StringIndex GetIndexForStringId(const dex::StringId& string_id) const {
CHECK_GE(&string_id, string_ids_) << GetLocation();
CHECK_LT(&string_id, string_ids_ + header_->string_ids_size_) << GetLocation();
return dex::StringIndex(&string_id - string_ids_);
}
- int32_t GetStringLength(const StringId& string_id) const;
+ int32_t GetStringLength(const dex::StringId& string_id) const;
// Returns a pointer to the UTF-8 string data referred to by the given string_id as well as the
// length of the string when decoded as a UTF-16 string. Note the UTF-16 length is not the same
// as the string length of the string data.
- const char* GetStringDataAndUtf16Length(const StringId& string_id, uint32_t* utf16_length) const;
+ const char* GetStringDataAndUtf16Length(const dex::StringId& string_id,
+ uint32_t* utf16_length) const;
- const char* GetStringData(const StringId& string_id) const;
+ const char* GetStringData(const dex::StringId& string_id) const;
// Index version of GetStringDataAndUtf16Length.
const char* StringDataAndUtf16LengthByIdx(dex::StringIndex idx, uint32_t* utf16_length) const;
@@ -522,9 +263,9 @@ class DexFile {
const char* StringDataByIdx(dex::StringIndex idx) const;
// Looks up a string id for a given modified utf8 string.
- const StringId* FindStringId(const char* string) const;
+ const dex::StringId* FindStringId(const char* string) const;
- const TypeId* FindTypeId(const char* string) const;
+ const dex::TypeId* FindTypeId(const char* string) const;
// Returns the number of type identifiers in the .dex file.
uint32_t NumTypeIds() const {
@@ -537,12 +278,12 @@ class DexFile {
}
// Returns the TypeId at the specified index.
- const TypeId& GetTypeId(dex::TypeIndex idx) const {
+ const dex::TypeId& GetTypeId(dex::TypeIndex idx) const {
DCHECK_LT(idx.index_, NumTypeIds()) << GetLocation();
return type_ids_[idx.index_];
}
- dex::TypeIndex GetIndexForTypeId(const TypeId& type_id) const {
+ dex::TypeIndex GetIndexForTypeId(const dex::TypeId& type_id) const {
CHECK_GE(&type_id, type_ids_) << GetLocation();
CHECK_LT(&type_id, type_ids_ + header_->type_ids_size_) << GetLocation();
size_t result = &type_id - type_ids_;
@@ -556,10 +297,10 @@ class DexFile {
const char* StringByTypeIdx(dex::TypeIndex idx) const;
// Returns the type descriptor string of a type id.
- const char* GetTypeDescriptor(const TypeId& type_id) const;
+ const char* GetTypeDescriptor(const dex::TypeId& type_id) const;
// Looks up a type for the given string index
- const TypeId* FindTypeId(dex::StringIndex string_idx) const;
+ const dex::TypeId* FindTypeId(dex::StringIndex string_idx) const;
// Returns the number of field identifiers in the .dex file.
size_t NumFieldIds() const {
@@ -568,38 +309,38 @@ class DexFile {
}
// Returns the FieldId at the specified index.
- const FieldId& GetFieldId(uint32_t idx) const {
+ const dex::FieldId& GetFieldId(uint32_t idx) const {
DCHECK_LT(idx, NumFieldIds()) << GetLocation();
return field_ids_[idx];
}
- uint32_t GetIndexForFieldId(const FieldId& field_id) const {
+ uint32_t GetIndexForFieldId(const dex::FieldId& field_id) const {
CHECK_GE(&field_id, field_ids_) << GetLocation();
CHECK_LT(&field_id, field_ids_ + header_->field_ids_size_) << GetLocation();
return &field_id - field_ids_;
}
// Looks up a field by its declaring class, name and type
- const FieldId* FindFieldId(const DexFile::TypeId& declaring_klass,
- const DexFile::StringId& name,
- const DexFile::TypeId& type) const;
+ const dex::FieldId* FindFieldId(const dex::TypeId& declaring_klass,
+ const dex::StringId& name,
+ const dex::TypeId& type) const;
- uint32_t FindCodeItemOffset(const DexFile::ClassDef& class_def,
+ uint32_t FindCodeItemOffset(const dex::ClassDef& class_def,
uint32_t dex_method_idx) const;
- virtual uint32_t GetCodeItemSize(const DexFile::CodeItem& disk_code_item) const = 0;
+ virtual uint32_t GetCodeItemSize(const dex::CodeItem& disk_code_item) const = 0;
// Returns the declaring class descriptor string of a field id.
- const char* GetFieldDeclaringClassDescriptor(const FieldId& field_id) const {
- const DexFile::TypeId& type_id = GetTypeId(field_id.class_idx_);
+ const char* GetFieldDeclaringClassDescriptor(const dex::FieldId& field_id) const {
+ const dex::TypeId& type_id = GetTypeId(field_id.class_idx_);
return GetTypeDescriptor(type_id);
}
// Returns the class descriptor string of a field id.
- const char* GetFieldTypeDescriptor(const FieldId& field_id) const;
+ const char* GetFieldTypeDescriptor(const dex::FieldId& field_id) const;
// Returns the name of a field id.
- const char* GetFieldName(const FieldId& field_id) const;
+ const char* GetFieldName(const dex::FieldId& field_id) const;
// Returns the number of method identifiers in the .dex file.
size_t NumMethodIds() const {
@@ -608,47 +349,47 @@ class DexFile {
}
// Returns the MethodId at the specified index.
- const MethodId& GetMethodId(uint32_t idx) const {
+ const dex::MethodId& GetMethodId(uint32_t idx) const {
DCHECK_LT(idx, NumMethodIds()) << GetLocation();
return method_ids_[idx];
}
- uint32_t GetIndexForMethodId(const MethodId& method_id) const {
+ uint32_t GetIndexForMethodId(const dex::MethodId& method_id) const {
CHECK_GE(&method_id, method_ids_) << GetLocation();
CHECK_LT(&method_id, method_ids_ + header_->method_ids_size_) << GetLocation();
return &method_id - method_ids_;
}
// Looks up a method by its declaring class, name and proto_id
- const MethodId* FindMethodId(const DexFile::TypeId& declaring_klass,
- const DexFile::StringId& name,
- const DexFile::ProtoId& signature) const;
+ const dex::MethodId* FindMethodId(const dex::TypeId& declaring_klass,
+ const dex::StringId& name,
+ const dex::ProtoId& signature) const;
// Returns the declaring class descriptor string of a method id.
- const char* GetMethodDeclaringClassDescriptor(const MethodId& method_id) const;
+ const char* GetMethodDeclaringClassDescriptor(const dex::MethodId& method_id) const;
// Returns the prototype of a method id.
- const ProtoId& GetMethodPrototype(const MethodId& method_id) const {
+ const dex::ProtoId& GetMethodPrototype(const dex::MethodId& method_id) const {
return GetProtoId(method_id.proto_idx_);
}
// Returns a representation of the signature of a method id.
- const Signature GetMethodSignature(const MethodId& method_id) const;
+ const Signature GetMethodSignature(const dex::MethodId& method_id) const;
// Returns a representation of the signature of a proto id.
- const Signature GetProtoSignature(const ProtoId& proto_id) const;
+ const Signature GetProtoSignature(const dex::ProtoId& proto_id) const;
// Returns the name of a method id.
- const char* GetMethodName(const MethodId& method_id) const;
- const char* GetMethodName(const MethodId& method_id, uint32_t* utf_length) const;
+ const char* GetMethodName(const dex::MethodId& method_id) const;
+ const char* GetMethodName(const dex::MethodId& method_id, uint32_t* utf_length) const;
const char* GetMethodName(uint32_t idx, uint32_t* utf_length) const;
// Returns the shorty of a method by its index.
const char* GetMethodShorty(uint32_t idx) const;
// Returns the shorty of a method id.
- const char* GetMethodShorty(const MethodId& method_id) const;
- const char* GetMethodShorty(const MethodId& method_id, uint32_t* length) const;
+ const char* GetMethodShorty(const dex::MethodId& method_id) const;
+ const char* GetMethodShorty(const dex::MethodId& method_id, uint32_t* length) const;
// Returns the number of class definitions in the .dex file.
uint32_t NumClassDefs() const {
@@ -657,32 +398,32 @@ class DexFile {
}
// Returns the ClassDef at the specified index.
- const ClassDef& GetClassDef(uint16_t idx) const {
+ const dex::ClassDef& GetClassDef(uint16_t idx) const {
DCHECK_LT(idx, NumClassDefs()) << GetLocation();
return class_defs_[idx];
}
- uint16_t GetIndexForClassDef(const ClassDef& class_def) const {
+ uint16_t GetIndexForClassDef(const dex::ClassDef& class_def) const {
CHECK_GE(&class_def, class_defs_) << GetLocation();
CHECK_LT(&class_def, class_defs_ + header_->class_defs_size_) << GetLocation();
return &class_def - class_defs_;
}
// Returns the class descriptor string of a class definition.
- const char* GetClassDescriptor(const ClassDef& class_def) const;
+ const char* GetClassDescriptor(const dex::ClassDef& class_def) const;
// Looks up a class definition by its type index.
- const ClassDef* FindClassDef(dex::TypeIndex type_idx) const;
+ const dex::ClassDef* FindClassDef(dex::TypeIndex type_idx) const;
- const TypeList* GetInterfacesList(const ClassDef& class_def) const {
- return DataPointer<TypeList>(class_def.interfaces_off_);
+ const dex::TypeList* GetInterfacesList(const dex::ClassDef& class_def) const {
+ return DataPointer<dex::TypeList>(class_def.interfaces_off_);
}
uint32_t NumMethodHandles() const {
return num_method_handles_;
}
- const MethodHandleItem& GetMethodHandle(uint32_t idx) const {
+ const dex::MethodHandleItem& GetMethodHandle(uint32_t idx) const {
CHECK_LT(idx, NumMethodHandles());
return method_handles_[idx];
}
@@ -691,23 +432,23 @@ class DexFile {
return num_call_site_ids_;
}
- const CallSiteIdItem& GetCallSiteId(uint32_t idx) const {
+ const dex::CallSiteIdItem& GetCallSiteId(uint32_t idx) const {
CHECK_LT(idx, NumCallSiteIds());
return call_site_ids_[idx];
}
// Returns a pointer to the raw memory mapped class_data_item
- const uint8_t* GetClassData(const ClassDef& class_def) const {
+ const uint8_t* GetClassData(const dex::ClassDef& class_def) const {
return DataPointer<uint8_t>(class_def.class_data_off_);
}
// Return the code item for a provided offset.
- const CodeItem* GetCodeItem(const uint32_t code_off) const {
+ const dex::CodeItem* GetCodeItem(const uint32_t code_off) const {
// May be null for native or abstract methods.
- return DataPointer<CodeItem>(code_off);
+ return DataPointer<dex::CodeItem>(code_off);
}
- const char* GetReturnTypeDescriptor(const ProtoId& proto_id) const;
+ const char* GetReturnTypeDescriptor(const dex::ProtoId& proto_id) const;
// Returns the number of prototype identifiers in the .dex file.
size_t NumProtoIds() const {
@@ -716,23 +457,23 @@ class DexFile {
}
// Returns the ProtoId at the specified index.
- const ProtoId& GetProtoId(dex::ProtoIndex idx) const {
+ const dex::ProtoId& GetProtoId(dex::ProtoIndex idx) const {
DCHECK_LT(idx.index_, NumProtoIds()) << GetLocation();
return proto_ids_[idx.index_];
}
- dex::ProtoIndex GetIndexForProtoId(const ProtoId& proto_id) const {
+ dex::ProtoIndex GetIndexForProtoId(const dex::ProtoId& proto_id) const {
CHECK_GE(&proto_id, proto_ids_) << GetLocation();
CHECK_LT(&proto_id, proto_ids_ + header_->proto_ids_size_) << GetLocation();
return dex::ProtoIndex(&proto_id - proto_ids_);
}
// Looks up a proto id for a given return type and signature type list
- const ProtoId* FindProtoId(dex::TypeIndex return_type_idx,
- const dex::TypeIndex* signature_type_idxs,
+ const dex::ProtoId* FindProtoId(dex::TypeIndex return_type_idx,
+ const dex::TypeIndex* signature_type_idxs,
uint32_t signature_length) const;
- const ProtoId* FindProtoId(dex::TypeIndex return_type_idx,
- const std::vector<dex::TypeIndex>& signature_type_idxs) const {
+ const dex::ProtoId* FindProtoId(dex::TypeIndex return_type_idx,
+ const std::vector<dex::TypeIndex>& signature_type_idxs) const {
return FindProtoId(return_type_idx, &signature_type_idxs[0], signature_type_idxs.size());
}
@@ -748,21 +489,22 @@ class DexFile {
// Returns the short form method descriptor for the given prototype.
const char* GetShorty(dex::ProtoIndex proto_idx) const;
- const TypeList* GetProtoParameters(const ProtoId& proto_id) const {
- return DataPointer<TypeList>(proto_id.parameters_off_);
+ const dex::TypeList* GetProtoParameters(const dex::ProtoId& proto_id) const {
+ return DataPointer<dex::TypeList>(proto_id.parameters_off_);
}
- const uint8_t* GetEncodedStaticFieldValuesArray(const ClassDef& class_def) const {
+ const uint8_t* GetEncodedStaticFieldValuesArray(const dex::ClassDef& class_def) const {
return DataPointer<uint8_t>(class_def.static_values_off_);
}
- const uint8_t* GetCallSiteEncodedValuesArray(const CallSiteIdItem& call_site_id) const {
+ const uint8_t* GetCallSiteEncodedValuesArray(const dex::CallSiteIdItem& call_site_id) const {
return DataBegin() + call_site_id.data_off_;
}
dex::ProtoIndex GetProtoIndexForCallSite(uint32_t call_site_idx) const;
- static const TryItem* GetTryItems(const DexInstructionIterator& code_item_end, uint32_t offset);
+ static const dex::TryItem* GetTryItems(const DexInstructionIterator& code_item_end,
+ uint32_t offset);
// Get the base of the encoded data for the given DexCode.
static const uint8_t* GetCatchHandlerData(const DexInstructionIterator& code_item_end,
@@ -770,7 +512,7 @@ class DexFile {
uint32_t offset);
// Find which try region is associated with the given address (ie dex pc). Returns -1 if none.
- static int32_t FindTryItem(const TryItem* try_items, uint32_t tries_size, uint32_t address);
+ static int32_t FindTryItem(const dex::TryItem* try_items, uint32_t tries_size, uint32_t address);
// Get the pointer to the start of the debugging data
const uint8_t* GetDebugInfoStream(uint32_t debug_info_off) const {
@@ -807,76 +549,83 @@ class DexFile {
// Callback for "new locals table entry".
typedef void (*DexDebugNewLocalCb)(void* context, const LocalInfo& entry);
- const AnnotationsDirectoryItem* GetAnnotationsDirectory(const ClassDef& class_def) const {
- return DataPointer<AnnotationsDirectoryItem>(class_def.annotations_off_);
+ const dex::AnnotationsDirectoryItem* GetAnnotationsDirectory(const dex::ClassDef& class_def)
+ const {
+ return DataPointer<dex::AnnotationsDirectoryItem>(class_def.annotations_off_);
}
- const AnnotationSetItem* GetClassAnnotationSet(const AnnotationsDirectoryItem* anno_dir) const {
- return DataPointer<AnnotationSetItem>(anno_dir->class_annotations_off_);
+ const dex::AnnotationSetItem* GetClassAnnotationSet(const dex::AnnotationsDirectoryItem* anno_dir)
+ const {
+ return DataPointer<dex::AnnotationSetItem>(anno_dir->class_annotations_off_);
}
- const FieldAnnotationsItem* GetFieldAnnotations(const AnnotationsDirectoryItem* anno_dir) const {
+ const dex::FieldAnnotationsItem* GetFieldAnnotations(
+ const dex::AnnotationsDirectoryItem* anno_dir) const {
return (anno_dir->fields_size_ == 0)
? nullptr
- : reinterpret_cast<const FieldAnnotationsItem*>(&anno_dir[1]);
+ : reinterpret_cast<const dex::FieldAnnotationsItem*>(&anno_dir[1]);
}
- const MethodAnnotationsItem* GetMethodAnnotations(const AnnotationsDirectoryItem* anno_dir)
- const {
+ const dex::MethodAnnotationsItem* GetMethodAnnotations(
+ const dex::AnnotationsDirectoryItem* anno_dir) const {
if (anno_dir->methods_size_ == 0) {
return nullptr;
}
// Skip past the header and field annotations.
const uint8_t* addr = reinterpret_cast<const uint8_t*>(&anno_dir[1]);
- addr += anno_dir->fields_size_ * sizeof(FieldAnnotationsItem);
- return reinterpret_cast<const MethodAnnotationsItem*>(addr);
+ addr += anno_dir->fields_size_ * sizeof(dex::FieldAnnotationsItem);
+ return reinterpret_cast<const dex::MethodAnnotationsItem*>(addr);
}
- const ParameterAnnotationsItem* GetParameterAnnotations(const AnnotationsDirectoryItem* anno_dir)
- const {
+ const dex::ParameterAnnotationsItem* GetParameterAnnotations(
+ const dex::AnnotationsDirectoryItem* anno_dir) const {
if (anno_dir->parameters_size_ == 0) {
return nullptr;
}
// Skip past the header, field annotations, and method annotations.
const uint8_t* addr = reinterpret_cast<const uint8_t*>(&anno_dir[1]);
- addr += anno_dir->fields_size_ * sizeof(FieldAnnotationsItem);
- addr += anno_dir->methods_size_ * sizeof(MethodAnnotationsItem);
- return reinterpret_cast<const ParameterAnnotationsItem*>(addr);
+ addr += anno_dir->fields_size_ * sizeof(dex::FieldAnnotationsItem);
+ addr += anno_dir->methods_size_ * sizeof(dex::MethodAnnotationsItem);
+ return reinterpret_cast<const dex::ParameterAnnotationsItem*>(addr);
}
- const AnnotationSetItem* GetFieldAnnotationSetItem(const FieldAnnotationsItem& anno_item) const {
- return DataPointer<AnnotationSetItem>(anno_item.annotations_off_);
+ const dex::AnnotationSetItem* GetFieldAnnotationSetItem(
+ const dex::FieldAnnotationsItem& anno_item) const {
+ return DataPointer<dex::AnnotationSetItem>(anno_item.annotations_off_);
}
- const AnnotationSetItem* GetMethodAnnotationSetItem(const MethodAnnotationsItem& anno_item)
- const {
- return DataPointer<AnnotationSetItem>(anno_item.annotations_off_);
+ const dex::AnnotationSetItem* GetMethodAnnotationSetItem(
+ const dex::MethodAnnotationsItem& anno_item) const {
+ return DataPointer<dex::AnnotationSetItem>(anno_item.annotations_off_);
}
- const AnnotationSetRefList* GetParameterAnnotationSetRefList(
- const ParameterAnnotationsItem* anno_item) const {
- return DataPointer<AnnotationSetRefList>(anno_item->annotations_off_);
+ const dex::AnnotationSetRefList* GetParameterAnnotationSetRefList(
+ const dex::ParameterAnnotationsItem* anno_item) const {
+ return DataPointer<dex::AnnotationSetRefList>(anno_item->annotations_off_);
}
- ALWAYS_INLINE const AnnotationItem* GetAnnotationItemAtOffset(uint32_t offset) const {
- return DataPointer<AnnotationItem>(offset);
+ ALWAYS_INLINE const dex::AnnotationItem* GetAnnotationItemAtOffset(uint32_t offset) const {
+ return DataPointer<dex::AnnotationItem>(offset);
}
- ALWAYS_INLINE const HiddenapiClassData* GetHiddenapiClassDataAtOffset(uint32_t offset) const {
- return DataPointer<HiddenapiClassData>(offset);
+ ALWAYS_INLINE const dex::HiddenapiClassData* GetHiddenapiClassDataAtOffset(uint32_t offset)
+ const {
+ return DataPointer<dex::HiddenapiClassData>(offset);
}
- ALWAYS_INLINE const HiddenapiClassData* GetHiddenapiClassData() const {
+ ALWAYS_INLINE const dex::HiddenapiClassData* GetHiddenapiClassData() const {
return hiddenapi_class_data_;
}
- const AnnotationItem* GetAnnotationItem(const AnnotationSetItem* set_item, uint32_t index) const {
+ const dex::AnnotationItem* GetAnnotationItem(const dex::AnnotationSetItem* set_item,
+ uint32_t index) const {
DCHECK_LE(index, set_item->size_);
return GetAnnotationItemAtOffset(set_item->entries_[index]);
}
- const AnnotationSetItem* GetSetRefItemItem(const AnnotationSetRefItem* anno_item) const {
- return DataPointer<AnnotationSetItem>(anno_item->annotations_off_);
+ const dex::AnnotationSetItem* GetSetRefItemItem(const dex::AnnotationSetRefItem* anno_item)
+ const {
+ return DataPointer<dex::AnnotationSetItem>(anno_item->annotations_off_);
}
// Debug info opcodes and constants
@@ -925,7 +674,7 @@ class DexFile {
const IndexToStringData& index_to_string_data,
const DexDebugNewPosition& position_functor);
- const char* GetSourceFile(const ClassDef& class_def) const {
+ const char* GetSourceFile(const dex::ClassDef& class_def) const {
if (!class_def.source_file_idx_.IsValid()) {
return nullptr;
} else {
@@ -973,8 +722,8 @@ class DexFile {
}
// Read MapItems and validate/set remaining offsets.
- const DexFile::MapList* GetMapList() const {
- return reinterpret_cast<const DexFile::MapList*>(DataBegin() + header_->map_off_);
+ const dex::MapList* GetMapList() const {
+ return reinterpret_cast<const dex::MapList*>(DataBegin() + header_->map_off_);
}
// Utility methods for reading integral values from a buffer.
@@ -1078,38 +827,38 @@ class DexFile {
const Header* const header_;
// Points to the base of the string identifier list.
- const StringId* const string_ids_;
+ const dex::StringId* const string_ids_;
// Points to the base of the type identifier list.
- const TypeId* const type_ids_;
+ const dex::TypeId* const type_ids_;
// Points to the base of the field identifier list.
- const FieldId* const field_ids_;
+ const dex::FieldId* const field_ids_;
// Points to the base of the method identifier list.
- const MethodId* const method_ids_;
+ const dex::MethodId* const method_ids_;
// Points to the base of the prototype identifier list.
- const ProtoId* const proto_ids_;
+ const dex::ProtoId* const proto_ids_;
// Points to the base of the class definition list.
- const ClassDef* const class_defs_;
+ const dex::ClassDef* const class_defs_;
// Points to the base of the method handles list.
- const MethodHandleItem* method_handles_;
+ const dex::MethodHandleItem* method_handles_;
// Number of elements in the method handles list.
size_t num_method_handles_;
// Points to the base of the call sites id list.
- const CallSiteIdItem* call_site_ids_;
+ const dex::CallSiteIdItem* call_site_ids_;
// Number of elements in the call sites list.
size_t num_call_site_ids_;
// Points to the base of the hiddenapi class data item_, or nullptr if the dex
// file does not have one.
- const HiddenapiClassData* hiddenapi_class_data_;
+ const dex::HiddenapiClassData* hiddenapi_class_data_;
// If this dex file was loaded from an oat file, oat_dex_file_ contains a
// pointer to the OatDexFile it was loaded from. Otherwise oat_dex_file_ is
@@ -1135,7 +884,7 @@ std::ostream& operator<<(std::ostream& os, const DexFile& dex_file);
// Iterate over a dex file's ProtoId's paramters
class DexFileParameterIterator {
public:
- DexFileParameterIterator(const DexFile& dex_file, const DexFile::ProtoId& proto_id)
+ DexFileParameterIterator(const DexFile& dex_file, const dex::ProtoId& proto_id)
: dex_file_(dex_file) {
type_list_ = dex_file_.GetProtoParameters(proto_id);
if (type_list_ != nullptr) {
@@ -1153,7 +902,7 @@ class DexFileParameterIterator {
}
private:
const DexFile& dex_file_;
- const DexFile::TypeList* type_list_ = nullptr;
+ const dex::TypeList* type_list_ = nullptr;
uint32_t size_ = 0;
uint32_t pos_ = 0;
DISALLOW_IMPLICIT_CONSTRUCTORS(DexFileParameterIterator);
@@ -1179,7 +928,7 @@ class Signature : public ValueObject {
bool operator==(const StringPiece& rhs) const;
private:
- Signature(const DexFile* dex, const DexFile::ProtoId& proto) : dex_file_(dex), proto_id_(&proto) {
+ Signature(const DexFile* dex, const dex::ProtoId& proto) : dex_file_(dex), proto_id_(&proto) {
}
Signature() = default;
@@ -1187,7 +936,7 @@ class Signature : public ValueObject {
friend class DexFile;
const DexFile* const dex_file_ = nullptr;
- const DexFile::ProtoId* const proto_id_ = nullptr;
+ const dex::ProtoId* const proto_id_ = nullptr;
};
std::ostream& operator<<(std::ostream& os, const Signature& sig);
@@ -1242,7 +991,7 @@ std::ostream& operator<<(std::ostream& os, const EncodedArrayValueIterator::Valu
class EncodedStaticFieldValueIterator : public EncodedArrayValueIterator {
public:
EncodedStaticFieldValueIterator(const DexFile& dex_file,
- const DexFile::ClassDef& class_def)
+ const dex::ClassDef& class_def)
: EncodedArrayValueIterator(dex_file,
dex_file.GetEncodedStaticFieldValuesArray(class_def))
{}
@@ -1255,7 +1004,7 @@ std::ostream& operator<<(std::ostream& os, const EncodedStaticFieldValueIterator
class CallSiteArrayValueIterator : public EncodedArrayValueIterator {
public:
CallSiteArrayValueIterator(const DexFile& dex_file,
- const DexFile::CallSiteIdItem& call_site_id)
+ const dex::CallSiteIdItem& call_site_id)
: EncodedArrayValueIterator(dex_file,
dex_file.GetCallSiteEncodedValuesArray(call_site_id))
{}
diff --git a/libdexfile/dex/dex_file_exception_helpers.cc b/libdexfile/dex/dex_file_exception_helpers.cc
index 8e597fd3dd..72b2554d7f 100644
--- a/libdexfile/dex/dex_file_exception_helpers.cc
+++ b/libdexfile/dex/dex_file_exception_helpers.cc
@@ -17,6 +17,7 @@
#include "dex_file_exception_helpers.h"
#include "code_item_accessors-inl.h"
+#include "dex_file_structs.h"
namespace art {
@@ -29,7 +30,7 @@ CatchHandlerIterator::CatchHandlerIterator(const CodeItemDataAccessor& accessor,
case 0:
break;
case 1: {
- const DexFile::TryItem* tries = accessor.TryItems().begin();
+ const dex::TryItem* tries = accessor.TryItems().begin();
uint32_t start = tries->start_addr_;
if (address >= start) {
uint32_t end = start + tries->insn_count_;
@@ -40,7 +41,7 @@ CatchHandlerIterator::CatchHandlerIterator(const CodeItemDataAccessor& accessor,
break;
}
default: {
- const DexFile::TryItem* try_item = accessor.FindTryItem(address);
+ const dex::TryItem* try_item = accessor.FindTryItem(address);
offset = try_item != nullptr ? try_item->handler_off_ : -1;
break;
}
@@ -49,7 +50,7 @@ CatchHandlerIterator::CatchHandlerIterator(const CodeItemDataAccessor& accessor,
}
CatchHandlerIterator::CatchHandlerIterator(const CodeItemDataAccessor& accessor,
- const DexFile::TryItem& try_item) {
+ const dex::TryItem& try_item) {
handler_.address_ = -1;
Init(accessor, try_item.handler_off_);
}
diff --git a/libdexfile/dex/dex_file_exception_helpers.h b/libdexfile/dex/dex_file_exception_helpers.h
index a05fd68e86..08127c865d 100644
--- a/libdexfile/dex/dex_file_exception_helpers.h
+++ b/libdexfile/dex/dex_file_exception_helpers.h
@@ -17,17 +17,23 @@
#ifndef ART_LIBDEXFILE_DEX_DEX_FILE_EXCEPTION_HELPERS_H_
#define ART_LIBDEXFILE_DEX_DEX_FILE_EXCEPTION_HELPERS_H_
-#include "dex_file.h"
+#include <android-base/logging.h>
+
+#include "dex_file_types.h"
namespace art {
+namespace dex {
+struct TryItem;
+} // namespace dex
+
class CodeItemDataAccessor;
class CatchHandlerIterator {
public:
CatchHandlerIterator(const CodeItemDataAccessor& accessor, uint32_t address);
- CatchHandlerIterator(const CodeItemDataAccessor& accessor, const DexFile::TryItem& try_item);
+ CatchHandlerIterator(const CodeItemDataAccessor& accessor, const dex::TryItem& try_item);
explicit CatchHandlerIterator(const uint8_t* handler_data) {
Init(handler_data);
diff --git a/libdexfile/dex/dex_file_loader_test.cc b/libdexfile/dex/dex_file_loader_test.cc
index 9c61d1ac5f..8b7ca1776f 100644
--- a/libdexfile/dex/dex_file_loader_test.cc
+++ b/libdexfile/dex/dex_file_loader_test.cc
@@ -487,10 +487,9 @@ TEST_F(DexFileLoaderTest, OpenDexDebugInfoLocalNullType) {
0xf25f2b38U,
true,
&dex_bytes);
- const DexFile::ClassDef& class_def = raw->GetClassDef(0);
+ const dex::ClassDef& class_def = raw->GetClassDef(0);
constexpr uint32_t kMethodIdx = 1;
- const DexFile::CodeItem* code_item = raw->GetCodeItem(raw->FindCodeItemOffset(class_def,
- kMethodIdx));
+ const dex::CodeItem* code_item = raw->GetCodeItem(raw->FindCodeItemOffset(class_def, kMethodIdx));
CodeItemDebugInfoAccessor accessor(*raw, code_item, kMethodIdx);
ASSERT_TRUE(accessor.DecodeDebugLocalInfo(true, 1, VoidFunctor()));
}
diff --git a/libdexfile/dex/dex_file_structs.h b/libdexfile/dex/dex_file_structs.h
new file mode 100644
index 0000000000..2d252270f3
--- /dev/null
+++ b/libdexfile/dex/dex_file_structs.h
@@ -0,0 +1,298 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ART_LIBDEXFILE_DEX_DEX_FILE_STRUCTS_H_
+#define ART_LIBDEXFILE_DEX_DEX_FILE_STRUCTS_H_
+
+#include <android-base/logging.h>
+#include <android-base/macros.h>
+
+#include <inttypes.h>
+
+#include "dex_file_types.h"
+#include "modifiers.h"
+
+namespace art {
+
+class DexWriter;
+
+namespace dex {
+
+struct MapItem {
+ uint16_t type_;
+ uint16_t unused_;
+ uint32_t size_;
+ uint32_t offset_;
+};
+
+struct MapList {
+ uint32_t size_;
+ MapItem list_[1];
+
+ size_t Size() const { return sizeof(uint32_t) + (size_ * sizeof(MapItem)); }
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(MapList);
+};
+
+// Raw string_id_item.
+struct StringId {
+ uint32_t string_data_off_; // offset in bytes from the base address
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(StringId);
+};
+
+// Raw type_id_item.
+struct TypeId {
+ dex::StringIndex descriptor_idx_; // index into string_ids
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(TypeId);
+};
+
+// Raw field_id_item.
+struct FieldId {
+ dex::TypeIndex class_idx_; // index into type_ids_ array for defining class
+ dex::TypeIndex type_idx_; // index into type_ids_ array for field type
+ dex::StringIndex name_idx_; // index into string_ids_ array for field name
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(FieldId);
+};
+
+// Raw proto_id_item.
+struct ProtoId {
+ dex::StringIndex shorty_idx_; // index into string_ids array for shorty descriptor
+ dex::TypeIndex return_type_idx_; // index into type_ids array for return type
+ uint16_t pad_; // padding = 0
+ uint32_t parameters_off_; // file offset to type_list for parameter types
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(ProtoId);
+};
+
+// Raw method_id_item.
+struct MethodId {
+ dex::TypeIndex class_idx_; // index into type_ids_ array for defining class
+ dex::ProtoIndex proto_idx_; // index into proto_ids_ array for method prototype
+ dex::StringIndex name_idx_; // index into string_ids_ array for method name
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(MethodId);
+};
+
+// Base code_item, compact dex and standard dex have different code item layouts.
+struct CodeItem {
+ protected:
+ CodeItem() = default;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(CodeItem);
+};
+
+// Raw class_def_item.
+struct ClassDef {
+ dex::TypeIndex class_idx_; // index into type_ids_ array for this class
+ uint16_t pad1_; // padding = 0
+ uint32_t access_flags_;
+ dex::TypeIndex superclass_idx_; // index into type_ids_ array for superclass
+ uint16_t pad2_; // padding = 0
+ uint32_t interfaces_off_; // file offset to TypeList
+ dex::StringIndex source_file_idx_; // index into string_ids_ for source file name
+ uint32_t annotations_off_; // file offset to annotations_directory_item
+ uint32_t class_data_off_; // file offset to class_data_item
+ uint32_t static_values_off_; // file offset to EncodedArray
+
+ // Returns the valid access flags, that is, Java modifier bits relevant to the ClassDef type
+ // (class or interface). These are all in the lower 16b and do not contain runtime flags.
+ uint32_t GetJavaAccessFlags() const {
+ // Make sure that none of our runtime-only flags are set.
+ static_assert((kAccValidClassFlags & kAccJavaFlagsMask) == kAccValidClassFlags,
+ "Valid class flags not a subset of Java flags");
+ static_assert((kAccValidInterfaceFlags & kAccJavaFlagsMask) == kAccValidInterfaceFlags,
+ "Valid interface flags not a subset of Java flags");
+
+ if ((access_flags_ & kAccInterface) != 0) {
+ // Interface.
+ return access_flags_ & kAccValidInterfaceFlags;
+ } else {
+ // Class.
+ return access_flags_ & kAccValidClassFlags;
+ }
+ }
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(ClassDef);
+};
+
+// Raw type_item.
+struct TypeItem {
+ dex::TypeIndex type_idx_; // index into type_ids section
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(TypeItem);
+};
+
+// Raw type_list.
+class TypeList {
+ public:
+ uint32_t Size() const {
+ return size_;
+ }
+
+ const TypeItem& GetTypeItem(uint32_t idx) const {
+ DCHECK_LT(idx, this->size_);
+ return this->list_[idx];
+ }
+
+ // Size in bytes of the part of the list that is common.
+ static constexpr size_t GetHeaderSize() {
+ return 4U;
+ }
+
+ // Size in bytes of the whole type list including all the stored elements.
+ static constexpr size_t GetListSize(size_t count) {
+ return GetHeaderSize() + sizeof(TypeItem) * count;
+ }
+
+ private:
+ uint32_t size_; // size of the list, in entries
+ TypeItem list_[1]; // elements of the list
+ DISALLOW_COPY_AND_ASSIGN(TypeList);
+};
+
+// raw method_handle_item
+struct MethodHandleItem {
+ uint16_t method_handle_type_;
+ uint16_t reserved1_; // Reserved for future use.
+ uint16_t field_or_method_idx_; // Field index for accessors, method index otherwise.
+ uint16_t reserved2_; // Reserved for future use.
+ private:
+ DISALLOW_COPY_AND_ASSIGN(MethodHandleItem);
+};
+
+// raw call_site_id_item
+struct CallSiteIdItem {
+ uint32_t data_off_; // Offset into data section pointing to encoded array items.
+ private:
+ DISALLOW_COPY_AND_ASSIGN(CallSiteIdItem);
+};
+
+// Raw try_item.
+struct TryItem {
+ static constexpr size_t kAlignment = sizeof(uint32_t);
+
+ uint32_t start_addr_;
+ uint16_t insn_count_;
+ uint16_t handler_off_;
+
+ private:
+ TryItem() = default;
+ friend class ::art::DexWriter;
+ DISALLOW_COPY_AND_ASSIGN(TryItem);
+};
+
+struct AnnotationsDirectoryItem {
+ uint32_t class_annotations_off_;
+ uint32_t fields_size_;
+ uint32_t methods_size_;
+ uint32_t parameters_size_;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(AnnotationsDirectoryItem);
+};
+
+struct FieldAnnotationsItem {
+ uint32_t field_idx_;
+ uint32_t annotations_off_;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(FieldAnnotationsItem);
+};
+
+struct MethodAnnotationsItem {
+ uint32_t method_idx_;
+ uint32_t annotations_off_;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(MethodAnnotationsItem);
+};
+
+struct ParameterAnnotationsItem {
+ uint32_t method_idx_;
+ uint32_t annotations_off_;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(ParameterAnnotationsItem);
+};
+
+struct AnnotationSetRefItem {
+ uint32_t annotations_off_;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(AnnotationSetRefItem);
+};
+
+struct AnnotationSetRefList {
+ uint32_t size_;
+ AnnotationSetRefItem list_[1];
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(AnnotationSetRefList);
+};
+
+struct AnnotationSetItem {
+ uint32_t size_;
+ uint32_t entries_[1];
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(AnnotationSetItem);
+};
+
+struct AnnotationItem {
+ uint8_t visibility_;
+ uint8_t annotation_[1];
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(AnnotationItem);
+};
+
+struct HiddenapiClassData {
+ uint32_t size_; // total size of the item
+ uint32_t flags_offset_[1]; // array of offsets from the beginning of this item,
+ // indexed by class def index
+
+ // Returns a pointer to the beginning of a uleb128-stream of hiddenapi
+ // flags for a class def of given index. Values are in the same order
+ // as fields/methods in the class data. Returns null if the class does
+ // not have class data.
+ const uint8_t* GetFlagsPointer(uint32_t class_def_idx) const {
+ if (flags_offset_[class_def_idx] == 0) {
+ return nullptr;
+ } else {
+ return reinterpret_cast<const uint8_t*>(this) + flags_offset_[class_def_idx];
+ }
+ }
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(HiddenapiClassData);
+};
+
+} // namespace dex
+} // namespace art
+
+#endif // ART_LIBDEXFILE_DEX_DEX_FILE_STRUCTS_H_
diff --git a/libdexfile/dex/dex_file_tracking_registrar.cc b/libdexfile/dex/dex_file_tracking_registrar.cc
index 29ff6be4fc..1903dc946f 100644
--- a/libdexfile/dex/dex_file_tracking_registrar.cc
+++ b/libdexfile/dex/dex_file_tracking_registrar.cc
@@ -158,7 +158,7 @@ void DexFileTrackingRegistrar::SetDexFileRegistration(bool should_poison) {
void DexFileTrackingRegistrar::SetAllCodeItemRegistration(bool should_poison) {
for (ClassAccessor accessor : dex_file_->GetClasses()) {
for (const ClassAccessor::Method& method : accessor.GetMethods()) {
- const DexFile::CodeItem* code_item = method.GetCodeItem();
+ const dex::CodeItem* code_item = method.GetCodeItem();
if (code_item != nullptr) {
const void* code_item_begin = reinterpret_cast<const void*>(code_item);
size_t code_item_size = dex_file_->GetCodeItemSize(*code_item);
@@ -171,7 +171,7 @@ void DexFileTrackingRegistrar::SetAllCodeItemRegistration(bool should_poison) {
void DexFileTrackingRegistrar::SetAllCodeItemStartRegistration(bool should_poison) {
for (ClassAccessor class_accessor : dex_file_->GetClasses()) {
for (const ClassAccessor::Method& method : class_accessor.GetMethods()) {
- const DexFile::CodeItem* code_item = method.GetCodeItem();
+ const dex::CodeItem* code_item = method.GetCodeItem();
if (code_item != nullptr) {
const void* code_item_begin = reinterpret_cast<const void*>(code_item);
size_t code_item_start = reinterpret_cast<size_t>(code_item);
@@ -189,7 +189,7 @@ void DexFileTrackingRegistrar::SetAllCodeItemStartRegistration(bool should_poiso
void DexFileTrackingRegistrar::SetAllInsnsRegistration(bool should_poison) {
for (ClassAccessor class_accessor : dex_file_->GetClasses()) {
for (const ClassAccessor::Method& method : class_accessor.GetMethods()) {
- const DexFile::CodeItem* code_item = method.GetCodeItem();
+ const dex::CodeItem* code_item = method.GetCodeItem();
if (code_item != nullptr) {
CodeItemInstructionAccessor accessor(*dex_file_, code_item);
const void* insns_begin = reinterpret_cast<const void*>(accessor.Insns());
@@ -204,9 +204,9 @@ void DexFileTrackingRegistrar::SetAllInsnsRegistration(bool should_poison) {
void DexFileTrackingRegistrar::SetCodeItemRegistration(const char* class_name, bool should_poison) {
for (ClassAccessor accessor : dex_file_->GetClasses()) {
for (const ClassAccessor::Method& method : accessor.GetMethods()) {
- const DexFile::MethodId& methodid_item = dex_file_->GetMethodId(method.GetIndex());
+ const dex::MethodId& methodid_item = dex_file_->GetMethodId(method.GetIndex());
const char * methodid_name = dex_file_->GetMethodName(methodid_item);
- const DexFile::CodeItem* code_item = method.GetCodeItem();
+ const dex::CodeItem* code_item = method.GetCodeItem();
if (code_item != nullptr && strcmp(methodid_name, class_name) == 0) {
const void* code_item_begin = reinterpret_cast<const void*>(code_item);
size_t code_item_size = dex_file_->GetCodeItemSize(*code_item);
@@ -218,7 +218,7 @@ void DexFileTrackingRegistrar::SetCodeItemRegistration(const char* class_name, b
void DexFileTrackingRegistrar::SetAllStringDataStartRegistration(bool should_poison) {
for (size_t stringid_ctr = 0; stringid_ctr < dex_file_->NumStringIds(); ++stringid_ctr) {
- const DexFile::StringId & string_id = dex_file_->GetStringId(StringIndex(stringid_ctr));
+ const dex::StringId & string_id = dex_file_->GetStringId(StringIndex(stringid_ctr));
const void* string_data_begin = reinterpret_cast<const void*>(dex_file_->Begin() + string_id.string_data_off_);
// Data Section of String Data Item
const void* string_data_data_begin = reinterpret_cast<const void*>(dex_file_->GetStringData(string_id));
@@ -229,11 +229,11 @@ void DexFileTrackingRegistrar::SetAllStringDataStartRegistration(bool should_poi
void DexFileTrackingRegistrar::SetAllStringDataRegistration(bool should_poison) {
size_t map_offset = dex_file_->GetHeader().map_off_;
- auto map_list = reinterpret_cast<const DexFile::MapList*>(dex_file_->Begin() + map_offset);
+ auto map_list = reinterpret_cast<const dex::MapList*>(dex_file_->Begin() + map_offset);
for (size_t map_ctr = 0; map_ctr < map_list->size_; ++map_ctr) {
- const DexFile::MapItem& map_item = map_list->list_[map_ctr];
+ const dex::MapItem& map_item = map_list->list_[map_ctr];
if (map_item.type_ == DexFile::kDexTypeStringDataItem) {
- const DexFile::MapItem& next_map_item = map_list->list_[map_ctr + 1];
+ const dex::MapItem& next_map_item = map_list->list_[map_ctr + 1];
const void* string_data_begin = reinterpret_cast<const void*>(dex_file_->Begin() + map_item.offset_);
size_t string_data_size = next_map_item.offset_ - map_item.offset_;
range_values_.push_back(std::make_tuple(string_data_begin, string_data_size, should_poison));
diff --git a/libdexfile/dex/dex_file_verifier.cc b/libdexfile/dex/dex_file_verifier.cc
index 78e4618f04..f376c4dc7b 100644
--- a/libdexfile/dex/dex_file_verifier.cc
+++ b/libdexfile/dex/dex_file_verifier.cc
@@ -116,22 +116,22 @@ const char* DexFileVerifier::CheckLoadStringByTypeIdx(dex::TypeIndex type_idx,
return CheckLoadStringByIdx(dex_file_->GetTypeId(type_idx).descriptor_idx_, error_string);
}
-const DexFile::FieldId* DexFileVerifier::CheckLoadFieldId(uint32_t idx, const char* error_string) {
+const dex::FieldId* DexFileVerifier::CheckLoadFieldId(uint32_t idx, const char* error_string) {
if (UNLIKELY(!CheckIndex(idx, dex_file_->NumFieldIds(), error_string))) {
return nullptr;
}
return &dex_file_->GetFieldId(idx);
}
-const DexFile::MethodId* DexFileVerifier::CheckLoadMethodId(uint32_t idx, const char* err_string) {
+const dex::MethodId* DexFileVerifier::CheckLoadMethodId(uint32_t idx, const char* err_string) {
if (UNLIKELY(!CheckIndex(idx, dex_file_->NumMethodIds(), err_string))) {
return nullptr;
}
return &dex_file_->GetMethodId(idx);
}
-const DexFile::ProtoId* DexFileVerifier::CheckLoadProtoId(dex::ProtoIndex idx,
- const char* err_string) {
+const dex::ProtoId* DexFileVerifier::CheckLoadProtoId(dex::ProtoIndex idx,
+ const char* err_string) {
if (UNLIKELY(!CheckIndex(idx.index_, dex_file_->NumProtoIds(), err_string))) {
return nullptr;
}
@@ -154,14 +154,14 @@ const DexFile::ProtoId* DexFileVerifier::CheckLoadProtoId(dex::ProtoIndex idx,
// Helper macro to load method id. Return last parameter on error.
#define LOAD_METHOD(var, idx, error_string, error_stmt) \
- const DexFile::MethodId* (var) = CheckLoadMethodId(idx, error_string); \
+ const dex::MethodId* (var) = CheckLoadMethodId(idx, error_string); \
if (UNLIKELY((var) == nullptr)) { \
error_stmt; \
}
// Helper macro to load method id. Return last parameter on error.
#define LOAD_FIELD(var, idx, fmt, error_stmt) \
- const DexFile::FieldId* (var) = CheckLoadFieldId(idx, fmt); \
+ const dex::FieldId* (var) = CheckLoadFieldId(idx, fmt); \
if (UNLIKELY((var) == nullptr)) { \
error_stmt; \
}
@@ -385,14 +385,13 @@ bool DexFileVerifier::CheckHeader() {
}
bool DexFileVerifier::CheckMap() {
- const DexFile::MapList* map = reinterpret_cast<const DexFile::MapList*>(begin_ +
- header_->map_off_);
+ const dex::MapList* map = reinterpret_cast<const dex::MapList*>(begin_ + header_->map_off_);
// Check that map list content is available.
- if (!CheckListSize(map, 1, sizeof(DexFile::MapList), "maplist content")) {
+ if (!CheckListSize(map, 1, sizeof(dex::MapList), "maplist content")) {
return false;
}
- const DexFile::MapItem* item = map->list_;
+ const dex::MapItem* item = map->list_;
uint32_t count = map->size_;
uint32_t last_offset = 0;
@@ -402,7 +401,7 @@ bool DexFileVerifier::CheckMap() {
uint32_t used_bits = 0;
// Sanity check the size of the map list.
- if (!CheckListSize(item, count, sizeof(DexFile::MapItem), "map size")) {
+ if (!CheckListSize(item, count, sizeof(dex::MapItem), "map size")) {
return false;
}
@@ -526,8 +525,9 @@ uint32_t DexFileVerifier::ReadUnsignedLittleEndian(uint32_t size) {
return false; \
}
-bool DexFileVerifier::CheckAndGetHandlerOffsets(const DexFile::CodeItem* code_item,
- uint32_t* handler_offsets, uint32_t handlers_size) {
+bool DexFileVerifier::CheckAndGetHandlerOffsets(const dex::CodeItem* code_item,
+ uint32_t* handler_offsets,
+ uint32_t handlers_size) {
CodeItemDataAccessor accessor(*dex_file_, code_item);
const uint8_t* handlers_base = accessor.GetCatchHandlerData();
@@ -587,8 +587,7 @@ bool DexFileVerifier::CheckClassDataItemField(uint32_t idx,
// Check that it's the right class.
dex::TypeIndex my_class_index =
- (reinterpret_cast<const DexFile::FieldId*>(begin_ + header_->field_ids_off_) + idx)->
- class_idx_;
+ (reinterpret_cast<const dex::FieldId*>(begin_ + header_->field_ids_off_) + idx)->class_idx_;
if (class_type_index != my_class_index) {
ErrorStringPrintf("Field's class index unexpected, %" PRIu16 "vs %" PRIu16,
my_class_index.index_,
@@ -625,8 +624,8 @@ bool DexFileVerifier::CheckClassDataItemMethod(uint32_t idx,
return false;
}
- const DexFile::MethodId& method_id =
- *(reinterpret_cast<const DexFile::MethodId*>(begin_ + header_->method_ids_off_) + idx);
+ const dex::MethodId& method_id =
+ *(reinterpret_cast<const dex::MethodId*>(begin_ + header_->method_ids_off_) + idx);
// Check that it's the right class.
dex::TypeIndex my_class_index = method_id.class_idx_;
@@ -911,7 +910,7 @@ bool DexFileVerifier::CheckEncodedAnnotation() {
bool DexFileVerifier::FindClassIndexAndDef(uint32_t index,
bool is_field,
dex::TypeIndex* class_type_index,
- const DexFile::ClassDef** output_class_def) {
+ const dex::ClassDef** output_class_def) {
DCHECK(class_type_index != nullptr);
DCHECK(output_class_def != nullptr);
@@ -923,11 +922,11 @@ bool DexFileVerifier::FindClassIndexAndDef(uint32_t index,
// Next get the type index.
if (is_field) {
*class_type_index =
- (reinterpret_cast<const DexFile::FieldId*>(begin_ + header_->field_ids_off_) + index)->
+ (reinterpret_cast<const dex::FieldId*>(begin_ + header_->field_ids_off_) + index)->
class_idx_;
} else {
*class_type_index =
- (reinterpret_cast<const DexFile::MethodId*>(begin_ + header_->method_ids_off_) + index)->
+ (reinterpret_cast<const dex::MethodId*>(begin_ + header_->method_ids_off_) + index)->
class_idx_;
}
@@ -938,10 +937,10 @@ bool DexFileVerifier::FindClassIndexAndDef(uint32_t index,
// Now search for the class def. This is basically a specialized version of the DexFile code, as
// we should not trust that this is a valid DexFile just yet.
- const DexFile::ClassDef* class_def_begin =
- reinterpret_cast<const DexFile::ClassDef*>(begin_ + header_->class_defs_off_);
+ const dex::ClassDef* class_def_begin =
+ reinterpret_cast<const dex::ClassDef*>(begin_ + header_->class_defs_off_);
for (size_t i = 0; i < header_->class_defs_size_; ++i) {
- const DexFile::ClassDef* class_def = class_def_begin + i;
+ const dex::ClassDef* class_def = class_def_begin + i;
if (class_def->class_idx_ == *class_type_index) {
*output_class_def = class_def;
return true;
@@ -965,7 +964,7 @@ bool DexFileVerifier::CheckOrder(const char* type_descr,
return true;
}
-bool DexFileVerifier::CheckStaticFieldTypes(const DexFile::ClassDef* class_def) {
+bool DexFileVerifier::CheckStaticFieldTypes(const dex::ClassDef* class_def) {
if (class_def == nullptr) {
return true;
}
@@ -978,7 +977,7 @@ bool DexFileVerifier::CheckStaticFieldTypes(const DexFile::ClassDef* class_def)
break;
}
uint32_t index = field.GetIndex();
- const DexFile::TypeId& type_id = dex_file_->GetTypeId(dex_file_->GetFieldId(index).type_idx_);
+ const dex::TypeId& type_id = dex_file_->GetTypeId(dex_file_->GetFieldId(index).type_idx_);
const char* field_type_name =
dex_file_->GetStringData(dex_file_->GetStringId(type_id.descriptor_idx_));
Primitive::Type field_type = Primitive::GetType(field_type_name[0]);
@@ -1069,7 +1068,7 @@ bool DexFileVerifier::CheckIntraClassDataItemFields(size_t count,
ClassAccessor::Field* field,
bool* have_class,
dex::TypeIndex* class_type_index,
- const DexFile::ClassDef** class_def) {
+ const dex::ClassDef** class_def) {
DCHECK(field != nullptr);
constexpr const char* kTypeDescr = kStatic ? "static field" : "instance field";
@@ -1121,7 +1120,7 @@ bool DexFileVerifier::CheckIntraClassDataItemMethods(ClassAccessor::Method* meth
size_t num_directs,
bool* have_class,
dex::TypeIndex* class_type_index,
- const DexFile::ClassDef** class_def) {
+ const dex::ClassDef** class_def) {
DCHECK(method != nullptr);
const char* kTypeDescr = method->IsStaticOrDirect() ? "direct method" : "virtual method";
@@ -1176,7 +1175,7 @@ bool DexFileVerifier::CheckIntraClassDataItem() {
// as the lookup is expensive, cache the result.
bool have_class = false;
dex::TypeIndex class_type_index;
- const DexFile::ClassDef* class_def = nullptr;
+ const dex::ClassDef* class_def = nullptr;
ClassAccessor::Field field(*dex_file_, accessor.ptr_pos_);
// Check fields.
@@ -1232,8 +1231,8 @@ bool DexFileVerifier::CheckIntraClassDataItem() {
}
bool DexFileVerifier::CheckIntraCodeItem() {
- const DexFile::CodeItem* code_item = reinterpret_cast<const DexFile::CodeItem*>(ptr_);
- if (!CheckListSize(code_item, 1, sizeof(DexFile::CodeItem), "code")) {
+ const dex::CodeItem* code_item = reinterpret_cast<const dex::CodeItem*>(ptr_);
+ if (!CheckListSize(code_item, 1, sizeof(dex::CodeItem), "code")) {
return false;
}
@@ -1275,8 +1274,8 @@ bool DexFileVerifier::CheckIntraCodeItem() {
return false;
}
- const DexFile::TryItem* try_items = accessor.TryItems().begin();
- if (!CheckListSize(try_items, try_items_size, sizeof(DexFile::TryItem), "try_items size")) {
+ const dex::TryItem* try_items = accessor.TryItems().begin();
+ if (!CheckListSize(try_items, try_items_size, sizeof(dex::TryItem), "try_items size")) {
return false;
}
@@ -1558,8 +1557,7 @@ bool DexFileVerifier::CheckIntraAnnotationItem() {
}
bool DexFileVerifier::CheckIntraHiddenapiClassData() {
- const DexFile::HiddenapiClassData* item =
- reinterpret_cast<const DexFile::HiddenapiClassData*>(ptr_);
+ const dex::HiddenapiClassData* item = reinterpret_cast<const dex::HiddenapiClassData*>(ptr_);
// Check expected header size.
uint32_t num_header_elems = dex_file_->NumClassDefs() + 1;
@@ -1586,7 +1584,7 @@ bool DexFileVerifier::CheckIntraHiddenapiClassData() {
// Check offsets for each class def.
for (uint32_t i = 0; i < dex_file_->NumClassDefs(); ++i) {
- const DexFile::ClassDef& class_def = dex_file_->GetClassDef(i);
+ const dex::ClassDef& class_def = dex_file_->GetClassDef(i);
const uint8_t* class_data = dex_file_->GetClassData(class_def);
uint32_t offset = item->flags_offset_[i];
@@ -1659,24 +1657,28 @@ bool DexFileVerifier::CheckIntraHiddenapiClassData() {
}
bool DexFileVerifier::CheckIntraAnnotationsDirectoryItem() {
- const DexFile::AnnotationsDirectoryItem* item =
- reinterpret_cast<const DexFile::AnnotationsDirectoryItem*>(ptr_);
- if (!CheckListSize(item, 1, sizeof(DexFile::AnnotationsDirectoryItem), "annotations_directory")) {
+ const dex::AnnotationsDirectoryItem* item =
+ reinterpret_cast<const dex::AnnotationsDirectoryItem*>(ptr_);
+ if (!CheckListSize(item, 1, sizeof(dex::AnnotationsDirectoryItem), "annotations_directory")) {
return false;
}
// Field annotations follow immediately after the annotations directory.
- const DexFile::FieldAnnotationsItem* field_item =
- reinterpret_cast<const DexFile::FieldAnnotationsItem*>(item + 1);
+ const dex::FieldAnnotationsItem* field_item =
+ reinterpret_cast<const dex::FieldAnnotationsItem*>(item + 1);
uint32_t field_count = item->fields_size_;
- if (!CheckListSize(field_item, field_count, sizeof(DexFile::FieldAnnotationsItem), "field_annotations list")) {
+ if (!CheckListSize(field_item,
+ field_count,
+ sizeof(dex::FieldAnnotationsItem),
+ "field_annotations list")) {
return false;
}
uint32_t last_idx = 0;
for (uint32_t i = 0; i < field_count; i++) {
if (UNLIKELY(last_idx >= field_item->field_idx_ && i != 0)) {
- ErrorStringPrintf("Out-of-order field_idx for annotation: %x then %x", last_idx, field_item->field_idx_);
+ ErrorStringPrintf("Out-of-order field_idx for annotation: %x then %x",
+ last_idx, field_item->field_idx_);
return false;
}
last_idx = field_item->field_idx_;
@@ -1684,10 +1686,13 @@ bool DexFileVerifier::CheckIntraAnnotationsDirectoryItem() {
}
// Method annotations follow immediately after field annotations.
- const DexFile::MethodAnnotationsItem* method_item =
- reinterpret_cast<const DexFile::MethodAnnotationsItem*>(field_item);
+ const dex::MethodAnnotationsItem* method_item =
+ reinterpret_cast<const dex::MethodAnnotationsItem*>(field_item);
uint32_t method_count = item->methods_size_;
- if (!CheckListSize(method_item, method_count, sizeof(DexFile::MethodAnnotationsItem), "method_annotations list")) {
+ if (!CheckListSize(method_item,
+ method_count,
+ sizeof(dex::MethodAnnotationsItem),
+ "method_annotations list")) {
return false;
}
@@ -1703,10 +1708,10 @@ bool DexFileVerifier::CheckIntraAnnotationsDirectoryItem() {
}
// Parameter annotations follow immediately after method annotations.
- const DexFile::ParameterAnnotationsItem* parameter_item =
- reinterpret_cast<const DexFile::ParameterAnnotationsItem*>(method_item);
+ const dex::ParameterAnnotationsItem* parameter_item =
+ reinterpret_cast<const dex::ParameterAnnotationsItem*>(method_item);
uint32_t parameter_count = item->parameters_size_;
- if (!CheckListSize(parameter_item, parameter_count, sizeof(DexFile::ParameterAnnotationsItem),
+ if (!CheckListSize(parameter_item, parameter_count, sizeof(dex::ParameterAnnotationsItem),
"parameter_annotations list")) {
return false;
}
@@ -1757,69 +1762,69 @@ bool DexFileVerifier::CheckIntraSectionIterate(size_t offset, uint32_t section_c
const uint8_t* start_ptr = ptr_;
switch (kType) {
case DexFile::kDexTypeStringIdItem: {
- if (!CheckListSize(ptr_, 1, sizeof(DexFile::StringId), "string_ids")) {
+ if (!CheckListSize(ptr_, 1, sizeof(dex::StringId), "string_ids")) {
return false;
}
- ptr_ += sizeof(DexFile::StringId);
+ ptr_ += sizeof(dex::StringId);
break;
}
case DexFile::kDexTypeTypeIdItem: {
- if (!CheckListSize(ptr_, 1, sizeof(DexFile::TypeId), "type_ids")) {
+ if (!CheckListSize(ptr_, 1, sizeof(dex::TypeId), "type_ids")) {
return false;
}
- ptr_ += sizeof(DexFile::TypeId);
+ ptr_ += sizeof(dex::TypeId);
break;
}
case DexFile::kDexTypeProtoIdItem: {
- if (!CheckListSize(ptr_, 1, sizeof(DexFile::ProtoId), "proto_ids")) {
+ if (!CheckListSize(ptr_, 1, sizeof(dex::ProtoId), "proto_ids")) {
return false;
}
- ptr_ += sizeof(DexFile::ProtoId);
+ ptr_ += sizeof(dex::ProtoId);
break;
}
case DexFile::kDexTypeFieldIdItem: {
- if (!CheckListSize(ptr_, 1, sizeof(DexFile::FieldId), "field_ids")) {
+ if (!CheckListSize(ptr_, 1, sizeof(dex::FieldId), "field_ids")) {
return false;
}
- ptr_ += sizeof(DexFile::FieldId);
+ ptr_ += sizeof(dex::FieldId);
break;
}
case DexFile::kDexTypeMethodIdItem: {
- if (!CheckListSize(ptr_, 1, sizeof(DexFile::MethodId), "method_ids")) {
+ if (!CheckListSize(ptr_, 1, sizeof(dex::MethodId), "method_ids")) {
return false;
}
- ptr_ += sizeof(DexFile::MethodId);
+ ptr_ += sizeof(dex::MethodId);
break;
}
case DexFile::kDexTypeClassDefItem: {
- if (!CheckListSize(ptr_, 1, sizeof(DexFile::ClassDef), "class_defs")) {
+ if (!CheckListSize(ptr_, 1, sizeof(dex::ClassDef), "class_defs")) {
return false;
}
- ptr_ += sizeof(DexFile::ClassDef);
+ ptr_ += sizeof(dex::ClassDef);
break;
}
case DexFile::kDexTypeCallSiteIdItem: {
- if (!CheckListSize(ptr_, 1, sizeof(DexFile::CallSiteIdItem), "call_site_ids")) {
+ if (!CheckListSize(ptr_, 1, sizeof(dex::CallSiteIdItem), "call_site_ids")) {
return false;
}
- ptr_ += sizeof(DexFile::CallSiteIdItem);
+ ptr_ += sizeof(dex::CallSiteIdItem);
break;
}
case DexFile::kDexTypeMethodHandleItem: {
- if (!CheckListSize(ptr_, 1, sizeof(DexFile::MethodHandleItem), "method_handles")) {
+ if (!CheckListSize(ptr_, 1, sizeof(dex::MethodHandleItem), "method_handles")) {
return false;
}
- ptr_ += sizeof(DexFile::MethodHandleItem);
+ ptr_ += sizeof(dex::MethodHandleItem);
break;
}
case DexFile::kDexTypeTypeList: {
- if (!CheckList(sizeof(DexFile::TypeItem), "type_list", &ptr_)) {
+ if (!CheckList(sizeof(dex::TypeItem), "type_list", &ptr_)) {
return false;
}
break;
}
case DexFile::kDexTypeAnnotationSetRefList: {
- if (!CheckList(sizeof(DexFile::AnnotationSetRefItem), "annotation_set_ref_list", &ptr_)) {
+ if (!CheckList(sizeof(dex::AnnotationSetRefItem), "annotation_set_ref_list", &ptr_)) {
return false;
}
break;
@@ -1986,9 +1991,8 @@ bool DexFileVerifier::CheckIntraDataSection(size_t offset, uint32_t count) {
}
bool DexFileVerifier::CheckIntraSection() {
- const DexFile::MapList* map =
- reinterpret_cast<const DexFile::MapList*>(begin_ + header_->map_off_);
- const DexFile::MapItem* item = map->list_;
+ const dex::MapList* map = reinterpret_cast<const dex::MapList*>(begin_ + header_->map_off_);
+ const dex::MapItem* item = map->list_;
size_t offset = 0;
uint32_t count = map->size_;
ptr_ = begin_;
@@ -2052,8 +2056,8 @@ bool DexFileVerifier::CheckIntraSection() {
section_offset, header_->map_off_);
return false;
}
- ptr_ += sizeof(uint32_t) + (map->size_ * sizeof(DexFile::MapItem));
- offset = section_offset + sizeof(uint32_t) + (map->size_ * sizeof(DexFile::MapItem));
+ ptr_ += sizeof(uint32_t) + (map->size_ * sizeof(dex::MapItem));
+ offset = section_offset + sizeof(uint32_t) + (map->size_ * sizeof(dex::MapItem));
break;
#define CHECK_INTRA_SECTION_ITERATE_CASE(type) \
@@ -2137,26 +2141,26 @@ dex::TypeIndex DexFileVerifier::FindFirstClassDataDefiner(const uint8_t* ptr, bo
dex::TypeIndex DexFileVerifier::FindFirstAnnotationsDirectoryDefiner(const uint8_t* ptr,
bool* success) {
- const DexFile::AnnotationsDirectoryItem* item =
- reinterpret_cast<const DexFile::AnnotationsDirectoryItem*>(ptr);
+ const dex::AnnotationsDirectoryItem* item =
+ reinterpret_cast<const dex::AnnotationsDirectoryItem*>(ptr);
*success = true;
if (item->fields_size_ != 0) {
- DexFile::FieldAnnotationsItem* field_items = (DexFile::FieldAnnotationsItem*) (item + 1);
+ dex::FieldAnnotationsItem* field_items = (dex::FieldAnnotationsItem*) (item + 1);
LOAD_FIELD(field, field_items[0].field_idx_, "first_annotations_dir_definer field_id",
*success = false; return dex::TypeIndex(DexFile::kDexNoIndex16))
return field->class_idx_;
}
if (item->methods_size_ != 0) {
- DexFile::MethodAnnotationsItem* method_items = (DexFile::MethodAnnotationsItem*) (item + 1);
+ dex::MethodAnnotationsItem* method_items = (dex::MethodAnnotationsItem*) (item + 1);
LOAD_METHOD(method, method_items[0].method_idx_, "first_annotations_dir_definer method id",
*success = false; return dex::TypeIndex(DexFile::kDexNoIndex16))
return method->class_idx_;
}
if (item->parameters_size_ != 0) {
- DexFile::ParameterAnnotationsItem* parameter_items = (DexFile::ParameterAnnotationsItem*) (item + 1);
+ dex::ParameterAnnotationsItem* parameter_items = (dex::ParameterAnnotationsItem*) (item + 1);
LOAD_METHOD(method, parameter_items[0].method_idx_, "first_annotations_dir_definer method id",
*success = false; return dex::TypeIndex(DexFile::kDexNoIndex16))
return method->class_idx_;
@@ -2166,7 +2170,7 @@ dex::TypeIndex DexFileVerifier::FindFirstAnnotationsDirectoryDefiner(const uint8
}
bool DexFileVerifier::CheckInterStringIdItem() {
- const DexFile::StringId* item = reinterpret_cast<const DexFile::StringId*>(ptr_);
+ const dex::StringId* item = reinterpret_cast<const dex::StringId*>(ptr_);
// Check the map to make sure it has the right offset->type.
if (!CheckOffsetToTypeMap(item->string_data_off_, DexFile::kDexTypeStringDataItem)) {
@@ -2175,7 +2179,7 @@ bool DexFileVerifier::CheckInterStringIdItem() {
// Check ordering between items.
if (previous_item_ != nullptr) {
- const DexFile::StringId* prev_item = reinterpret_cast<const DexFile::StringId*>(previous_item_);
+ const dex::StringId* prev_item = reinterpret_cast<const dex::StringId*>(previous_item_);
const char* prev_str = dex_file_->GetStringData(*prev_item);
const char* str = dex_file_->GetStringData(*item);
if (UNLIKELY(CompareModifiedUtf8ToModifiedUtf8AsUtf16CodePointValues(prev_str, str) >= 0)) {
@@ -2184,12 +2188,12 @@ bool DexFileVerifier::CheckInterStringIdItem() {
}
}
- ptr_ += sizeof(DexFile::StringId);
+ ptr_ += sizeof(dex::StringId);
return true;
}
bool DexFileVerifier::CheckInterTypeIdItem() {
- const DexFile::TypeId* item = reinterpret_cast<const DexFile::TypeId*>(ptr_);
+ const dex::TypeId* item = reinterpret_cast<const dex::TypeId*>(ptr_);
LOAD_STRING(descriptor, item->descriptor_idx_, "inter_type_id_item descriptor_idx")
@@ -2201,7 +2205,7 @@ bool DexFileVerifier::CheckInterTypeIdItem() {
// Check ordering between items.
if (previous_item_ != nullptr) {
- const DexFile::TypeId* prev_item = reinterpret_cast<const DexFile::TypeId*>(previous_item_);
+ const dex::TypeId* prev_item = reinterpret_cast<const dex::TypeId*>(previous_item_);
if (UNLIKELY(prev_item->descriptor_idx_ >= item->descriptor_idx_)) {
ErrorStringPrintf("Out-of-order type_ids: %x then %x",
prev_item->descriptor_idx_.index_,
@@ -2210,12 +2214,12 @@ bool DexFileVerifier::CheckInterTypeIdItem() {
}
}
- ptr_ += sizeof(DexFile::TypeId);
+ ptr_ += sizeof(dex::TypeId);
return true;
}
bool DexFileVerifier::CheckInterProtoIdItem() {
- const DexFile::ProtoId* item = reinterpret_cast<const DexFile::ProtoId*>(ptr_);
+ const dex::ProtoId* item = reinterpret_cast<const dex::ProtoId*>(ptr_);
LOAD_STRING(shorty, item->shorty_idx_, "inter_proto_id_item shorty_idx")
@@ -2258,7 +2262,7 @@ bool DexFileVerifier::CheckInterProtoIdItem() {
// Check ordering between items. This relies on type_ids being in order.
if (previous_item_ != nullptr) {
- const DexFile::ProtoId* prev = reinterpret_cast<const DexFile::ProtoId*>(previous_item_);
+ const dex::ProtoId* prev = reinterpret_cast<const dex::ProtoId*>(previous_item_);
if (UNLIKELY(prev->return_type_idx_ > item->return_type_idx_)) {
ErrorStringPrintf("Out-of-order proto_id return types");
return false;
@@ -2291,12 +2295,12 @@ bool DexFileVerifier::CheckInterProtoIdItem() {
}
}
- ptr_ += sizeof(DexFile::ProtoId);
+ ptr_ += sizeof(dex::ProtoId);
return true;
}
bool DexFileVerifier::CheckInterFieldIdItem() {
- const DexFile::FieldId* item = reinterpret_cast<const DexFile::FieldId*>(ptr_);
+ const dex::FieldId* item = reinterpret_cast<const dex::FieldId*>(ptr_);
// Check that the class descriptor is valid.
LOAD_STRING_BY_TYPE(class_descriptor, item->class_idx_, "inter_field_id_item class_idx")
@@ -2321,7 +2325,7 @@ bool DexFileVerifier::CheckInterFieldIdItem() {
// Check ordering between items. This relies on the other sections being in order.
if (previous_item_ != nullptr) {
- const DexFile::FieldId* prev_item = reinterpret_cast<const DexFile::FieldId*>(previous_item_);
+ const dex::FieldId* prev_item = reinterpret_cast<const dex::FieldId*>(previous_item_);
if (UNLIKELY(prev_item->class_idx_ > item->class_idx_)) {
ErrorStringPrintf("Out-of-order field_ids");
return false;
@@ -2338,12 +2342,12 @@ bool DexFileVerifier::CheckInterFieldIdItem() {
}
}
- ptr_ += sizeof(DexFile::FieldId);
+ ptr_ += sizeof(dex::FieldId);
return true;
}
bool DexFileVerifier::CheckInterMethodIdItem() {
- const DexFile::MethodId* item = reinterpret_cast<const DexFile::MethodId*>(ptr_);
+ const dex::MethodId* item = reinterpret_cast<const dex::MethodId*>(ptr_);
// Check that the class descriptor is a valid reference name.
LOAD_STRING_BY_TYPE(class_descriptor, item->class_idx_, "inter_method_id_item class_idx")
@@ -2368,7 +2372,7 @@ bool DexFileVerifier::CheckInterMethodIdItem() {
// Check ordering between items. This relies on the other sections being in order.
if (previous_item_ != nullptr) {
- const DexFile::MethodId* prev_item = reinterpret_cast<const DexFile::MethodId*>(previous_item_);
+ const dex::MethodId* prev_item = reinterpret_cast<const dex::MethodId*>(previous_item_);
if (UNLIKELY(prev_item->class_idx_ > item->class_idx_)) {
ErrorStringPrintf("Out-of-order method_ids");
return false;
@@ -2385,12 +2389,12 @@ bool DexFileVerifier::CheckInterMethodIdItem() {
}
}
- ptr_ += sizeof(DexFile::MethodId);
+ ptr_ += sizeof(dex::MethodId);
return true;
}
bool DexFileVerifier::CheckInterClassDefItem() {
- const DexFile::ClassDef* item = reinterpret_cast<const DexFile::ClassDef*>(ptr_);
+ const dex::ClassDef* item = reinterpret_cast<const dex::ClassDef*>(ptr_);
// Check that class_idx_ is representable as a uint16_t;
if (UNLIKELY(!IsValidTypeId(item->class_idx_.index_, item->pad1_))) {
@@ -2452,7 +2456,7 @@ bool DexFileVerifier::CheckInterClassDefItem() {
// Check that a class is defined after its super class (if the
// latter is defined in the same Dex file).
- const DexFile::ClassDef* superclass_def = dex_file_->FindClassDef(item->superclass_idx_);
+ const dex::ClassDef* superclass_def = dex_file_->FindClassDef(item->superclass_idx_);
if (superclass_def != nullptr) {
// The superclass is defined in this Dex file.
if (superclass_def > item) {
@@ -2476,7 +2480,7 @@ bool DexFileVerifier::CheckInterClassDefItem() {
}
// Check interfaces.
- const DexFile::TypeList* interfaces = dex_file_->GetInterfacesList(*item);
+ const dex::TypeList* interfaces = dex_file_->GetInterfacesList(*item);
if (interfaces != nullptr) {
uint32_t size = interfaces->Size();
for (uint32_t i = 0; i < size; i++) {
@@ -2491,7 +2495,7 @@ bool DexFileVerifier::CheckInterClassDefItem() {
// Check that a class is defined after the interfaces it implements
// (if they are defined in the same Dex file).
- const DexFile::ClassDef* interface_def =
+ const dex::ClassDef* interface_def =
dex_file_->FindClassDef(interfaces->GetTypeItem(i).type_idx_);
if (interface_def != nullptr) {
// The interface is defined in this Dex file.
@@ -2567,12 +2571,12 @@ bool DexFileVerifier::CheckInterClassDefItem() {
}
}
- ptr_ += sizeof(DexFile::ClassDef);
+ ptr_ += sizeof(dex::ClassDef);
return true;
}
bool DexFileVerifier::CheckInterCallSiteIdItem() {
- const DexFile::CallSiteIdItem* item = reinterpret_cast<const DexFile::CallSiteIdItem*>(ptr_);
+ const dex::CallSiteIdItem* item = reinterpret_cast<const dex::CallSiteIdItem*>(ptr_);
// Check call site referenced by item is in encoded array section.
if (!CheckOffsetToTypeMap(item->data_off_, DexFile::kDexTypeEncodedArrayItem)) {
@@ -2622,12 +2626,12 @@ bool DexFileVerifier::CheckInterCallSiteIdItem() {
return false;
}
- ptr_ += sizeof(DexFile::CallSiteIdItem);
+ ptr_ += sizeof(dex::CallSiteIdItem);
return true;
}
bool DexFileVerifier::CheckInterMethodHandleItem() {
- const DexFile::MethodHandleItem* item = reinterpret_cast<const DexFile::MethodHandleItem*>(ptr_);
+ const dex::MethodHandleItem* item = reinterpret_cast<const dex::MethodHandleItem*>(ptr_);
DexFile::MethodHandleType method_handle_type =
static_cast<DexFile::MethodHandleType>(item->method_handle_type_);
@@ -2655,14 +2659,13 @@ bool DexFileVerifier::CheckInterMethodHandleItem() {
}
}
- ptr_ += sizeof(DexFile::MethodHandleItem);
+ ptr_ += sizeof(dex::MethodHandleItem);
return true;
}
bool DexFileVerifier::CheckInterAnnotationSetRefList() {
- const DexFile::AnnotationSetRefList* list =
- reinterpret_cast<const DexFile::AnnotationSetRefList*>(ptr_);
- const DexFile::AnnotationSetRefItem* item = list->list_;
+ const dex::AnnotationSetRefList* list = reinterpret_cast<const dex::AnnotationSetRefList*>(ptr_);
+ const dex::AnnotationSetRefItem* item = list->list_;
uint32_t count = list->size_;
for (; count != 0u; --count) {
@@ -2678,7 +2681,7 @@ bool DexFileVerifier::CheckInterAnnotationSetRefList() {
}
bool DexFileVerifier::CheckInterAnnotationSetItem() {
- const DexFile::AnnotationSetItem* set = reinterpret_cast<const DexFile::AnnotationSetItem*>(ptr_);
+ const dex::AnnotationSetItem* set = reinterpret_cast<const dex::AnnotationSetItem*>(ptr_);
const uint32_t* offsets = set->entries_;
uint32_t count = set->size_;
uint32_t last_idx = 0;
@@ -2689,8 +2692,8 @@ bool DexFileVerifier::CheckInterAnnotationSetItem() {
}
// Get the annotation from the offset and the type index for the annotation.
- const DexFile::AnnotationItem* annotation =
- reinterpret_cast<const DexFile::AnnotationItem*>(begin_ + *offsets);
+ const dex::AnnotationItem* annotation =
+ reinterpret_cast<const dex::AnnotationItem*>(begin_ + *offsets);
const uint8_t* data = annotation->annotation_;
DECODE_UNSIGNED_CHECKED_FROM(data, idx);
@@ -2741,8 +2744,8 @@ bool DexFileVerifier::CheckInterClassDataItem() {
}
bool DexFileVerifier::CheckInterAnnotationsDirectoryItem() {
- const DexFile::AnnotationsDirectoryItem* item =
- reinterpret_cast<const DexFile::AnnotationsDirectoryItem*>(ptr_);
+ const dex::AnnotationsDirectoryItem* item =
+ reinterpret_cast<const dex::AnnotationsDirectoryItem*>(ptr_);
bool success;
dex::TypeIndex defining_class = FindFirstAnnotationsDirectoryDefiner(ptr_, &success);
if (!success) {
@@ -2755,8 +2758,8 @@ bool DexFileVerifier::CheckInterAnnotationsDirectoryItem() {
}
// Field annotations follow immediately after the annotations directory.
- const DexFile::FieldAnnotationsItem* field_item =
- reinterpret_cast<const DexFile::FieldAnnotationsItem*>(item + 1);
+ const dex::FieldAnnotationsItem* field_item =
+ reinterpret_cast<const dex::FieldAnnotationsItem*>(item + 1);
uint32_t field_count = item->fields_size_;
for (uint32_t i = 0; i < field_count; i++) {
LOAD_FIELD(field, field_item->field_idx_, "inter_annotations_directory_item field_id",
@@ -2772,8 +2775,8 @@ bool DexFileVerifier::CheckInterAnnotationsDirectoryItem() {
}
// Method annotations follow immediately after field annotations.
- const DexFile::MethodAnnotationsItem* method_item =
- reinterpret_cast<const DexFile::MethodAnnotationsItem*>(field_item);
+ const dex::MethodAnnotationsItem* method_item =
+ reinterpret_cast<const dex::MethodAnnotationsItem*>(field_item);
uint32_t method_count = item->methods_size_;
for (uint32_t i = 0; i < method_count; i++) {
LOAD_METHOD(method, method_item->method_idx_, "inter_annotations_directory_item method_id",
@@ -2789,8 +2792,8 @@ bool DexFileVerifier::CheckInterAnnotationsDirectoryItem() {
}
// Parameter annotations follow immediately after method annotations.
- const DexFile::ParameterAnnotationsItem* parameter_item =
- reinterpret_cast<const DexFile::ParameterAnnotationsItem*>(method_item);
+ const dex::ParameterAnnotationsItem* parameter_item =
+ reinterpret_cast<const dex::ParameterAnnotationsItem*>(method_item);
uint32_t parameter_count = item->parameters_size_;
for (uint32_t i = 0; i < parameter_count; i++) {
LOAD_METHOD(parameter_method, parameter_item->method_idx_,
@@ -2946,8 +2949,8 @@ bool DexFileVerifier::CheckInterSectionIterate(size_t offset,
}
bool DexFileVerifier::CheckInterSection() {
- const DexFile::MapList* map = reinterpret_cast<const DexFile::MapList*>(begin_ + header_->map_off_);
- const DexFile::MapItem* item = map->list_;
+ const dex::MapList* map = reinterpret_cast<const dex::MapList*>(begin_ + header_->map_off_);
+ const dex::MapItem* item = map->list_;
uint32_t count = map->size_;
// Cross check the items listed in the map.
@@ -3056,9 +3059,8 @@ static std::string GetStringOrError(const uint8_t* const begin,
return "(error)";
}
- const DexFile::StringId* string_id =
- reinterpret_cast<const DexFile::StringId*>(begin + header->string_ids_off_)
- + string_idx.index_;
+ const dex::StringId* string_id =
+ reinterpret_cast<const dex::StringId*>(begin + header->string_ids_off_) + string_idx.index_;
// Assume that the data is OK at this point. String data has been checked at this point.
@@ -3079,8 +3081,8 @@ static std::string GetClassOrError(const uint8_t* const begin,
// a valid defining class.
CHECK_LT(class_idx.index_, header->type_ids_size_);
- const DexFile::TypeId* type_id =
- reinterpret_cast<const DexFile::TypeId*>(begin + header->type_ids_off_) + class_idx.index_;
+ const dex::TypeId* type_id =
+ reinterpret_cast<const dex::TypeId*>(begin + header->type_ids_off_) + class_idx.index_;
// Assume that the data is OK at this point. Type id offsets have been checked at this point.
@@ -3093,8 +3095,8 @@ static std::string GetFieldDescriptionOrError(const uint8_t* const begin,
// The `idx` has already been checked in `DexFileVerifier::CheckClassDataItemField()`.
CHECK_LT(idx, header->field_ids_size_);
- const DexFile::FieldId* field_id =
- reinterpret_cast<const DexFile::FieldId*>(begin + header->field_ids_off_) + idx;
+ const dex::FieldId* field_id =
+ reinterpret_cast<const dex::FieldId*>(begin + header->field_ids_off_) + idx;
// Assume that the data is OK at this point. Field id offsets have been checked at this point.
@@ -3110,8 +3112,8 @@ static std::string GetMethodDescriptionOrError(const uint8_t* const begin,
// The `idx` has already been checked in `DexFileVerifier::CheckClassDataItemMethod()`.
CHECK_LT(idx, header->method_ids_size_);
- const DexFile::MethodId* method_id =
- reinterpret_cast<const DexFile::MethodId*>(begin + header->method_ids_off_) + idx;
+ const dex::MethodId* method_id =
+ reinterpret_cast<const dex::MethodId*>(begin + header->method_ids_off_) + idx;
// Assume that the data is OK at this point. Method id offsets have been checked at this point.
@@ -3202,16 +3204,16 @@ bool DexFileVerifier::CheckFieldAccessFlags(uint32_t idx,
void DexFileVerifier::FindStringRangesForMethodNames() {
// Use DexFile::StringId* as RandomAccessIterator.
- const DexFile::StringId* first = reinterpret_cast<const DexFile::StringId*>(
+ const dex::StringId* first = reinterpret_cast<const dex::StringId*>(
begin_ + header_->string_ids_off_);
- const DexFile::StringId* last = first + header_->string_ids_size_;
+ const dex::StringId* last = first + header_->string_ids_size_;
- auto get_string = [begin = begin_](const DexFile::StringId& id) {
+ auto get_string = [begin = begin_](const dex::StringId& id) {
const uint8_t* str_data_ptr = begin + id.string_data_off_;
DecodeUnsignedLeb128(&str_data_ptr);
return reinterpret_cast<const char*>(str_data_ptr);
};
- auto compare = [&get_string](const DexFile::StringId& lhs, const char* rhs) {
+ auto compare = [&get_string](const dex::StringId& lhs, const char* rhs) {
return CompareModifiedUtf8ToModifiedUtf8AsUtf16CodePointValues(get_string(lhs), rhs) < 0;
};
@@ -3451,8 +3453,8 @@ bool DexFileVerifier::CheckConstructorProperties(
constructor_flags == (kAccConstructor | kAccStatic));
// Check signature matches expectations.
- const DexFile::MethodId* const method_id = CheckLoadMethodId(method_index,
- "Bad <init>/<clinit> method id");
+ const dex::MethodId* const method_id = CheckLoadMethodId(method_index,
+ "Bad <init>/<clinit> method id");
if (method_id == nullptr) {
return false;
}
@@ -3462,8 +3464,8 @@ bool DexFileVerifier::CheckConstructorProperties(
// TODO(oth): the error message here is to satisfy the MethodId test
// in the DexFileVerifierTest. The test is checking that the error
// contains this string if the index is out of range.
- const DexFile::ProtoId* const proto_id = CheckLoadProtoId(method_id->proto_idx_,
- "inter_method_id_item proto_idx");
+ const dex::ProtoId* const proto_id = CheckLoadProtoId(method_id->proto_idx_,
+ "inter_method_id_item proto_idx");
if (proto_id == nullptr) {
return false;
}
diff --git a/libdexfile/dex/dex_file_verifier.h b/libdexfile/dex/dex_file_verifier.h
index a81df48398..b51a417297 100644
--- a/libdexfile/dex/dex_file_verifier.h
+++ b/libdexfile/dex/dex_file_verifier.h
@@ -79,7 +79,7 @@ class DexFileVerifier {
bool CheckMap();
uint32_t ReadUnsignedLittleEndian(uint32_t size);
- bool CheckAndGetHandlerOffsets(const DexFile::CodeItem* code_item,
+ bool CheckAndGetHandlerOffsets(const dex::CodeItem* code_item,
uint32_t* handler_offsets, uint32_t handlers_size);
bool CheckClassDataItemField(uint32_t idx,
uint32_t access_flags,
@@ -95,7 +95,7 @@ class DexFileVerifier {
size_t* remaining_directs);
ALWAYS_INLINE
bool CheckOrder(const char* type_descr, uint32_t curr_index, uint32_t prev_index);
- bool CheckStaticFieldTypes(const DexFile::ClassDef* class_def);
+ bool CheckStaticFieldTypes(const dex::ClassDef* class_def);
bool CheckPadding(size_t offset, uint32_t aligned_offset, DexFile::MapItemType type);
bool CheckEncodedValue();
@@ -110,7 +110,7 @@ class DexFileVerifier {
ClassAccessor::Field* field,
bool* have_class,
dex::TypeIndex* class_type_index,
- const DexFile::ClassDef** class_def);
+ const dex::ClassDef** class_def);
// Check all methods of the given type from the given iterator. Load the class data from the first
// method, if necessary (and return it), or use the given values.
bool CheckIntraClassDataItemMethods(ClassAccessor::Method* method,
@@ -119,7 +119,7 @@ class DexFileVerifier {
size_t num_directs,
bool* have_class,
dex::TypeIndex* class_type_index,
- const DexFile::ClassDef** class_def);
+ const dex::ClassDef** class_def);
bool CheckIntraCodeItem();
bool CheckIntraStringDataItem();
@@ -166,9 +166,9 @@ class DexFileVerifier {
// Load a field/method/proto Id by index. Checks whether the index is in bounds, printing the
// error if not. If there is an error, null is returned.
- const DexFile::FieldId* CheckLoadFieldId(uint32_t idx, const char* error_fmt);
- const DexFile::MethodId* CheckLoadMethodId(uint32_t idx, const char* error_fmt);
- const DexFile::ProtoId* CheckLoadProtoId(dex::ProtoIndex idx, const char* error_fmt);
+ const dex::FieldId* CheckLoadFieldId(uint32_t idx, const char* error_fmt);
+ const dex::MethodId* CheckLoadMethodId(uint32_t idx, const char* error_fmt);
+ const dex::ProtoId* CheckLoadProtoId(dex::ProtoIndex idx, const char* error_fmt);
void ErrorStringPrintf(const char* fmt, ...)
__attribute__((__format__(__printf__, 2, 3))) COLD_ATTR;
@@ -182,7 +182,7 @@ class DexFileVerifier {
bool FindClassIndexAndDef(uint32_t index,
bool is_field,
dex::TypeIndex* class_type_index,
- const DexFile::ClassDef** output_class_def);
+ const dex::ClassDef** output_class_def);
// Check validity of the given access flags, interpreted for a field in the context of a class
// with the given second access flags.
@@ -247,7 +247,7 @@ class DexFileVerifier {
std::string failure_reason_;
// Set of type ids for which there are ClassDef elements in the dex file.
- std::unordered_set<decltype(DexFile::ClassDef::class_idx_)> defined_classes_;
+ std::unordered_set<decltype(dex::ClassDef::class_idx_)> defined_classes_;
// Cached string indices for "interesting" entries wrt/ method names. Will be populated by
// FindStringRangesForMethodNames (which is automatically called before verifying the
diff --git a/libdexfile/dex/dex_file_verifier_test.cc b/libdexfile/dex/dex_file_verifier_test.cc
index c3180f0660..b2cff4f311 100644
--- a/libdexfile/dex/dex_file_verifier_test.cc
+++ b/libdexfile/dex/dex_file_verifier_test.cc
@@ -153,7 +153,7 @@ TEST_F(DexFileVerifierTest, MethodId) {
kGoodTestDex,
"method_id_class_idx",
[](DexFile* dex_file) {
- DexFile::MethodId* method_id = const_cast<DexFile::MethodId*>(&dex_file->GetMethodId(0));
+ dex::MethodId* method_id = const_cast<dex::MethodId*>(&dex_file->GetMethodId(0));
method_id->class_idx_ = dex::TypeIndex(0xFF);
},
"could not find declaring class for direct method index 0");
@@ -163,7 +163,7 @@ TEST_F(DexFileVerifierTest, MethodId) {
kGoodTestDex,
"method_id_proto_idx",
[](DexFile* dex_file) {
- DexFile::MethodId* method_id = const_cast<DexFile::MethodId*>(&dex_file->GetMethodId(0));
+ dex::MethodId* method_id = const_cast<dex::MethodId*>(&dex_file->GetMethodId(0));
method_id->proto_idx_ = dex::ProtoIndex(0xFF);
},
"inter_method_id_item proto_idx");
@@ -173,7 +173,7 @@ TEST_F(DexFileVerifierTest, MethodId) {
kGoodTestDex,
"method_id_name_idx",
[](DexFile* dex_file) {
- DexFile::MethodId* method_id = const_cast<DexFile::MethodId*>(&dex_file->GetMethodId(0));
+ dex::MethodId* method_id = const_cast<dex::MethodId*>(&dex_file->GetMethodId(0));
method_id->name_idx_ = dex::StringIndex(0xFF);
},
"Bad index for method flags verification");
@@ -244,7 +244,7 @@ static const uint8_t* FindMethodData(const DexFile* dex_file,
for (const ClassAccessor::Method& method : accessor.GetMethods()) {
uint32_t method_index = method.GetIndex();
dex::StringIndex name_index = dex_file->GetMethodId(method_index).name_idx_;
- const DexFile::StringId& string_id = dex_file->GetStringId(name_index);
+ const dex::StringId& string_id = dex_file->GetStringId(name_index);
const char* str = dex_file->GetStringData(string_id);
if (strcmp(name, str) == 0) {
if (method_idx != nullptr) {
@@ -837,7 +837,7 @@ static const uint8_t* FindFieldData(const DexFile* dex_file, const char* name) {
for (const ClassAccessor::Field& field : accessor.GetFields()) {
uint32_t field_index = field.GetIndex();
dex::StringIndex name_index = dex_file->GetFieldId(field_index).name_idx_;
- const DexFile::StringId& string_id = dex_file->GetStringId(name_index);
+ const dex::StringId& string_id = dex_file->GetStringId(name_index);
const char* str = dex_file->GetStringData(string_id);
if (strcmp(name, str) == 0) {
// Go to the back of the access flags.
@@ -1415,9 +1415,9 @@ TEST_F(DexFileVerifierTest, ProtoOrdering) {
dex_file->GetMethodId(method_idx + 1).proto_idx_.index_);
// Their return types should be the same.
dex::ProtoIndex proto1_idx = dex_file->GetMethodId(method_idx).proto_idx_;
- const DexFile::ProtoId& proto1 = dex_file->GetProtoId(proto1_idx);
+ const dex::ProtoId& proto1 = dex_file->GetProtoId(proto1_idx);
dex::ProtoIndex proto2_idx(proto1_idx.index_ + 1u);
- const DexFile::ProtoId& proto2 = dex_file->GetProtoId(proto2_idx);
+ const dex::ProtoId& proto2 = dex_file->GetProtoId(proto2_idx);
CHECK_EQ(proto1.return_type_idx_, proto2.return_type_idx_);
// And the first should not have any parameters while the second should have some.
CHECK(!DexFileParameterIterator(*dex_file, proto1).HasNext());
diff --git a/libdexfile/dex/method_reference.h b/libdexfile/dex/method_reference.h
index 266582b059..f66ac30c53 100644
--- a/libdexfile/dex/method_reference.h
+++ b/libdexfile/dex/method_reference.h
@@ -31,7 +31,7 @@ class MethodReference : public DexFileReference {
std::string PrettyMethod(bool with_signature = true) const {
return dex_file->PrettyMethod(index, with_signature);
}
- const DexFile::MethodId& GetMethodId() const {
+ const dex::MethodId& GetMethodId() const {
return dex_file->GetMethodId(index);
}
};
@@ -50,8 +50,8 @@ struct MethodReferenceValueComparator {
bool SlowCompare(MethodReference mr1, MethodReference mr2) const {
// The order is the same as for method ids in a single dex file.
// Compare the class descriptors first.
- const DexFile::MethodId& mid1 = mr1.GetMethodId();
- const DexFile::MethodId& mid2 = mr2.GetMethodId();
+ const dex::MethodId& mid1 = mr1.GetMethodId();
+ const dex::MethodId& mid2 = mr2.GetMethodId();
int descriptor_diff = strcmp(mr1.dex_file->StringByTypeIdx(mid1.class_idx_),
mr2.dex_file->StringByTypeIdx(mid2.class_idx_));
if (descriptor_diff != 0) {
@@ -63,17 +63,17 @@ struct MethodReferenceValueComparator {
return name_diff < 0;
}
// And then compare proto ids, starting with return type comparison.
- const DexFile::ProtoId& prid1 = mr1.dex_file->GetProtoId(mid1.proto_idx_);
- const DexFile::ProtoId& prid2 = mr2.dex_file->GetProtoId(mid2.proto_idx_);
+ const dex::ProtoId& prid1 = mr1.dex_file->GetProtoId(mid1.proto_idx_);
+ const dex::ProtoId& prid2 = mr2.dex_file->GetProtoId(mid2.proto_idx_);
int return_type_diff = strcmp(mr1.dex_file->StringByTypeIdx(prid1.return_type_idx_),
mr2.dex_file->StringByTypeIdx(prid2.return_type_idx_));
if (return_type_diff != 0) {
return return_type_diff < 0;
}
// And finishing with lexicographical parameter comparison.
- const DexFile::TypeList* params1 = mr1.dex_file->GetProtoParameters(prid1);
+ const dex::TypeList* params1 = mr1.dex_file->GetProtoParameters(prid1);
size_t param1_size = (params1 != nullptr) ? params1->Size() : 0u;
- const DexFile::TypeList* params2 = mr2.dex_file->GetProtoParameters(prid2);
+ const dex::TypeList* params2 = mr2.dex_file->GetProtoParameters(prid2);
size_t param2_size = (params2 != nullptr) ? params2->Size() : 0u;
for (size_t i = 0, num = std::min(param1_size, param2_size); i != num; ++i) {
int param_diff = strcmp(mr1.dex_file->StringByTypeIdx(params1->GetTypeItem(i).type_idx_),
diff --git a/libdexfile/dex/standard_dex_file.cc b/libdexfile/dex/standard_dex_file.cc
index 40dcafde74..8bac44e02e 100644
--- a/libdexfile/dex/standard_dex_file.cc
+++ b/libdexfile/dex/standard_dex_file.cc
@@ -72,7 +72,7 @@ bool StandardDexFile::SupportsDefaultMethods() const {
return GetDexVersion() >= DexFile::kDefaultMethodsVersion;
}
-uint32_t StandardDexFile::GetCodeItemSize(const DexFile::CodeItem& item) const {
+uint32_t StandardDexFile::GetCodeItemSize(const dex::CodeItem& item) const {
DCHECK(IsInDataSection(&item));
return reinterpret_cast<uintptr_t>(CodeItemDataAccessor(*this, &item).CodeItemDataEnd()) -
reinterpret_cast<uintptr_t>(&item);
diff --git a/libdexfile/dex/standard_dex_file.h b/libdexfile/dex/standard_dex_file.h
index fd7e78f19f..838d4e3e78 100644
--- a/libdexfile/dex/standard_dex_file.h
+++ b/libdexfile/dex/standard_dex_file.h
@@ -32,7 +32,7 @@ class StandardDexFile : public DexFile {
// Same for now.
};
- struct CodeItem : public DexFile::CodeItem {
+ struct CodeItem : public dex::CodeItem {
static constexpr size_t kAlignment = 4;
private:
@@ -81,7 +81,7 @@ class StandardDexFile : public DexFile {
bool SupportsDefaultMethods() const override;
- uint32_t GetCodeItemSize(const DexFile::CodeItem& item) const override;
+ uint32_t GetCodeItemSize(const dex::CodeItem& item) const override;
size_t GetDequickenedSize() const override {
return Size();
diff --git a/libdexfile/dex/test_dex_file_builder.h b/libdexfile/dex/test_dex_file_builder.h
index 072aafb394..2b0bad0854 100644
--- a/libdexfile/dex/test_dex_file_builder.h
+++ b/libdexfile/dex/test_dex_file_builder.h
@@ -112,7 +112,7 @@ class TestDexFileBuilder {
header->string_ids_size_ = strings_.size();
header->string_ids_off_ = strings_.empty() ? 0u : string_ids_offset;
- uint32_t type_ids_offset = string_ids_offset + strings_.size() * sizeof(DexFile::StringId);
+ uint32_t type_ids_offset = string_ids_offset + strings_.size() * sizeof(dex::StringId);
uint32_t type_idx = 0u;
for (auto& entry : types_) {
entry.second = type_idx;
@@ -121,7 +121,7 @@ class TestDexFileBuilder {
header->type_ids_size_ = types_.size();
header->type_ids_off_ = types_.empty() ? 0u : type_ids_offset;
- uint32_t proto_ids_offset = type_ids_offset + types_.size() * sizeof(DexFile::TypeId);
+ uint32_t proto_ids_offset = type_ids_offset + types_.size() * sizeof(dex::TypeId);
uint32_t proto_idx = 0u;
for (auto& entry : protos_) {
entry.second.idx = proto_idx;
@@ -129,7 +129,7 @@ class TestDexFileBuilder {
size_t num_args = entry.first.args.size();
if (num_args != 0u) {
entry.second.data_offset = RoundUp(data_section_size, 4u);
- data_section_size = entry.second.data_offset + 4u + num_args * sizeof(DexFile::TypeItem);
+ data_section_size = entry.second.data_offset + 4u + num_args * sizeof(dex::TypeItem);
} else {
entry.second.data_offset = 0u;
}
@@ -137,7 +137,7 @@ class TestDexFileBuilder {
header->proto_ids_size_ = protos_.size();
header->proto_ids_off_ = protos_.empty() ? 0u : proto_ids_offset;
- uint32_t field_ids_offset = proto_ids_offset + protos_.size() * sizeof(DexFile::ProtoId);
+ uint32_t field_ids_offset = proto_ids_offset + protos_.size() * sizeof(dex::ProtoId);
uint32_t field_idx = 0u;
for (auto& entry : fields_) {
entry.second = field_idx;
@@ -146,7 +146,7 @@ class TestDexFileBuilder {
header->field_ids_size_ = fields_.size();
header->field_ids_off_ = fields_.empty() ? 0u : field_ids_offset;
- uint32_t method_ids_offset = field_ids_offset + fields_.size() * sizeof(DexFile::FieldId);
+ uint32_t method_ids_offset = field_ids_offset + fields_.size() * sizeof(dex::FieldId);
uint32_t method_idx = 0u;
for (auto& entry : methods_) {
entry.second = method_idx;
@@ -159,7 +159,7 @@ class TestDexFileBuilder {
header->class_defs_size_ = 0u;
header->class_defs_off_ = 0u;
- uint32_t data_section_offset = method_ids_offset + methods_.size() * sizeof(DexFile::MethodId);
+ uint32_t data_section_offset = method_ids_offset + methods_.size() * sizeof(dex::MethodId);
header->data_size_ = data_section_size;
header->data_off_ = (data_section_size != 0u) ? data_section_offset : 0u;
@@ -172,11 +172,11 @@ class TestDexFileBuilder {
uint32_t raw_offset = data_section_offset + entry.second.data_offset;
dex_file_data_[raw_offset] = static_cast<uint8_t>(entry.first.size());
std::memcpy(&dex_file_data_[raw_offset + 1], entry.first.c_str(), entry.first.size() + 1);
- Write32(string_ids_offset + entry.second.idx * sizeof(DexFile::StringId), raw_offset);
+ Write32(string_ids_offset + entry.second.idx * sizeof(dex::StringId), raw_offset);
}
for (const auto& entry : types_) {
- Write32(type_ids_offset + entry.second * sizeof(DexFile::TypeId), GetStringIdx(entry.first));
+ Write32(type_ids_offset + entry.second * sizeof(dex::TypeId), GetStringIdx(entry.first));
++type_idx;
}
@@ -184,7 +184,7 @@ class TestDexFileBuilder {
size_t num_args = entry.first.args.size();
uint32_t type_list_offset =
(num_args != 0u) ? data_section_offset + entry.second.data_offset : 0u;
- uint32_t raw_offset = proto_ids_offset + entry.second.idx * sizeof(DexFile::ProtoId);
+ uint32_t raw_offset = proto_ids_offset + entry.second.idx * sizeof(dex::ProtoId);
Write32(raw_offset + 0u, GetStringIdx(entry.first.shorty));
Write16(raw_offset + 4u, GetTypeIdx(entry.first.return_type));
Write32(raw_offset + 8u, type_list_offset);
@@ -192,21 +192,21 @@ class TestDexFileBuilder {
CHECK_NE(entry.second.data_offset, 0u);
Write32(type_list_offset, num_args);
for (size_t i = 0; i != num_args; ++i) {
- Write16(type_list_offset + 4u + i * sizeof(DexFile::TypeItem),
+ Write16(type_list_offset + 4u + i * sizeof(dex::TypeItem),
GetTypeIdx(entry.first.args[i]));
}
}
}
for (const auto& entry : fields_) {
- uint32_t raw_offset = field_ids_offset + entry.second * sizeof(DexFile::FieldId);
+ uint32_t raw_offset = field_ids_offset + entry.second * sizeof(dex::FieldId);
Write16(raw_offset + 0u, GetTypeIdx(entry.first.class_descriptor));
Write16(raw_offset + 2u, GetTypeIdx(entry.first.type));
Write32(raw_offset + 4u, GetStringIdx(entry.first.name));
}
for (const auto& entry : methods_) {
- uint32_t raw_offset = method_ids_offset + entry.second * sizeof(DexFile::MethodId);
+ uint32_t raw_offset = method_ids_offset + entry.second * sizeof(dex::MethodId);
Write16(raw_offset + 0u, GetTypeIdx(entry.first.class_descriptor));
auto it = protos_.find(*entry.first.proto);
CHECK(it != protos_.end());
diff --git a/libdexfile/dex/type_lookup_table.cc b/libdexfile/dex/type_lookup_table.cc
index 7d80a2e7f7..c46b488cd8 100644
--- a/libdexfile/dex/type_lookup_table.cc
+++ b/libdexfile/dex/type_lookup_table.cc
@@ -47,9 +47,9 @@ TypeLookupTable TypeLookupTable::Create(const DexFile& dex_file) {
// occupied then delay the insertion of the element to the second stage to reduce probing
// distance.
for (size_t class_def_idx = 0; class_def_idx < dex_file.NumClassDefs(); ++class_def_idx) {
- const DexFile::ClassDef& class_def = dex_file.GetClassDef(class_def_idx);
- const DexFile::TypeId& type_id = dex_file.GetTypeId(class_def.class_idx_);
- const DexFile::StringId& str_id = dex_file.GetStringId(type_id.descriptor_idx_);
+ const dex::ClassDef& class_def = dex_file.GetClassDef(class_def_idx);
+ const dex::TypeId& type_id = dex_file.GetTypeId(class_def.class_idx_);
+ const dex::StringId& str_id = dex_file.GetStringId(type_id.descriptor_idx_);
const uint32_t hash = ComputeModifiedUtf8Hash(dex_file.GetStringData(str_id));
const uint32_t pos = hash & mask;
if (entries[pos].IsEmpty()) {
@@ -62,9 +62,9 @@ TypeLookupTable TypeLookupTable::Create(const DexFile& dex_file) {
// The second stage. The initial position of these elements had a collision. Put these elements
// into the nearest free cells and link them together by updating next_pos_delta.
for (uint16_t class_def_idx : conflict_class_defs) {
- const DexFile::ClassDef& class_def = dex_file.GetClassDef(class_def_idx);
- const DexFile::TypeId& type_id = dex_file.GetTypeId(class_def.class_idx_);
- const DexFile::StringId& str_id = dex_file.GetStringId(type_id.descriptor_idx_);
+ const dex::ClassDef& class_def = dex_file.GetClassDef(class_def_idx);
+ const dex::TypeId& type_id = dex_file.GetTypeId(class_def.class_idx_);
+ const dex::StringId& str_id = dex_file.GetStringId(type_id.descriptor_idx_);
const uint32_t hash = ComputeModifiedUtf8Hash(dex_file.GetStringData(str_id));
// Find the last entry in the chain.
uint32_t tail_pos = hash & mask;
diff --git a/libprofile/profile/profile_compilation_info.cc b/libprofile/profile/profile_compilation_info.cc
index 9b32b9e415..8b8569d636 100644
--- a/libprofile/profile/profile_compilation_info.cc
+++ b/libprofile/profile/profile_compilation_info.cc
@@ -2198,7 +2198,7 @@ HashSet<std::string> ProfileCompilationInfo::GetClassDescriptors(
<< type_idx.index_ << " in dex " << dex_file->GetLocation();
return HashSet<std::string>();
}
- const DexFile::TypeId& type_id = dex_file->GetTypeId(type_idx);
+ const dex::TypeId& type_id = dex_file->GetTypeId(type_idx);
ret.insert(dex_file->GetTypeDescriptor(type_id));
}
} else {
diff --git a/oatdump/oatdump.cc b/oatdump/oatdump.cc
index d2a5bb87f8..4e1276ef72 100644
--- a/oatdump/oatdump.cc
+++ b/oatdump/oatdump.cc
@@ -296,7 +296,7 @@ class OatSymbolizer final {
const DexFile& dex_file,
uint32_t class_def_index,
uint32_t dex_method_index,
- const DexFile::CodeItem* code_item,
+ const dex::CodeItem* code_item,
uint32_t method_access_flags) {
if ((method_access_flags & kAccAbstract) != 0) {
// Abstract method, no code.
@@ -723,7 +723,7 @@ class OatDumper {
<< "': " << error_msg;
} else {
const char* descriptor = m->GetDeclaringClassDescriptor();
- const DexFile::ClassDef* class_def =
+ const dex::ClassDef* class_def =
OatDexFile::FindClassDef(*dex_file, descriptor, ComputeModifiedUtf8Hash(descriptor));
if (class_def != nullptr) {
uint16_t class_def_index = dex_file->GetIndexForClassDef(*class_def);
@@ -1092,12 +1092,12 @@ class OatDumper {
static constexpr uint32_t kMaxCodeSize = 100 * 1000;
bool DumpOatMethod(VariableIndentationOutputStream* vios,
- const DexFile::ClassDef& class_def,
+ const dex::ClassDef& class_def,
uint32_t class_method_index,
const OatFile::OatClass& oat_class,
const DexFile& dex_file,
uint32_t dex_method_idx,
- const DexFile::CodeItem* code_item,
+ const dex::CodeItem* code_item,
uint32_t method_access_flags,
bool* addr_found) {
bool success = true;
@@ -1490,8 +1490,8 @@ class OatDumper {
StackHandleScope<1>* hs,
uint32_t dex_method_idx,
const DexFile* dex_file,
- const DexFile::ClassDef& class_def,
- const DexFile::CodeItem* code_item,
+ const dex::ClassDef& class_def,
+ const dex::CodeItem* code_item,
uint32_t method_access_flags) {
if ((method_access_flags & kAccNative) == 0) {
ScopedObjectAccess soa(Thread::Current());
@@ -3007,7 +3007,7 @@ class IMTDumper {
for (uint32_t class_def_index = 0;
class_def_index != dex_file->NumClassDefs();
++class_def_index) {
- const DexFile::ClassDef& class_def = dex_file->GetClassDef(class_def_index);
+ const dex::ClassDef& class_def = dex_file->GetClassDef(class_def_index);
const char* descriptor = dex_file->GetClassDescriptor(class_def);
h_klass.Assign(class_linker->FindClass(self, descriptor, h_class_loader));
if (h_klass == nullptr) {
diff --git a/openjdkjvmti/ti_class.cc b/openjdkjvmti/ti_class.cc
index 0c07f56a07..a8e220cc21 100644
--- a/openjdkjvmti/ti_class.cc
+++ b/openjdkjvmti/ti_class.cc
@@ -162,9 +162,9 @@ struct ClassCallback : public art::ClassLoadCallback {
art::Handle<art::mirror::Class> klass,
art::Handle<art::mirror::ClassLoader> class_loader,
const art::DexFile& initial_dex_file,
- const art::DexFile::ClassDef& initial_class_def ATTRIBUTE_UNUSED,
+ const art::dex::ClassDef& initial_class_def ATTRIBUTE_UNUSED,
/*out*/art::DexFile const** final_dex_file,
- /*out*/art::DexFile::ClassDef const** final_class_def)
+ /*out*/art::dex::ClassDef const** final_class_def)
override REQUIRES_SHARED(art::Locks::mutator_lock_) {
bool is_enabled =
event_handler->IsEventEnabledAnywhere(ArtJvmtiEvent::kClassFileLoadHookRetransformable) ||
diff --git a/openjdkjvmti/ti_redefine.cc b/openjdkjvmti/ti_redefine.cc
index 6ca4e3846c..365530072d 100644
--- a/openjdkjvmti/ti_redefine.cc
+++ b/openjdkjvmti/ti_redefine.cc
@@ -629,7 +629,7 @@ bool Redefiner::ClassRedefinition::CheckSameMethods() {
// and removals. We should have already checked the fields.
for (const art::ClassAccessor::Method& method : accessor.GetMethods()) {
// Get the data on the method we are searching for
- const art::DexFile::MethodId& new_method_id = dex_file_->GetMethodId(method.GetIndex());
+ const art::dex::MethodId& new_method_id = dex_file_->GetMethodId(method.GetIndex());
const char* new_method_name = dex_file_->GetMethodName(new_method_id);
art::Signature new_method_signature = dex_file_->GetMethodSignature(new_method_id);
art::ArtMethod* old_method = FindMethod(h_klass, new_method_name, new_method_signature);
@@ -672,7 +672,7 @@ bool Redefiner::ClassRedefinition::CheckSameFields() {
auto old_iter = old_fields.begin();
for (const art::ClassAccessor::Field& new_field : new_accessor.GetFields()) {
// Get the data on the method we are searching for
- const art::DexFile::FieldId& new_field_id = dex_file_->GetFieldId(new_field.GetIndex());
+ const art::dex::FieldId& new_field_id = dex_file_->GetFieldId(new_field.GetIndex());
const char* new_field_name = dex_file_->GetFieldName(new_field_id);
const char* new_field_type = dex_file_->GetFieldTypeDescriptor(new_field_id);
@@ -685,7 +685,7 @@ bool Redefiner::ClassRedefinition::CheckSameFields() {
return false;
}
- const art::DexFile::FieldId& old_field_id = old_dex_file.GetFieldId(old_iter->GetIndex());
+ const art::dex::FieldId& old_field_id = old_dex_file.GetFieldId(old_iter->GetIndex());
const char* old_field_name = old_dex_file.GetFieldName(old_field_id);
const char* old_field_type = old_dex_file.GetFieldTypeDescriptor(old_field_id);
@@ -736,7 +736,7 @@ bool Redefiner::ClassRedefinition::CheckClass() {
}
// Get the ClassDef from the new DexFile.
// Since the dex file has only a single class def the index is always 0.
- const art::DexFile::ClassDef& def = dex_file_->GetClassDef(0);
+ const art::dex::ClassDef& def = dex_file_->GetClassDef(0);
// Get the class as it is now.
art::Handle<art::mirror::Class> current_class(hs.NewHandle(GetMirrorClass()));
@@ -773,7 +773,7 @@ bool Redefiner::ClassRedefinition::CheckClass() {
return false;
}
}
- const art::DexFile::TypeList* interfaces = dex_file_->GetInterfacesList(def);
+ const art::dex::TypeList* interfaces = dex_file_->GetInterfacesList(def);
if (interfaces == nullptr) {
if (current_class->NumDirectInterfaces() != 0) {
RecordFailure(ERR(UNSUPPORTED_REDEFINITION_HIERARCHY_CHANGED), "Interfaces added");
@@ -781,7 +781,7 @@ bool Redefiner::ClassRedefinition::CheckClass() {
}
} else {
DCHECK(!current_class->IsProxyClass());
- const art::DexFile::TypeList* current_interfaces = current_class->GetInterfaceTypeList();
+ const art::dex::TypeList* current_interfaces = current_class->GetInterfaceTypeList();
if (current_interfaces == nullptr || current_interfaces->Size() != interfaces->Size()) {
RecordFailure(ERR(UNSUPPORTED_REDEFINITION_HIERARCHY_CHANGED), "Interfaces added or removed");
return false;
@@ -1394,14 +1394,14 @@ jvmtiError Redefiner::Run() {
}
void Redefiner::ClassRedefinition::UpdateMethods(art::ObjPtr<art::mirror::Class> mclass,
- const art::DexFile::ClassDef& class_def) {
+ const art::dex::ClassDef& class_def) {
art::ClassLinker* linker = driver_->runtime_->GetClassLinker();
art::PointerSize image_pointer_size = linker->GetImagePointerSize();
- const art::DexFile::TypeId& declaring_class_id = dex_file_->GetTypeId(class_def.class_idx_);
+ const art::dex::TypeId& declaring_class_id = dex_file_->GetTypeId(class_def.class_idx_);
const art::DexFile& old_dex_file = mclass->GetDexFile();
// Update methods.
for (art::ArtMethod& method : mclass->GetDeclaredMethods(image_pointer_size)) {
- const art::DexFile::StringId* new_name_id = dex_file_->FindStringId(method.GetName());
+ const art::dex::StringId* new_name_id = dex_file_->FindStringId(method.GetName());
art::dex::TypeIndex method_return_idx =
dex_file_->GetIndexForTypeId(*dex_file_->FindTypeId(method.GetReturnTypeDescriptor()));
const auto* old_type_list = method.GetParameterTypeList();
@@ -1414,12 +1414,11 @@ void Redefiner::ClassRedefinition::UpdateMethods(art::ObjPtr<art::mirror::Class>
old_dex_file.GetTypeId(
old_type_list->GetTypeItem(i).type_idx_)))));
}
- const art::DexFile::ProtoId* proto_id = dex_file_->FindProtoId(method_return_idx,
- new_type_list);
+ const art::dex::ProtoId* proto_id = dex_file_->FindProtoId(method_return_idx, new_type_list);
CHECK(proto_id != nullptr || old_type_list == nullptr);
- const art::DexFile::MethodId* method_id = dex_file_->FindMethodId(declaring_class_id,
- *new_name_id,
- *proto_id);
+ const art::dex::MethodId* method_id = dex_file_->FindMethodId(declaring_class_id,
+ *new_name_id,
+ *proto_id);
CHECK(method_id != nullptr);
uint32_t dex_method_idx = dex_file_->GetIndexForMethodId(*method_id);
method.SetDexMethodIndex(dex_method_idx);
@@ -1435,12 +1434,12 @@ void Redefiner::ClassRedefinition::UpdateFields(art::ObjPtr<art::mirror::Class>
for (auto fields_iter : {mclass->GetIFields(), mclass->GetSFields()}) {
for (art::ArtField& field : fields_iter) {
std::string declaring_class_name;
- const art::DexFile::TypeId* new_declaring_id =
+ const art::dex::TypeId* new_declaring_id =
dex_file_->FindTypeId(field.GetDeclaringClass()->GetDescriptor(&declaring_class_name));
- const art::DexFile::StringId* new_name_id = dex_file_->FindStringId(field.GetName());
- const art::DexFile::TypeId* new_type_id = dex_file_->FindTypeId(field.GetTypeDescriptor());
+ const art::dex::StringId* new_name_id = dex_file_->FindStringId(field.GetName());
+ const art::dex::TypeId* new_type_id = dex_file_->FindTypeId(field.GetTypeDescriptor());
CHECK(new_name_id != nullptr && new_type_id != nullptr && new_declaring_id != nullptr);
- const art::DexFile::FieldId* new_field_id =
+ const art::dex::FieldId* new_field_id =
dex_file_->FindFieldId(*new_declaring_id, *new_name_id, *new_type_id);
CHECK(new_field_id != nullptr);
// We only need to update the index since the other data in the ArtField cannot be updated.
@@ -1455,7 +1454,7 @@ void Redefiner::ClassRedefinition::UpdateClass(
art::ObjPtr<art::mirror::DexCache> new_dex_cache,
art::ObjPtr<art::mirror::Object> original_dex_file) {
DCHECK_EQ(dex_file_->NumClassDefs(), 1u);
- const art::DexFile::ClassDef& class_def = dex_file_->GetClassDef(0);
+ const art::dex::ClassDef& class_def = dex_file_->GetClassDef(0);
UpdateMethods(mclass, class_def);
UpdateFields(mclass);
diff --git a/openjdkjvmti/ti_redefine.h b/openjdkjvmti/ti_redefine.h
index f4a4280aac..a974dc177f 100644
--- a/openjdkjvmti/ti_redefine.h
+++ b/openjdkjvmti/ti_redefine.h
@@ -39,13 +39,19 @@
#include "art_jvmti.h"
#include "base/array_ref.h"
#include "base/globals.h"
-#include "dex/dex_file.h"
#include "jni/jni_env_ext-inl.h"
#include "jvmti.h"
#include "mirror/array.h"
#include "mirror/class.h"
#include "obj_ptr.h"
+namespace art {
+namespace dex {
+struct ClassDef;
+} // namespace dex
+class DexFile;
+} // namespace art
+
namespace openjdkjvmti {
class ArtClassDefinition;
@@ -172,7 +178,7 @@ class Redefiner {
REQUIRES(art::Locks::mutator_lock_);
void UpdateMethods(art::ObjPtr<art::mirror::Class> mclass,
- const art::DexFile::ClassDef& class_def)
+ const art::dex::ClassDef& class_def)
REQUIRES(art::Locks::mutator_lock_);
void UpdateClass(art::ObjPtr<art::mirror::Class> mclass,
diff --git a/profman/profman.cc b/profman/profman.cc
index a0c387db88..88c5c4e5ad 100644
--- a/profman/profman.cc
+++ b/profman/profman.cc
@@ -615,14 +615,14 @@ class ProfMan final {
&startup_methods,
&post_startup_methods)) {
for (const dex::TypeIndex& type_index : class_types) {
- const DexFile::TypeId& type_id = dex_file->GetTypeId(type_index);
+ const dex::TypeId& type_id = dex_file->GetTypeId(type_index);
out_lines->insert(std::string(dex_file->GetTypeDescriptor(type_id)));
}
combined_methods = hot_methods;
combined_methods.insert(startup_methods.begin(), startup_methods.end());
combined_methods.insert(post_startup_methods.begin(), post_startup_methods.end());
for (uint16_t dex_method_idx : combined_methods) {
- const DexFile::MethodId& id = dex_file->GetMethodId(dex_method_idx);
+ const dex::MethodId& id = dex_file->GetMethodId(dex_method_idx);
std::string signature_string(dex_file->GetMethodSignature(id).ToString());
std::string type_string(dex_file->GetTypeDescriptor(dex_file->GetTypeId(id.class_idx_)));
std::string method_name(dex_file->GetMethodName(id));
@@ -782,7 +782,7 @@ class ProfMan final {
}
}
- const DexFile::TypeId* type_id = dex_file->FindTypeId(klass_descriptor.c_str());
+ const dex::TypeId* type_id = dex_file->FindTypeId(klass_descriptor.c_str());
if (type_id == nullptr) {
continue;
}
@@ -818,7 +818,7 @@ class ProfMan final {
const std::string& name = name_and_signature[0];
const std::string& signature = kProfileParsingFirstCharInSignature + name_and_signature[1];
- const DexFile::StringId* name_id = dex_file->FindStringId(name.c_str());
+ const dex::StringId* name_id = dex_file->FindStringId(name.c_str());
if (name_id == nullptr) {
LOG(WARNING) << "Could not find name: " << name;
return dex::kDexNoIndex;
@@ -829,12 +829,12 @@ class ProfMan final {
LOG(WARNING) << "Could not create type list" << signature;
return dex::kDexNoIndex;
}
- const DexFile::ProtoId* proto_id = dex_file->FindProtoId(return_type_idx, param_type_idxs);
+ const dex::ProtoId* proto_id = dex_file->FindProtoId(return_type_idx, param_type_idxs);
if (proto_id == nullptr) {
LOG(WARNING) << "Could not find proto_id: " << name;
return dex::kDexNoIndex;
}
- const DexFile::MethodId* method_id = dex_file->FindMethodId(
+ const dex::MethodId* method_id = dex_file->FindMethodId(
dex_file->GetTypeId(class_ref.TypeIndex()), *name_id, *proto_id);
if (method_id == nullptr) {
LOG(WARNING) << "Could not find method_id: " << name;
@@ -857,7 +857,7 @@ class ProfMan final {
uint32_t offset = dex_file->FindCodeItemOffset(
*dex_file->FindClassDef(class_ref.TypeIndex()),
method_index);
- const DexFile::CodeItem* code_item = dex_file->GetCodeItem(offset);
+ const dex::CodeItem* code_item = dex_file->GetCodeItem(offset);
bool found_invoke = false;
for (const DexInstructionPcPair& inst : CodeItemInstructionAccessor(*dex_file, code_item)) {
diff --git a/runtime/art_field-inl.h b/runtime/art_field-inl.h
index 53e4c11511..fb4141886a 100644
--- a/runtime/art_field-inl.h
+++ b/runtime/art_field-inl.h
@@ -291,7 +291,7 @@ inline const char* ArtField::GetTypeDescriptor() REQUIRES_SHARED(Locks::mutator_
return field_index == 0 ? "[Ljava/lang/Class;" : "[[Ljava/lang/Class;";
}
const DexFile* dex_file = GetDexFile();
- const DexFile::FieldId& field_id = dex_file->GetFieldId(field_index);
+ const dex::FieldId& field_id = dex_file->GetFieldId(field_index);
return dex_file->GetFieldTypeDescriptor(field_id);
}
@@ -342,7 +342,7 @@ inline const DexFile* ArtField::GetDexFile() REQUIRES_SHARED(Locks::mutator_lock
inline ObjPtr<mirror::String> ArtField::ResolveNameString() {
uint32_t dex_field_index = GetDexFieldIndex();
CHECK_NE(dex_field_index, dex::kDexNoIndex);
- const DexFile::FieldId& field_id = GetDexFile()->GetFieldId(dex_field_index);
+ const dex::FieldId& field_id = GetDexFile()->GetFieldId(dex_field_index);
return Runtime::Current()->GetClassLinker()->ResolveString(field_id.name_idx_, this);
}
diff --git a/runtime/art_method-inl.h b/runtime/art_method-inl.h
index fda269c31d..02196baebd 100644
--- a/runtime/art_method-inl.h
+++ b/runtime/art_method-inl.h
@@ -224,11 +224,11 @@ inline const char* ArtMethod::GetName() {
inline ObjPtr<mirror::String> ArtMethod::ResolveNameString() {
DCHECK(!IsProxyMethod());
- const DexFile::MethodId& method_id = GetDexFile()->GetMethodId(GetDexMethodIndex());
+ const dex::MethodId& method_id = GetDexFile()->GetMethodId(GetDexMethodIndex());
return Runtime::Current()->GetClassLinker()->ResolveString(method_id.name_idx_, this);
}
-inline const DexFile::CodeItem* ArtMethod::GetCodeItem() {
+inline const dex::CodeItem* ArtMethod::GetCodeItem() {
return GetDexFile()->GetCodeItem(GetCodeItemOffset());
}
@@ -245,16 +245,16 @@ inline int32_t ArtMethod::GetLineNumFromDexPC(uint32_t dex_pc) {
return annotations::GetLineNumFromPC(GetDexFile(), this, dex_pc);
}
-inline const DexFile::ProtoId& ArtMethod::GetPrototype() {
+inline const dex::ProtoId& ArtMethod::GetPrototype() {
DCHECK(!IsProxyMethod());
const DexFile* dex_file = GetDexFile();
return dex_file->GetMethodPrototype(dex_file->GetMethodId(GetDexMethodIndex()));
}
-inline const DexFile::TypeList* ArtMethod::GetParameterTypeList() {
+inline const dex::TypeList* ArtMethod::GetParameterTypeList() {
DCHECK(!IsProxyMethod());
const DexFile* dex_file = GetDexFile();
- const DexFile::ProtoId& proto = dex_file->GetMethodPrototype(
+ const dex::ProtoId& proto = dex_file->GetMethodPrototype(
dex_file->GetMethodId(GetDexMethodIndex()));
return dex_file->GetProtoParameters(proto);
}
@@ -273,7 +273,7 @@ inline uint16_t ArtMethod::GetClassDefIndex() {
}
}
-inline const DexFile::ClassDef& ArtMethod::GetClassDef() {
+inline const dex::ClassDef& ArtMethod::GetClassDef() {
DCHECK(!IsProxyMethod());
return GetDexFile()->GetClassDef(GetClassDefIndex());
}
@@ -344,8 +344,8 @@ inline ArtMethod* ArtMethod::GetInterfaceMethodIfProxy(PointerSize pointer_size)
inline dex::TypeIndex ArtMethod::GetReturnTypeIndex() {
DCHECK(!IsProxyMethod());
const DexFile* dex_file = GetDexFile();
- const DexFile::MethodId& method_id = dex_file->GetMethodId(GetDexMethodIndex());
- const DexFile::ProtoId& proto_id = dex_file->GetMethodPrototype(method_id);
+ const dex::MethodId& method_id = dex_file->GetMethodId(GetDexMethodIndex());
+ const dex::ProtoId& proto_id = dex_file->GetMethodPrototype(method_id);
return proto_id.return_type_idx_;
}
diff --git a/runtime/art_method.cc b/runtime/art_method.cc
index 5f5361aed8..dd5b0d5492 100644
--- a/runtime/art_method.cc
+++ b/runtime/art_method.cc
@@ -133,7 +133,7 @@ uint16_t ArtMethod::FindObsoleteDexClassDefIndex() {
DCHECK(IsObsolete());
const DexFile* dex_file = GetDexFile();
const dex::TypeIndex declaring_class_type = dex_file->GetMethodId(GetDexMethodIndex()).class_idx_;
- const DexFile::ClassDef* class_def = dex_file->FindClassDef(declaring_class_type);
+ const dex::ClassDef* class_def = dex_file->FindClassDef(declaring_class_type);
CHECK(class_def != nullptr);
return dex_file->GetIndexForClassDef(*class_def);
}
@@ -182,13 +182,13 @@ size_t ArtMethod::NumArgRegisters(const StringPiece& shorty) {
bool ArtMethod::HasSameNameAndSignature(ArtMethod* other) {
ScopedAssertNoThreadSuspension ants("HasSameNameAndSignature");
const DexFile* dex_file = GetDexFile();
- const DexFile::MethodId& mid = dex_file->GetMethodId(GetDexMethodIndex());
+ const dex::MethodId& mid = dex_file->GetMethodId(GetDexMethodIndex());
if (GetDexCache() == other->GetDexCache()) {
- const DexFile::MethodId& mid2 = dex_file->GetMethodId(other->GetDexMethodIndex());
+ const dex::MethodId& mid2 = dex_file->GetMethodId(other->GetDexMethodIndex());
return mid.name_idx_ == mid2.name_idx_ && mid.proto_idx_ == mid2.proto_idx_;
}
const DexFile* dex_file2 = other->GetDexFile();
- const DexFile::MethodId& mid2 = dex_file2->GetMethodId(other->GetDexMethodIndex());
+ const dex::MethodId& mid2 = dex_file2->GetMethodId(other->GetDexMethodIndex());
if (!DexFileStringEquals(dex_file, mid.name_idx_, dex_file2, mid2.name_idx_)) {
return false; // Name mismatch.
}
@@ -235,17 +235,17 @@ uint32_t ArtMethod::FindDexMethodIndexInOtherDexFile(const DexFile& other_dexfil
uint32_t name_and_signature_idx) {
const DexFile* dexfile = GetDexFile();
const uint32_t dex_method_idx = GetDexMethodIndex();
- const DexFile::MethodId& mid = dexfile->GetMethodId(dex_method_idx);
- const DexFile::MethodId& name_and_sig_mid = other_dexfile.GetMethodId(name_and_signature_idx);
+ const dex::MethodId& mid = dexfile->GetMethodId(dex_method_idx);
+ const dex::MethodId& name_and_sig_mid = other_dexfile.GetMethodId(name_and_signature_idx);
DCHECK_STREQ(dexfile->GetMethodName(mid), other_dexfile.GetMethodName(name_and_sig_mid));
DCHECK_EQ(dexfile->GetMethodSignature(mid), other_dexfile.GetMethodSignature(name_and_sig_mid));
if (dexfile == &other_dexfile) {
return dex_method_idx;
}
const char* mid_declaring_class_descriptor = dexfile->StringByTypeIdx(mid.class_idx_);
- const DexFile::TypeId* other_type_id = other_dexfile.FindTypeId(mid_declaring_class_descriptor);
+ const dex::TypeId* other_type_id = other_dexfile.FindTypeId(mid_declaring_class_descriptor);
if (other_type_id != nullptr) {
- const DexFile::MethodId* other_mid = other_dexfile.FindMethodId(
+ const dex::MethodId* other_mid = other_dexfile.FindMethodId(
*other_type_id, other_dexfile.GetStringId(name_and_sig_mid.name_idx_),
other_dexfile.GetProtoId(name_and_sig_mid.proto_idx_));
if (other_mid != nullptr) {
@@ -447,11 +447,11 @@ static const OatFile::OatMethod FindOatMethodFromDexFileFor(ArtMethod* method, b
// recreate the class_def_index from the descriptor.
std::string descriptor_storage;
- const DexFile::TypeId* declaring_class_type_id =
+ const dex::TypeId* declaring_class_type_id =
dex_file->FindTypeId(method->GetDeclaringClass()->GetDescriptor(&descriptor_storage));
CHECK(declaring_class_type_id != nullptr);
dex::TypeIndex declaring_class_type_index = dex_file->GetIndexForTypeId(*declaring_class_type_id);
- const DexFile::ClassDef* declaring_class_type_def =
+ const dex::ClassDef* declaring_class_type_def =
dex_file->FindClassDef(declaring_class_type_index);
CHECK(declaring_class_type_def != nullptr);
uint16_t declaring_class_def_index = dex_file->GetIndexForClassDef(*declaring_class_type_def);
@@ -522,7 +522,7 @@ bool ArtMethod::EqualParameters(Handle<mirror::ObjectArray<mirror::Class>> param
auto* dex_file = dex_cache->GetDexFile();
const auto& method_id = dex_file->GetMethodId(GetDexMethodIndex());
const auto& proto_id = dex_file->GetMethodPrototype(method_id);
- const DexFile::TypeList* proto_params = dex_file->GetProtoParameters(proto_id);
+ const dex::TypeList* proto_params = dex_file->GetProtoParameters(proto_id);
auto count = proto_params != nullptr ? proto_params->Size() : 0u;
auto param_len = params != nullptr ? params->GetLength() : 0u;
if (param_len != count) {
diff --git a/runtime/art_method.h b/runtime/art_method.h
index cc214f7ca3..6b598da6b3 100644
--- a/runtime/art_method.h
+++ b/runtime/art_method.h
@@ -29,7 +29,7 @@
#include "base/macros.h"
#include "base/runtime_debug.h"
#include "dex/code_item_accessors.h"
-#include "dex/dex_file.h"
+#include "dex/dex_file_structs.h"
#include "dex/dex_instruction_iterator.h"
#include "dex/modifiers.h"
#include "dex/primitive.h"
@@ -40,6 +40,7 @@
namespace art {
+class DexFile;
template<class T> class Handle;
class ImtConflictTable;
enum InvokeType : uint32_t;
@@ -586,21 +587,21 @@ class ArtMethod final {
ObjPtr<mirror::String> ResolveNameString() REQUIRES_SHARED(Locks::mutator_lock_);
- const DexFile::CodeItem* GetCodeItem() REQUIRES_SHARED(Locks::mutator_lock_);
+ const dex::CodeItem* GetCodeItem() REQUIRES_SHARED(Locks::mutator_lock_);
bool IsResolvedTypeIdx(dex::TypeIndex type_idx) REQUIRES_SHARED(Locks::mutator_lock_);
int32_t GetLineNumFromDexPC(uint32_t dex_pc) REQUIRES_SHARED(Locks::mutator_lock_);
- const DexFile::ProtoId& GetPrototype() REQUIRES_SHARED(Locks::mutator_lock_);
+ const dex::ProtoId& GetPrototype() REQUIRES_SHARED(Locks::mutator_lock_);
- const DexFile::TypeList* GetParameterTypeList() REQUIRES_SHARED(Locks::mutator_lock_);
+ const dex::TypeList* GetParameterTypeList() REQUIRES_SHARED(Locks::mutator_lock_);
const char* GetDeclaringClassSourceFile() REQUIRES_SHARED(Locks::mutator_lock_);
uint16_t GetClassDefIndex() REQUIRES_SHARED(Locks::mutator_lock_);
- const DexFile::ClassDef& GetClassDef() REQUIRES_SHARED(Locks::mutator_lock_);
+ const dex::ClassDef& GetClassDef() REQUIRES_SHARED(Locks::mutator_lock_);
ALWAYS_INLINE size_t GetNumberOfParameters() REQUIRES_SHARED(Locks::mutator_lock_);
diff --git a/runtime/class_linker-inl.h b/runtime/class_linker-inl.h
index 43f3ed36aa..978b1abbaf 100644
--- a/runtime/class_linker-inl.h
+++ b/runtime/class_linker-inl.h
@@ -23,6 +23,8 @@
#include "art_method-inl.h"
#include "base/mutex.h"
#include "class_linker.h"
+#include "dex/dex_file.h"
+#include "dex/dex_file_structs.h"
#include "gc_root-inl.h"
#include "handle_scope-inl.h"
#include "mirror/class_loader.h"
@@ -271,7 +273,7 @@ inline bool ClassLinker::CheckInvokeClassMismatch(ObjPtr<mirror::DexCache> dex_c
dex_cache,
type,
[this, dex_cache, method_idx, class_loader]() REQUIRES_SHARED(Locks::mutator_lock_) {
- const DexFile::MethodId& method_id = dex_cache->GetDexFile()->GetMethodId(method_idx);
+ const dex::MethodId& method_id = dex_cache->GetDexFile()->GetMethodId(method_idx);
ObjPtr<mirror::Class> klass =
LookupResolvedType(method_id.class_idx_, dex_cache, class_loader);
DCHECK(klass != nullptr);
@@ -286,7 +288,7 @@ inline ArtMethod* ClassLinker::LookupResolvedMethod(uint32_t method_idx,
ArtMethod* resolved = dex_cache->GetResolvedMethod(method_idx, pointer_size);
if (resolved == nullptr) {
const DexFile& dex_file = *dex_cache->GetDexFile();
- const DexFile::MethodId& method_id = dex_file.GetMethodId(method_idx);
+ const dex::MethodId& method_id = dex_file.GetMethodId(method_idx);
ObjPtr<mirror::Class> klass = LookupResolvedType(method_id.class_idx_, dex_cache, class_loader);
if (klass != nullptr) {
resolved = FindResolvedMethod(klass, dex_cache, class_loader, method_idx);
diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc
index 3b92e2c658..c22a5cbcd6 100644
--- a/runtime/class_linker.cc
+++ b/runtime/class_linker.cc
@@ -2628,13 +2628,13 @@ ObjPtr<mirror::Class> ClassLinker::EnsureResolved(Thread* self,
return klass;
}
-using ClassPathEntry = std::pair<const DexFile*, const DexFile::ClassDef*>;
+using ClassPathEntry = std::pair<const DexFile*, const dex::ClassDef*>;
// Search a collection of DexFiles for a descriptor
ClassPathEntry FindInClassPath(const char* descriptor,
size_t hash, const std::vector<const DexFile*>& class_path) {
for (const DexFile* dex_file : class_path) {
- const DexFile::ClassDef* dex_class_def = OatDexFile::FindClassDef(*dex_file, descriptor, hash);
+ const dex::ClassDef* dex_class_def = OatDexFile::FindClassDef(*dex_file, descriptor, hash);
if (dex_class_def != nullptr) {
return ClassPathEntry(dex_file, dex_class_def);
}
@@ -2784,8 +2784,7 @@ ObjPtr<mirror::Class> ClassLinker::FindClassInBaseDexClassLoaderClassPath(
ObjPtr<mirror::Class> ret;
auto define_class = [&](const DexFile* cp_dex_file) REQUIRES_SHARED(Locks::mutator_lock_) {
- const DexFile::ClassDef* dex_class_def =
- OatDexFile::FindClassDef(*cp_dex_file, descriptor, hash);
+ const dex::ClassDef* dex_class_def = OatDexFile::FindClassDef(*cp_dex_file, descriptor, hash);
if (dex_class_def != nullptr) {
ObjPtr<mirror::Class> klass = DefineClass(soa.Self(),
descriptor,
@@ -2985,7 +2984,7 @@ ObjPtr<mirror::Class> ClassLinker::DefineClass(Thread* self,
size_t hash,
Handle<mirror::ClassLoader> class_loader,
const DexFile& dex_file,
- const DexFile::ClassDef& dex_class_def) {
+ const dex::ClassDef& dex_class_def) {
StackHandleScope<3> hs(self);
auto klass = hs.NewHandle<mirror::Class>(nullptr);
@@ -3032,7 +3031,7 @@ ObjPtr<mirror::Class> ClassLinker::DefineClass(Thread* self,
// Get the real dex file. This will return the input if there aren't any callbacks or they do
// nothing.
DexFile const* new_dex_file = nullptr;
- DexFile::ClassDef const* new_class_def = nullptr;
+ dex::ClassDef const* new_class_def = nullptr;
// TODO We should ideally figure out some way to move this after we get a lock on the klass so it
// will only be called once.
Runtime::Current()->GetRuntimeCallbacks()->ClassPreDefine(descriptor,
@@ -3153,7 +3152,7 @@ ObjPtr<mirror::Class> ClassLinker::DefineClass(Thread* self,
}
uint32_t ClassLinker::SizeOfClassWithoutEmbeddedTables(const DexFile& dex_file,
- const DexFile::ClassDef& dex_class_def) {
+ const dex::ClassDef& dex_class_def) {
size_t num_ref = 0;
size_t num_8 = 0;
size_t num_16 = 0;
@@ -3171,7 +3170,7 @@ uint32_t ClassLinker::SizeOfClassWithoutEmbeddedTables(const DexFile& dex_file,
continue;
}
last_field_idx = field_idx;
- const DexFile::FieldId& field_id = dex_file.GetFieldId(field_idx);
+ const dex::FieldId& field_id = dex_file.GetFieldId(field_idx);
const char* descriptor = dex_file.GetFieldTypeDescriptor(field_id);
char c = descriptor[0];
switch (c) {
@@ -3400,7 +3399,7 @@ static void LinkCode(ClassLinker* class_linker,
}
void ClassLinker::SetupClass(const DexFile& dex_file,
- const DexFile::ClassDef& dex_class_def,
+ const dex::ClassDef& dex_class_def,
Handle<mirror::Class> klass,
ObjPtr<mirror::ClassLoader> class_loader) {
CHECK(klass != nullptr);
@@ -3481,7 +3480,7 @@ LinearAlloc* ClassLinker::GetOrCreateAllocatorForClassLoader(ObjPtr<mirror::Clas
void ClassLinker::LoadClass(Thread* self,
const DexFile& dex_file,
- const DexFile::ClassDef& dex_class_def,
+ const dex::ClassDef& dex_class_def,
Handle<mirror::Class> klass) {
ClassAccessor accessor(dex_file,
dex_class_def,
@@ -3606,7 +3605,7 @@ void ClassLinker::LoadMethod(const DexFile& dex_file,
Handle<mirror::Class> klass,
ArtMethod* dst) {
const uint32_t dex_method_idx = method.GetIndex();
- const DexFile::MethodId& method_id = dex_file.GetMethodId(dex_method_idx);
+ const dex::MethodId& method_id = dex_file.GetMethodId(dex_method_idx);
const char* method_name = dex_file.StringDataByIdx(method_id.name_idx_);
ScopedAssertNoThreadSuspension ants("LoadMethod");
@@ -4987,7 +4986,7 @@ bool ClassLinker::CanWeInitializeClass(ObjPtr<mirror::Class> klass, bool can_ini
}
// Check if there are encoded static values needing initialization.
if (klass->NumStaticFields() != 0) {
- const DexFile::ClassDef* dex_class_def = klass->GetClassDef();
+ const dex::ClassDef* dex_class_def = klass->GetClassDef();
DCHECK(dex_class_def != nullptr);
if (dex_class_def->static_values_off_ != 0) {
return false;
@@ -5204,7 +5203,7 @@ bool ClassLinker::InitializeClass(Thread* self, Handle<mirror::Class> klass,
const size_t num_static_fields = klass->NumStaticFields();
if (num_static_fields > 0) {
- const DexFile::ClassDef* dex_class_def = klass->GetClassDef();
+ const dex::ClassDef* dex_class_def = klass->GetClassDef();
CHECK(dex_class_def != nullptr);
StackHandleScope<3> hs(self);
Handle<mirror::ClassLoader> class_loader(hs.NewHandle(klass->GetClassLoader()));
@@ -5413,8 +5412,8 @@ static void ThrowSignatureCheckResolveReturnTypeException(Handle<mirror::Class>
DCHECK(Thread::Current()->IsExceptionPending());
DCHECK(!m->IsProxyMethod());
const DexFile* dex_file = m->GetDexFile();
- const DexFile::MethodId& method_id = dex_file->GetMethodId(m->GetDexMethodIndex());
- const DexFile::ProtoId& proto_id = dex_file->GetMethodPrototype(method_id);
+ const dex::MethodId& method_id = dex_file->GetMethodId(m->GetDexMethodIndex());
+ const dex::ProtoId& proto_id = dex_file->GetMethodPrototype(method_id);
dex::TypeIndex return_type_idx = proto_id.return_type_idx_;
std::string return_type = dex_file->PrettyType(return_type_idx);
std::string class_loader = mirror::Object::PrettyTypeOf(m->GetDeclaringClass()->GetClassLoader());
@@ -5492,8 +5491,8 @@ static bool HasSameSignatureWithDifferentClassLoaders(Thread* self,
return false;
}
}
- const DexFile::TypeList* types1 = method1->GetParameterTypeList();
- const DexFile::TypeList* types2 = method2->GetParameterTypeList();
+ const dex::TypeList* types1 = method1->GetParameterTypeList();
+ const dex::TypeList* types2 = method2->GetParameterTypeList();
if (types1 == nullptr) {
if (types2 != nullptr && types2->Size() != 0) {
ThrowSignatureMismatch(klass, super_klass, method1,
@@ -5852,7 +5851,7 @@ bool ClassLinker::LinkClass(Thread* self,
bool ClassLinker::LoadSuperAndInterfaces(Handle<mirror::Class> klass, const DexFile& dex_file) {
CHECK_EQ(ClassStatus::kIdx, klass->GetStatus());
- const DexFile::ClassDef& class_def = dex_file.GetClassDef(klass->GetDexClassDefIndex());
+ const dex::ClassDef& class_def = dex_file.GetClassDef(klass->GetDexClassDefIndex());
dex::TypeIndex super_class_idx = class_def.superclass_idx_;
if (super_class_idx.IsValid()) {
// Check that a class does not inherit from itself directly.
@@ -5883,7 +5882,7 @@ bool ClassLinker::LoadSuperAndInterfaces(Handle<mirror::Class> klass, const DexF
CHECK(super_class->IsResolved());
klass->SetSuperClass(super_class);
}
- const DexFile::TypeList* interfaces = dex_file.GetInterfacesList(class_def);
+ const dex::TypeList* interfaces = dex_file.GetInterfacesList(class_def);
if (interfaces != nullptr) {
for (size_t i = 0; i < interfaces->Size(); i++) {
dex::TypeIndex idx = interfaces->GetTypeItem(i).type_idx_;
@@ -6027,7 +6026,7 @@ class MethodNameAndSignatureComparator final : public ValueObject {
REQUIRES_SHARED(Locks::mutator_lock_) {
DCHECK(!other->IsProxyMethod()) << other->PrettyMethod();
const DexFile* other_dex_file = other->GetDexFile();
- const DexFile::MethodId& other_mid = other_dex_file->GetMethodId(other->GetDexMethodIndex());
+ const dex::MethodId& other_mid = other_dex_file->GetMethodId(other->GetDexMethodIndex());
if (dex_file_ == other_dex_file) {
return mid_->name_idx_ == other_mid.name_idx_ && mid_->proto_idx_ == other_mid.proto_idx_;
}
@@ -6045,7 +6044,7 @@ class MethodNameAndSignatureComparator final : public ValueObject {
// Dex file for the method to compare against.
const DexFile* const dex_file_;
// MethodId for the method to compare against.
- const DexFile::MethodId* const mid_;
+ const dex::MethodId* const mid_;
// Lazily computed name from the dex file's strings.
const char* name_;
// Lazily computed name length.
@@ -8336,7 +8335,7 @@ ArtMethod* ClassLinker::ResolveMethod(uint32_t method_idx,
return resolved;
}
const DexFile& dex_file = *dex_cache->GetDexFile();
- const DexFile::MethodId& method_id = dex_file.GetMethodId(method_idx);
+ const dex::MethodId& method_id = dex_file.GetMethodId(method_idx);
ObjPtr<mirror::Class> klass = nullptr;
if (valid_dex_cache_method) {
// We have a valid method from the DexCache but we need to perform ICCE and IAE checks.
@@ -8417,7 +8416,7 @@ ArtMethod* ClassLinker::ResolveMethodWithoutInvokeType(uint32_t method_idx,
return resolved;
}
// Fail, get the declaring class.
- const DexFile::MethodId& method_id = dex_cache->GetDexFile()->GetMethodId(method_idx);
+ const dex::MethodId& method_id = dex_cache->GetDexFile()->GetMethodId(method_idx);
ObjPtr<mirror::Class> klass = ResolveType(method_id.class_idx_, dex_cache, class_loader);
if (klass == nullptr) {
Thread::Current()->AssertPendingException();
@@ -8443,7 +8442,7 @@ ArtField* ClassLinker::LookupResolvedField(uint32_t field_idx,
ObjPtr<mirror::ClassLoader> class_loader,
bool is_static) {
const DexFile& dex_file = *dex_cache->GetDexFile();
- const DexFile::FieldId& field_id = dex_file.GetFieldId(field_idx);
+ const dex::FieldId& field_id = dex_file.GetFieldId(field_idx);
ObjPtr<mirror::Class> klass = dex_cache->GetResolvedType(field_id.class_idx_);
if (klass == nullptr) {
klass = LookupResolvedType(field_id.class_idx_, dex_cache, class_loader);
@@ -8468,7 +8467,7 @@ ArtField* ClassLinker::ResolveField(uint32_t field_idx,
return resolved;
}
const DexFile& dex_file = *dex_cache->GetDexFile();
- const DexFile::FieldId& field_id = dex_file.GetFieldId(field_idx);
+ const dex::FieldId& field_id = dex_file.GetFieldId(field_idx);
ObjPtr<mirror::Class> klass = ResolveType(field_id.class_idx_, dex_cache, class_loader);
if (klass == nullptr) {
DCHECK(Thread::Current()->IsExceptionPending());
@@ -8494,7 +8493,7 @@ ArtField* ClassLinker::ResolveFieldJLS(uint32_t field_idx,
return resolved;
}
const DexFile& dex_file = *dex_cache->GetDexFile();
- const DexFile::FieldId& field_id = dex_file.GetFieldId(field_idx);
+ const dex::FieldId& field_id = dex_file.GetFieldId(field_idx);
ObjPtr<mirror::Class> klass = ResolveType(field_id.class_idx_, dex_cache, class_loader);
if (klass == nullptr) {
DCHECK(Thread::Current()->IsExceptionPending());
@@ -8523,7 +8522,7 @@ ArtField* ClassLinker::FindResolvedField(ObjPtr<mirror::Class> klass,
: klass->FindInstanceField(dex_cache, field_idx);
if (resolved == nullptr) {
- const DexFile::FieldId& field_id = dex_file.GetFieldId(field_idx);
+ const dex::FieldId& field_id = dex_file.GetFieldId(field_idx);
const char* name = dex_file.GetFieldName(field_id);
const char* type = dex_file.GetFieldTypeDescriptor(field_id);
resolved = is_static ? mirror::Class::FindStaticField(self, klass, name, type)
@@ -8551,7 +8550,7 @@ ArtField* ClassLinker::FindResolvedFieldJLS(ObjPtr<mirror::Class> klass,
ArtField* resolved = nullptr;
Thread* self = Thread::Current();
const DexFile& dex_file = *dex_cache->GetDexFile();
- const DexFile::FieldId& field_id = dex_file.GetFieldId(field_idx);
+ const dex::FieldId& field_id = dex_file.GetFieldId(field_idx);
const char* name = dex_file.GetFieldName(field_id);
const char* type = dex_file.GetFieldTypeDescriptor(field_id);
@@ -8588,7 +8587,7 @@ ObjPtr<mirror::MethodType> ClassLinker::ResolveMethodType(
// First resolve the return type.
const DexFile& dex_file = *dex_cache->GetDexFile();
- const DexFile::ProtoId& proto_id = dex_file.GetProtoId(proto_idx);
+ const dex::ProtoId& proto_id = dex_file.GetProtoId(proto_idx);
Handle<mirror::Class> return_type(hs.NewHandle(
ResolveType(proto_id.return_type_idx_, dex_cache, class_loader)));
if (return_type == nullptr) {
@@ -8644,7 +8643,7 @@ ObjPtr<mirror::MethodType> ClassLinker::ResolveMethodType(Thread* self,
mirror::MethodHandle* ClassLinker::ResolveMethodHandleForField(
Thread* self,
- const DexFile::MethodHandleItem& method_handle,
+ const dex::MethodHandleItem& method_handle,
ArtMethod* referrer) {
DexFile::MethodHandleType handle_type =
static_cast<DexFile::MethodHandleType>(method_handle.method_handle_type_);
@@ -8772,7 +8771,7 @@ mirror::MethodHandle* ClassLinker::ResolveMethodHandleForField(
mirror::MethodHandle* ClassLinker::ResolveMethodHandleForMethod(
Thread* self,
- const DexFile::MethodHandleItem& method_handle,
+ const dex::MethodHandleItem& method_handle,
ArtMethod* referrer) {
DexFile::MethodHandleType handle_type =
static_cast<DexFile::MethodHandleType>(method_handle.method_handle_type_);
@@ -8895,7 +8894,7 @@ mirror::MethodHandle* ClassLinker::ResolveMethodHandleForMethod(
}
const DexFile* dex_file = referrer->GetDexFile();
- const DexFile::MethodId& method_id = dex_file->GetMethodId(method_handle.field_or_method_idx_);
+ const dex::MethodId& method_id = dex_file->GetMethodId(method_handle.field_or_method_idx_);
int32_t index = 0;
if (receiver_count != 0) {
// Insert receiver. Use the class identified in the method handle rather than the declaring
@@ -8907,7 +8906,7 @@ mirror::MethodHandle* ClassLinker::ResolveMethodHandleForMethod(
method_params->Set(index++, receiver_class);
}
- const DexFile::ProtoId& proto_id = dex_file->GetProtoId(method_id.proto_idx_);
+ const dex::ProtoId& proto_id = dex_file->GetProtoId(method_id.proto_idx_);
DexFileParameterIterator it(*dex_file, proto_id);
while (it.HasNext()) {
DCHECK_LT(index, num_params);
@@ -8951,7 +8950,7 @@ ObjPtr<mirror::MethodHandle> ClassLinker::ResolveMethodHandle(Thread* self,
ArtMethod* referrer)
REQUIRES_SHARED(Locks::mutator_lock_) {
const DexFile* const dex_file = referrer->GetDexFile();
- const DexFile::MethodHandleItem& method_handle = dex_file->GetMethodHandle(method_handle_idx);
+ const dex::MethodHandleItem& method_handle = dex_file->GetMethodHandle(method_handle_idx);
switch (static_cast<DexFile::MethodHandleType>(method_handle.method_handle_type_)) {
case DexFile::MethodHandleType::kStaticPut:
case DexFile::MethodHandleType::kStaticGet:
diff --git a/runtime/class_linker.h b/runtime/class_linker.h
index d0a7c9b846..fa5df441c7 100644
--- a/runtime/class_linker.h
+++ b/runtime/class_linker.h
@@ -29,7 +29,6 @@
#include "base/macros.h"
#include "dex/class_accessor.h"
#include "dex/dex_cache_resolved_classes.h"
-#include "dex/dex_file.h"
#include "dex/dex_file_types.h"
#include "gc_root.h"
#include "handle.h"
@@ -39,6 +38,10 @@
namespace art {
+namespace dex {
+struct ClassDef;
+} // namespace dex
+
namespace gc {
namespace space {
class ImageSpace;
@@ -73,6 +76,7 @@ class ArtMethod;
class ClassHierarchyAnalysis;
enum class ClassRoot : uint32_t;
class ClassTable;
+class DexFile;
template<class T> class Handle;
class ImtConflictTable;
template<typename T> class LengthPrefixedArray;
@@ -185,7 +189,7 @@ class ClassLinker {
size_t hash,
Handle<mirror::ClassLoader> class_loader,
const DexFile& dex_file,
- const DexFile::ClassDef& dex_class_def)
+ const dex::ClassDef& dex_class_def)
REQUIRES_SHARED(Locks::mutator_lock_)
REQUIRES(!Locks::dex_lock_);
@@ -844,19 +848,19 @@ class ClassLinker {
// Precomputes size needed for Class, in the case of a non-temporary class this size must be
// sufficient to hold all static fields.
uint32_t SizeOfClassWithoutEmbeddedTables(const DexFile& dex_file,
- const DexFile::ClassDef& dex_class_def);
+ const dex::ClassDef& dex_class_def);
// Setup the classloader, class def index, type idx so that we can insert this class in the class
// table.
void SetupClass(const DexFile& dex_file,
- const DexFile::ClassDef& dex_class_def,
+ const dex::ClassDef& dex_class_def,
Handle<mirror::Class> klass,
ObjPtr<mirror::ClassLoader> class_loader)
REQUIRES_SHARED(Locks::mutator_lock_);
void LoadClass(Thread* self,
const DexFile& dex_file,
- const DexFile::ClassDef& dex_class_def,
+ const dex::ClassDef& dex_class_def,
Handle<mirror::Class> klass)
REQUIRES_SHARED(Locks::mutator_lock_);
@@ -1028,12 +1032,12 @@ class ClassLinker {
REQUIRES_SHARED(Locks::mutator_lock_);
mirror::MethodHandle* ResolveMethodHandleForField(Thread* self,
- const DexFile::MethodHandleItem& method_handle,
+ const dex::MethodHandleItem& method_handle,
ArtMethod* referrer)
REQUIRES_SHARED(Locks::mutator_lock_);
mirror::MethodHandle* ResolveMethodHandleForMethod(Thread* self,
- const DexFile::MethodHandleItem& method_handle,
+ const dex::MethodHandleItem& method_handle,
ArtMethod* referrer)
REQUIRES_SHARED(Locks::mutator_lock_);
@@ -1403,9 +1407,9 @@ class ClassLoadCallback {
Handle<mirror::Class> klass ATTRIBUTE_UNUSED,
Handle<mirror::ClassLoader> class_loader ATTRIBUTE_UNUSED,
const DexFile& initial_dex_file ATTRIBUTE_UNUSED,
- const DexFile::ClassDef& initial_class_def ATTRIBUTE_UNUSED,
+ const dex::ClassDef& initial_class_def ATTRIBUTE_UNUSED,
/*out*/DexFile const** final_dex_file ATTRIBUTE_UNUSED,
- /*out*/DexFile::ClassDef const** final_class_def ATTRIBUTE_UNUSED)
+ /*out*/dex::ClassDef const** final_class_def ATTRIBUTE_UNUSED)
REQUIRES_SHARED(Locks::mutator_lock_) {}
// A class has been loaded.
diff --git a/runtime/class_linker_test.cc b/runtime/class_linker_test.cc
index 061c788a41..f3aefc2701 100644
--- a/runtime/class_linker_test.cc
+++ b/runtime/class_linker_test.cc
@@ -429,13 +429,13 @@ class ClassLinkerTest : public CommonRuntimeTest {
REQUIRES_SHARED(Locks::mutator_lock_) {
// Verify all the classes defined in this file
for (size_t i = 0; i < dex.NumClassDefs(); i++) {
- const DexFile::ClassDef& class_def = dex.GetClassDef(i);
+ const dex::ClassDef& class_def = dex.GetClassDef(i);
const char* descriptor = dex.GetClassDescriptor(class_def);
AssertDexFileClass(class_loader, descriptor);
}
// Verify all the types referenced by this file
for (size_t i = 0; i < dex.NumTypeIds(); i++) {
- const DexFile::TypeId& type_id = dex.GetTypeId(dex::TypeIndex(i));
+ const dex::TypeId& type_id = dex.GetTypeId(dex::TypeIndex(i));
const char* descriptor = dex.GetTypeDescriptor(type_id);
AssertDexFileClass(class_loader, descriptor);
}
@@ -997,7 +997,7 @@ TEST_F(ClassLinkerTest, LookupResolvedTypeArray) {
Handle<mirror::DexCache> dex_cache = hs.NewHandle(all_fields_klass->GetDexCache());
const DexFile& dex_file = *dex_cache->GetDexFile();
// Get the index of the array class we want to test.
- const DexFile::TypeId* array_id = dex_file.FindTypeId("[Ljava/lang/Object;");
+ const dex::TypeId* array_id = dex_file.FindTypeId("[Ljava/lang/Object;");
ASSERT_TRUE(array_id != nullptr);
dex::TypeIndex array_idx = dex_file.GetIndexForTypeId(*array_id);
// Check that the array class wasn't resolved yet.
@@ -1323,7 +1323,7 @@ TEST_F(ClassLinkerTest, ResolveVerifyAndClinit) {
klass->FindClassMethod("getS0", "()Ljava/lang/Object;", kRuntimePointerSize);
ASSERT_TRUE(getS0 != nullptr);
ASSERT_TRUE(getS0->IsStatic());
- const DexFile::TypeId* type_id = dex_file->FindTypeId("LStaticsFromCode;");
+ const dex::TypeId* type_id = dex_file->FindTypeId("LStaticsFromCode;");
ASSERT_TRUE(type_id != nullptr);
dex::TypeIndex type_idx = dex_file->GetIndexForTypeId(*type_id);
ObjPtr<mirror::Class> uninit = ResolveVerifyAndClinit(type_idx,
@@ -1564,7 +1564,7 @@ TEST_F(ClassLinkerMethodHandlesTest, TestResolveMethodTypes) {
Handle<mirror::DexCache> dex_cache = hs.NewHandle(
class_linker_->FindDexCache(soa.Self(), dex_file));
- const DexFile::MethodId& method1_id = dex_file.GetMethodId(method1->GetDexMethodIndex());
+ const dex::MethodId& method1_id = dex_file.GetMethodId(method1->GetDexMethodIndex());
// This is the MethodType corresponding to the prototype of
// String MethodTypes# method1(String).
@@ -1596,7 +1596,7 @@ TEST_F(ClassLinkerMethodHandlesTest, TestResolveMethodTypes) {
kRuntimePointerSize);
ASSERT_TRUE(method2 != nullptr);
ASSERT_FALSE(method2->IsDirect());
- const DexFile::MethodId& method2_id = dex_file.GetMethodId(method2->GetDexMethodIndex());
+ const dex::MethodId& method2_id = dex_file.GetMethodId(method2->GetDexMethodIndex());
Handle<mirror::MethodType> method2_type = hs.NewHandle(
class_linker_->ResolveMethodType(soa.Self(), method2_id.proto_idx_, dex_cache, class_loader));
ASSERT_OBJ_PTR_NE(method1_type.Get(), method2_type.Get());
diff --git a/runtime/common_dex_operations.h b/runtime/common_dex_operations.h
index 5c5431d5d9..1c95622ab1 100644
--- a/runtime/common_dex_operations.h
+++ b/runtime/common_dex_operations.h
@@ -24,6 +24,7 @@
#include "base/macros.h"
#include "class_linker.h"
#include "dex/code_item_accessors.h"
+#include "dex/dex_file_structs.h"
#include "dex/primitive.h"
#include "handle_scope-inl.h"
#include "instrumentation.h"
@@ -42,7 +43,7 @@ namespace art {
namespace interpreter {
void ArtInterpreterToInterpreterBridge(Thread* self,
- const DexFile::CodeItem* code_item,
+ const dex::CodeItem* code_item,
ShadowFrame* shadow_frame,
JValue* result)
REQUIRES_SHARED(Locks::mutator_lock_);
diff --git a/runtime/debugger.cc b/runtime/debugger.cc
index 80140b3aa1..adf01c3428 100644
--- a/runtime/debugger.cc
+++ b/runtime/debugger.cc
@@ -3927,7 +3927,7 @@ JDWP::JdwpError Dbg::PrepareInvokeMethod(uint32_t request_id, JDWP::ObjectId thr
StackHandleScope<2> hs(soa.Self());
HandleWrapper<mirror::Object> h_obj(hs.NewHandleWrapper(&receiver));
HandleWrapper<mirror::Class> h_klass(hs.NewHandleWrapper(&c));
- const DexFile::TypeList* types = m->GetParameterTypeList();
+ const dex::TypeList* types = m->GetParameterTypeList();
for (size_t i = 0; i < arg_count; ++i) {
if (shorty[i + 1] != JdwpTagToShortyChar(arg_types[i])) {
return JDWP::ERR_ILLEGAL_ARGUMENT;
diff --git a/runtime/dex/dex_file_annotations.cc b/runtime/dex/dex_file_annotations.cc
index 9127a27bc8..e75baf88fb 100644
--- a/runtime/dex/dex_file_annotations.cc
+++ b/runtime/dex/dex_file_annotations.cc
@@ -44,6 +44,15 @@ namespace art {
using android::base::StringPrintf;
+using dex::AnnotationItem;
+using dex::AnnotationSetItem;
+using dex::AnnotationSetRefItem;
+using dex::AnnotationSetRefList;
+using dex::AnnotationsDirectoryItem;
+using dex::FieldAnnotationsItem;
+using dex::MethodAnnotationsItem;
+using dex::ParameterAnnotationsItem;
+
struct DexFile::AnnotationValue {
JValue value_;
uint8_t type_;
@@ -75,7 +84,7 @@ class ClassData {
return dex_file_;
}
- const DexFile::ClassDef* GetClassDef() const REQUIRES_SHARED(Locks::mutator_lock_) {
+ const dex::ClassDef* GetClassDef() const REQUIRES_SHARED(Locks::mutator_lock_) {
return class_def_;
}
@@ -107,7 +116,7 @@ class ClassData {
ClassData(Handle<mirror::Class> klass,
ArtMethod* method,
const DexFile& dex_file,
- const DexFile::ClassDef* class_def) REQUIRES_SHARED(Locks::mutator_lock_)
+ const dex::ClassDef* class_def) REQUIRES_SHARED(Locks::mutator_lock_)
: real_klass_(klass),
method_(method),
dex_file_(dex_file),
@@ -118,7 +127,7 @@ class ClassData {
Handle<mirror::Class> real_klass_;
ArtMethod* method_;
const DexFile& dex_file_;
- const DexFile::ClassDef* class_def_;
+ const dex::ClassDef* class_def_;
DISALLOW_COPY_AND_ASSIGN(ClassData);
};
@@ -137,21 +146,20 @@ bool IsVisibilityCompatible(uint32_t actual, uint32_t expected) {
return actual == expected;
}
-const DexFile::AnnotationSetItem* FindAnnotationSetForField(ArtField* field)
+const AnnotationSetItem* FindAnnotationSetForField(ArtField* field)
REQUIRES_SHARED(Locks::mutator_lock_) {
const DexFile* dex_file = field->GetDexFile();
ObjPtr<mirror::Class> klass = field->GetDeclaringClass();
- const DexFile::ClassDef* class_def = klass->GetClassDef();
+ const dex::ClassDef* class_def = klass->GetClassDef();
if (class_def == nullptr) {
DCHECK(klass->IsProxyClass());
return nullptr;
}
- const DexFile::AnnotationsDirectoryItem* annotations_dir =
- dex_file->GetAnnotationsDirectory(*class_def);
+ const AnnotationsDirectoryItem* annotations_dir = dex_file->GetAnnotationsDirectory(*class_def);
if (annotations_dir == nullptr) {
return nullptr;
}
- const DexFile::FieldAnnotationsItem* field_annotations =
+ const FieldAnnotationsItem* field_annotations =
dex_file->GetFieldAnnotations(annotations_dir);
if (field_annotations == nullptr) {
return nullptr;
@@ -166,14 +174,14 @@ const DexFile::AnnotationSetItem* FindAnnotationSetForField(ArtField* field)
return nullptr;
}
-const DexFile::AnnotationItem* SearchAnnotationSet(const DexFile& dex_file,
- const DexFile::AnnotationSetItem* annotation_set,
- const char* descriptor,
- uint32_t visibility)
+const AnnotationItem* SearchAnnotationSet(const DexFile& dex_file,
+ const AnnotationSetItem* annotation_set,
+ const char* descriptor,
+ uint32_t visibility)
REQUIRES_SHARED(Locks::mutator_lock_) {
- const DexFile::AnnotationItem* result = nullptr;
+ const AnnotationItem* result = nullptr;
for (uint32_t i = 0; i < annotation_set->size_; ++i) {
- const DexFile::AnnotationItem* annotation_item = dex_file.GetAnnotationItem(annotation_set, i);
+ const AnnotationItem* annotation_item = dex_file.GetAnnotationItem(annotation_set, i);
if (!IsVisibilityCompatible(annotation_item->visibility_, visibility)) {
continue;
}
@@ -268,16 +276,14 @@ const uint8_t* SearchEncodedAnnotation(const DexFile& dex_file,
return nullptr;
}
-const DexFile::AnnotationSetItem* FindAnnotationSetForMethod(const DexFile& dex_file,
- const DexFile::ClassDef& class_def,
- uint32_t method_index) {
- const DexFile::AnnotationsDirectoryItem* annotations_dir =
- dex_file.GetAnnotationsDirectory(class_def);
+const AnnotationSetItem* FindAnnotationSetForMethod(const DexFile& dex_file,
+ const dex::ClassDef& class_def,
+ uint32_t method_index) {
+ const AnnotationsDirectoryItem* annotations_dir = dex_file.GetAnnotationsDirectory(class_def);
if (annotations_dir == nullptr) {
return nullptr;
}
- const DexFile::MethodAnnotationsItem* method_annotations =
- dex_file.GetMethodAnnotations(annotations_dir);
+ const MethodAnnotationsItem* method_annotations = dex_file.GetMethodAnnotations(annotations_dir);
if (method_annotations == nullptr) {
return nullptr;
}
@@ -290,7 +296,7 @@ const DexFile::AnnotationSetItem* FindAnnotationSetForMethod(const DexFile& dex_
return nullptr;
}
-inline const DexFile::AnnotationSetItem* FindAnnotationSetForMethod(ArtMethod* method)
+inline const AnnotationSetItem* FindAnnotationSetForMethod(ArtMethod* method)
REQUIRES_SHARED(Locks::mutator_lock_) {
if (method->IsProxyMethod()) {
return nullptr;
@@ -300,15 +306,15 @@ inline const DexFile::AnnotationSetItem* FindAnnotationSetForMethod(ArtMethod* m
method->GetDexMethodIndex());
}
-const DexFile::ParameterAnnotationsItem* FindAnnotationsItemForMethod(ArtMethod* method)
+const ParameterAnnotationsItem* FindAnnotationsItemForMethod(ArtMethod* method)
REQUIRES_SHARED(Locks::mutator_lock_) {
const DexFile* dex_file = method->GetDexFile();
- const DexFile::AnnotationsDirectoryItem* annotations_dir =
+ const AnnotationsDirectoryItem* annotations_dir =
dex_file->GetAnnotationsDirectory(method->GetClassDef());
if (annotations_dir == nullptr) {
return nullptr;
}
- const DexFile::ParameterAnnotationsItem* parameter_annotations =
+ const ParameterAnnotationsItem* parameter_annotations =
dex_file->GetParameterAnnotations(annotations_dir);
if (parameter_annotations == nullptr) {
return nullptr;
@@ -323,16 +329,15 @@ const DexFile::ParameterAnnotationsItem* FindAnnotationsItemForMethod(ArtMethod*
return nullptr;
}
-const DexFile::AnnotationSetItem* FindAnnotationSetForClass(const ClassData& klass)
+const AnnotationSetItem* FindAnnotationSetForClass(const ClassData& klass)
REQUIRES_SHARED(Locks::mutator_lock_) {
const DexFile& dex_file = klass.GetDexFile();
- const DexFile::ClassDef* class_def = klass.GetClassDef();
+ const dex::ClassDef* class_def = klass.GetClassDef();
if (class_def == nullptr) {
DCHECK(klass.GetRealClass()->IsProxyClass());
return nullptr;
}
- const DexFile::AnnotationsDirectoryItem* annotations_dir =
- dex_file.GetAnnotationsDirectory(*class_def);
+ const AnnotationsDirectoryItem* annotations_dir = dex_file.GetAnnotationsDirectory(*class_def);
if (annotations_dir == nullptr) {
return nullptr;
}
@@ -768,15 +773,14 @@ ObjPtr<mirror::Object> CreateAnnotationMember(const ClassData& klass,
return new_member.Get();
}
-const DexFile::AnnotationItem* GetAnnotationItemFromAnnotationSet(
- const ClassData& klass,
- const DexFile::AnnotationSetItem* annotation_set,
- uint32_t visibility,
- Handle<mirror::Class> annotation_class)
+const AnnotationItem* GetAnnotationItemFromAnnotationSet(const ClassData& klass,
+ const AnnotationSetItem* annotation_set,
+ uint32_t visibility,
+ Handle<mirror::Class> annotation_class)
REQUIRES_SHARED(Locks::mutator_lock_) {
const DexFile& dex_file = klass.GetDexFile();
for (uint32_t i = 0; i < annotation_set->size_; ++i) {
- const DexFile::AnnotationItem* annotation_item = dex_file.GetAnnotationItem(annotation_set, i);
+ const AnnotationItem* annotation_item = dex_file.GetAnnotationItem(annotation_set, i);
if (!IsVisibilityCompatible(annotation_item->visibility_, visibility)) {
continue;
}
@@ -805,13 +809,12 @@ const DexFile::AnnotationItem* GetAnnotationItemFromAnnotationSet(
return nullptr;
}
-ObjPtr<mirror::Object> GetAnnotationObjectFromAnnotationSet(
- const ClassData& klass,
- const DexFile::AnnotationSetItem* annotation_set,
- uint32_t visibility,
- Handle<mirror::Class> annotation_class)
+ObjPtr<mirror::Object> GetAnnotationObjectFromAnnotationSet(const ClassData& klass,
+ const AnnotationSetItem* annotation_set,
+ uint32_t visibility,
+ Handle<mirror::Class> annotation_class)
REQUIRES_SHARED(Locks::mutator_lock_) {
- const DexFile::AnnotationItem* annotation_item = GetAnnotationItemFromAnnotationSet(
+ const AnnotationItem* annotation_item = GetAnnotationItemFromAnnotationSet(
klass, annotation_set, visibility, annotation_class);
if (annotation_item == nullptr) {
return nullptr;
@@ -821,7 +824,7 @@ ObjPtr<mirror::Object> GetAnnotationObjectFromAnnotationSet(
}
ObjPtr<mirror::Object> GetAnnotationValue(const ClassData& klass,
- const DexFile::AnnotationItem* annotation_item,
+ const AnnotationItem* annotation_item,
const char* annotation_name,
Handle<mirror::Class> array_class,
uint32_t expected_type)
@@ -855,11 +858,11 @@ ObjPtr<mirror::Object> GetAnnotationValue(const ClassData& klass,
static ObjPtr<mirror::ObjectArray<mirror::String>> GetSignatureValue(
const ClassData& klass,
- const DexFile::AnnotationSetItem* annotation_set)
+ const AnnotationSetItem* annotation_set)
REQUIRES_SHARED(Locks::mutator_lock_) {
const DexFile& dex_file = klass.GetDexFile();
StackHandleScope<1> hs(Thread::Current());
- const DexFile::AnnotationItem* annotation_item =
+ const AnnotationItem* annotation_item =
SearchAnnotationSet(dex_file, annotation_set, "Ldalvik/annotation/Signature;",
DexFile::kDexVisibilitySystem);
if (annotation_item == nullptr) {
@@ -877,12 +880,11 @@ static ObjPtr<mirror::ObjectArray<mirror::String>> GetSignatureValue(
return obj->AsObjectArray<mirror::String>();
}
-ObjPtr<mirror::ObjectArray<mirror::Class>> GetThrowsValue(
- const ClassData& klass,
- const DexFile::AnnotationSetItem* annotation_set)
+ObjPtr<mirror::ObjectArray<mirror::Class>> GetThrowsValue(const ClassData& klass,
+ const AnnotationSetItem* annotation_set)
REQUIRES_SHARED(Locks::mutator_lock_) {
const DexFile& dex_file = klass.GetDexFile();
- const DexFile::AnnotationItem* annotation_item =
+ const AnnotationItem* annotation_item =
SearchAnnotationSet(dex_file, annotation_set, "Ldalvik/annotation/Throws;",
DexFile::kDexVisibilitySystem);
if (annotation_item == nullptr) {
@@ -903,7 +905,7 @@ ObjPtr<mirror::ObjectArray<mirror::Class>> GetThrowsValue(
ObjPtr<mirror::ObjectArray<mirror::Object>> ProcessAnnotationSet(
const ClassData& klass,
- const DexFile::AnnotationSetItem* annotation_set,
+ const AnnotationSetItem* annotation_set,
uint32_t visibility)
REQUIRES_SHARED(Locks::mutator_lock_) {
const DexFile& dex_file = klass.GetDexFile();
@@ -925,7 +927,7 @@ ObjPtr<mirror::ObjectArray<mirror::Object>> ProcessAnnotationSet(
uint32_t dest_index = 0;
for (uint32_t i = 0; i < size; ++i) {
- const DexFile::AnnotationItem* annotation_item = dex_file.GetAnnotationItem(annotation_set, i);
+ const AnnotationItem* annotation_item = dex_file.GetAnnotationItem(annotation_set, i);
// Note that we do not use IsVisibilityCompatible here because older code
// was correct for this case.
if (annotation_item->visibility_ != visibility) {
@@ -961,7 +963,7 @@ ObjPtr<mirror::ObjectArray<mirror::Object>> ProcessAnnotationSet(
ObjPtr<mirror::ObjectArray<mirror::Object>> ProcessAnnotationSetRefList(
const ClassData& klass,
- const DexFile::AnnotationSetRefList* set_ref_list,
+ const AnnotationSetRefList* set_ref_list,
uint32_t size)
REQUIRES_SHARED(Locks::mutator_lock_) {
const DexFile& dex_file = klass.GetDexFile();
@@ -982,8 +984,8 @@ ObjPtr<mirror::ObjectArray<mirror::Object>> ProcessAnnotationSetRefList(
return nullptr;
}
for (uint32_t index = 0; index < size; ++index) {
- const DexFile::AnnotationSetRefItem* set_ref_item = &set_ref_list->list_[index];
- const DexFile::AnnotationSetItem* set_item = dex_file.GetSetRefItemItem(set_ref_item);
+ const AnnotationSetRefItem* set_ref_item = &set_ref_list->list_[index];
+ const AnnotationSetItem* set_item = dex_file.GetSetRefItemItem(set_ref_item);
ObjPtr<mirror::Object> annotation_set = ProcessAnnotationSet(klass,
set_item,
DexFile::kDexVisibilityRuntime);
@@ -1000,7 +1002,7 @@ namespace annotations {
ObjPtr<mirror::Object> GetAnnotationForField(ArtField* field,
Handle<mirror::Class> annotation_class) {
- const DexFile::AnnotationSetItem* annotation_set = FindAnnotationSetForField(field);
+ const AnnotationSetItem* annotation_set = FindAnnotationSetForField(field);
if (annotation_set == nullptr) {
return nullptr;
}
@@ -1013,14 +1015,14 @@ ObjPtr<mirror::Object> GetAnnotationForField(ArtField* field,
}
ObjPtr<mirror::ObjectArray<mirror::Object>> GetAnnotationsForField(ArtField* field) {
- const DexFile::AnnotationSetItem* annotation_set = FindAnnotationSetForField(field);
+ const AnnotationSetItem* annotation_set = FindAnnotationSetForField(field);
StackHandleScope<1> hs(Thread::Current());
const ClassData field_class(hs, field);
return ProcessAnnotationSet(field_class, annotation_set, DexFile::kDexVisibilityRuntime);
}
ObjPtr<mirror::ObjectArray<mirror::String>> GetSignatureAnnotationForField(ArtField* field) {
- const DexFile::AnnotationSetItem* annotation_set = FindAnnotationSetForField(field);
+ const AnnotationSetItem* annotation_set = FindAnnotationSetForField(field);
if (annotation_set == nullptr) {
return nullptr;
}
@@ -1030,13 +1032,13 @@ ObjPtr<mirror::ObjectArray<mirror::String>> GetSignatureAnnotationForField(ArtFi
}
bool IsFieldAnnotationPresent(ArtField* field, Handle<mirror::Class> annotation_class) {
- const DexFile::AnnotationSetItem* annotation_set = FindAnnotationSetForField(field);
+ const AnnotationSetItem* annotation_set = FindAnnotationSetForField(field);
if (annotation_set == nullptr) {
return false;
}
StackHandleScope<1> hs(Thread::Current());
const ClassData field_class(hs, field);
- const DexFile::AnnotationItem* annotation_item = GetAnnotationItemFromAnnotationSet(
+ const AnnotationItem* annotation_item = GetAnnotationItemFromAnnotationSet(
field_class, annotation_set, DexFile::kDexVisibilityRuntime, annotation_class);
return annotation_item != nullptr;
}
@@ -1044,17 +1046,17 @@ bool IsFieldAnnotationPresent(ArtField* field, Handle<mirror::Class> annotation_
ObjPtr<mirror::Object> GetAnnotationDefaultValue(ArtMethod* method) {
const ClassData klass(method);
const DexFile* dex_file = &klass.GetDexFile();
- const DexFile::AnnotationsDirectoryItem* annotations_dir =
+ const AnnotationsDirectoryItem* annotations_dir =
dex_file->GetAnnotationsDirectory(*klass.GetClassDef());
if (annotations_dir == nullptr) {
return nullptr;
}
- const DexFile::AnnotationSetItem* annotation_set =
+ const AnnotationSetItem* annotation_set =
dex_file->GetClassAnnotationSet(annotations_dir);
if (annotation_set == nullptr) {
return nullptr;
}
- const DexFile::AnnotationItem* annotation_item = SearchAnnotationSet(*dex_file, annotation_set,
+ const AnnotationItem* annotation_item = SearchAnnotationSet(*dex_file, annotation_set,
"Ldalvik/annotation/AnnotationDefault;", DexFile::kDexVisibilitySystem);
if (annotation_item == nullptr) {
return nullptr;
@@ -1087,7 +1089,7 @@ ObjPtr<mirror::Object> GetAnnotationDefaultValue(ArtMethod* method) {
ObjPtr<mirror::Object> GetAnnotationForMethod(ArtMethod* method,
Handle<mirror::Class> annotation_class) {
- const DexFile::AnnotationSetItem* annotation_set = FindAnnotationSetForMethod(method);
+ const AnnotationSetItem* annotation_set = FindAnnotationSetForMethod(method);
if (annotation_set == nullptr) {
return nullptr;
}
@@ -1096,14 +1098,14 @@ ObjPtr<mirror::Object> GetAnnotationForMethod(ArtMethod* method,
}
ObjPtr<mirror::ObjectArray<mirror::Object>> GetAnnotationsForMethod(ArtMethod* method) {
- const DexFile::AnnotationSetItem* annotation_set = FindAnnotationSetForMethod(method);
+ const AnnotationSetItem* annotation_set = FindAnnotationSetForMethod(method);
return ProcessAnnotationSet(ClassData(method),
annotation_set,
DexFile::kDexVisibilityRuntime);
}
ObjPtr<mirror::ObjectArray<mirror::Class>> GetExceptionTypesForMethod(ArtMethod* method) {
- const DexFile::AnnotationSetItem* annotation_set = FindAnnotationSetForMethod(method);
+ const AnnotationSetItem* annotation_set = FindAnnotationSetForMethod(method);
if (annotation_set == nullptr) {
return nullptr;
}
@@ -1112,12 +1114,12 @@ ObjPtr<mirror::ObjectArray<mirror::Class>> GetExceptionTypesForMethod(ArtMethod*
ObjPtr<mirror::ObjectArray<mirror::Object>> GetParameterAnnotations(ArtMethod* method) {
const DexFile* dex_file = method->GetDexFile();
- const DexFile::ParameterAnnotationsItem* parameter_annotations =
+ const ParameterAnnotationsItem* parameter_annotations =
FindAnnotationsItemForMethod(method);
if (parameter_annotations == nullptr) {
return nullptr;
}
- const DexFile::AnnotationSetRefList* set_ref_list =
+ const AnnotationSetRefList* set_ref_list =
dex_file->GetParameterAnnotationSetRefList(parameter_annotations);
if (set_ref_list == nullptr) {
return nullptr;
@@ -1128,12 +1130,12 @@ ObjPtr<mirror::ObjectArray<mirror::Object>> GetParameterAnnotations(ArtMethod* m
uint32_t GetNumberOfAnnotatedMethodParameters(ArtMethod* method) {
const DexFile* dex_file = method->GetDexFile();
- const DexFile::ParameterAnnotationsItem* parameter_annotations =
+ const ParameterAnnotationsItem* parameter_annotations =
FindAnnotationsItemForMethod(method);
if (parameter_annotations == nullptr) {
return 0u;
}
- const DexFile::AnnotationSetRefList* set_ref_list =
+ const AnnotationSetRefList* set_ref_list =
dex_file->GetParameterAnnotationSetRefList(parameter_annotations);
if (set_ref_list == nullptr) {
return 0u;
@@ -1145,12 +1147,11 @@ ObjPtr<mirror::Object> GetAnnotationForMethodParameter(ArtMethod* method,
uint32_t parameter_idx,
Handle<mirror::Class> annotation_class) {
const DexFile* dex_file = method->GetDexFile();
- const DexFile::ParameterAnnotationsItem* parameter_annotations =
- FindAnnotationsItemForMethod(method);
+ const ParameterAnnotationsItem* parameter_annotations = FindAnnotationsItemForMethod(method);
if (parameter_annotations == nullptr) {
return nullptr;
}
- const DexFile::AnnotationSetRefList* set_ref_list =
+ const AnnotationSetRefList* set_ref_list =
dex_file->GetParameterAnnotationSetRefList(parameter_annotations);
if (set_ref_list == nullptr) {
return nullptr;
@@ -1158,8 +1159,8 @@ ObjPtr<mirror::Object> GetAnnotationForMethodParameter(ArtMethod* method,
if (parameter_idx >= set_ref_list->size_) {
return nullptr;
}
- const DexFile::AnnotationSetRefItem* annotation_set_ref = &set_ref_list->list_[parameter_idx];
- const DexFile::AnnotationSetItem* annotation_set =
+ const AnnotationSetRefItem* annotation_set_ref = &set_ref_list->list_[parameter_idx];
+ const AnnotationSetItem* annotation_set =
dex_file->GetSetRefItemItem(annotation_set_ref);
if (annotation_set == nullptr) {
return nullptr;
@@ -1174,14 +1175,14 @@ bool GetParametersMetadataForMethod(
ArtMethod* method,
/*out*/ MutableHandle<mirror::ObjectArray<mirror::String>>* names,
/*out*/ MutableHandle<mirror::IntArray>* access_flags) {
- const DexFile::AnnotationSetItem* annotation_set =
+ const AnnotationSetItem* annotation_set =
FindAnnotationSetForMethod(method);
if (annotation_set == nullptr) {
return false;
}
const DexFile* dex_file = method->GetDexFile();
- const DexFile::AnnotationItem* annotation_item =
+ const AnnotationItem* annotation_item =
SearchAnnotationSet(*dex_file,
annotation_set,
"Ldalvik/annotation/MethodParameters;",
@@ -1228,7 +1229,7 @@ bool GetParametersMetadataForMethod(
}
ObjPtr<mirror::ObjectArray<mirror::String>> GetSignatureAnnotationForMethod(ArtMethod* method) {
- const DexFile::AnnotationSetItem* annotation_set = FindAnnotationSetForMethod(method);
+ const AnnotationSetItem* annotation_set = FindAnnotationSetForMethod(method);
if (annotation_set == nullptr) {
return nullptr;
}
@@ -1238,11 +1239,11 @@ ObjPtr<mirror::ObjectArray<mirror::String>> GetSignatureAnnotationForMethod(ArtM
bool IsMethodAnnotationPresent(ArtMethod* method,
Handle<mirror::Class> annotation_class,
uint32_t visibility /* = DexFile::kDexVisibilityRuntime */) {
- const DexFile::AnnotationSetItem* annotation_set = FindAnnotationSetForMethod(method);
+ const AnnotationSetItem* annotation_set = FindAnnotationSetForMethod(method);
if (annotation_set == nullptr) {
return false;
}
- const DexFile::AnnotationItem* annotation_item = GetAnnotationItemFromAnnotationSet(
+ const AnnotationItem* annotation_item = GetAnnotationItemFromAnnotationSet(
ClassData(method), annotation_set, visibility, annotation_class);
return annotation_item != nullptr;
}
@@ -1263,11 +1264,11 @@ static void DCheckNativeAnnotation(const char* descriptor, jclass cls) {
// Check whether a method from the `dex_file` with the given `annotation_set`
// is annotated with `annotation_descriptor` with build visibility.
static bool IsMethodBuildAnnotationPresent(const DexFile& dex_file,
- const DexFile::AnnotationSetItem& annotation_set,
+ const AnnotationSetItem& annotation_set,
const char* annotation_descriptor,
jclass annotation_class) {
for (uint32_t i = 0; i < annotation_set.size_; ++i) {
- const DexFile::AnnotationItem* annotation_item = dex_file.GetAnnotationItem(&annotation_set, i);
+ const AnnotationItem* annotation_item = dex_file.GetAnnotationItem(&annotation_set, i);
if (!IsVisibilityCompatible(annotation_item->visibility_, DexFile::kDexVisibilityBuild)) {
continue;
}
@@ -1283,9 +1284,9 @@ static bool IsMethodBuildAnnotationPresent(const DexFile& dex_file,
}
uint32_t GetNativeMethodAnnotationAccessFlags(const DexFile& dex_file,
- const DexFile::ClassDef& class_def,
+ const dex::ClassDef& class_def,
uint32_t method_index) {
- const DexFile::AnnotationSetItem* annotation_set =
+ const dex::AnnotationSetItem* annotation_set =
FindAnnotationSetForMethod(dex_file, class_def, method_index);
if (annotation_set == nullptr) {
return 0u;
@@ -1312,7 +1313,7 @@ uint32_t GetNativeMethodAnnotationAccessFlags(const DexFile& dex_file,
ObjPtr<mirror::Object> GetAnnotationForClass(Handle<mirror::Class> klass,
Handle<mirror::Class> annotation_class) {
ClassData data(klass);
- const DexFile::AnnotationSetItem* annotation_set = FindAnnotationSetForClass(data);
+ const AnnotationSetItem* annotation_set = FindAnnotationSetForClass(data);
if (annotation_set == nullptr) {
return nullptr;
}
@@ -1324,17 +1325,17 @@ ObjPtr<mirror::Object> GetAnnotationForClass(Handle<mirror::Class> klass,
ObjPtr<mirror::ObjectArray<mirror::Object>> GetAnnotationsForClass(Handle<mirror::Class> klass) {
ClassData data(klass);
- const DexFile::AnnotationSetItem* annotation_set = FindAnnotationSetForClass(data);
+ const AnnotationSetItem* annotation_set = FindAnnotationSetForClass(data);
return ProcessAnnotationSet(data, annotation_set, DexFile::kDexVisibilityRuntime);
}
ObjPtr<mirror::ObjectArray<mirror::Class>> GetDeclaredClasses(Handle<mirror::Class> klass) {
ClassData data(klass);
- const DexFile::AnnotationSetItem* annotation_set = FindAnnotationSetForClass(data);
+ const AnnotationSetItem* annotation_set = FindAnnotationSetForClass(data);
if (annotation_set == nullptr) {
return nullptr;
}
- const DexFile::AnnotationItem* annotation_item =
+ const AnnotationItem* annotation_item =
SearchAnnotationSet(data.GetDexFile(), annotation_set, "Ldalvik/annotation/MemberClasses;",
DexFile::kDexVisibilitySystem);
if (annotation_item == nullptr) {
@@ -1355,11 +1356,11 @@ ObjPtr<mirror::ObjectArray<mirror::Class>> GetDeclaredClasses(Handle<mirror::Cla
ObjPtr<mirror::Class> GetDeclaringClass(Handle<mirror::Class> klass) {
ClassData data(klass);
- const DexFile::AnnotationSetItem* annotation_set = FindAnnotationSetForClass(data);
+ const AnnotationSetItem* annotation_set = FindAnnotationSetForClass(data);
if (annotation_set == nullptr) {
return nullptr;
}
- const DexFile::AnnotationItem* annotation_item =
+ const AnnotationItem* annotation_item =
SearchAnnotationSet(data.GetDexFile(), annotation_set, "Ldalvik/annotation/EnclosingClass;",
DexFile::kDexVisibilitySystem);
if (annotation_item == nullptr) {
@@ -1382,11 +1383,11 @@ ObjPtr<mirror::Class> GetEnclosingClass(Handle<mirror::Class> klass) {
return declaring_class;
}
ClassData data(klass);
- const DexFile::AnnotationSetItem* annotation_set = FindAnnotationSetForClass(data);
+ const AnnotationSetItem* annotation_set = FindAnnotationSetForClass(data);
if (annotation_set == nullptr) {
return nullptr;
}
- const DexFile::AnnotationItem* annotation_item =
+ const AnnotationItem* annotation_item =
SearchAnnotationSet(data.GetDexFile(),
annotation_set,
"Ldalvik/annotation/EnclosingMethod;",
@@ -1423,11 +1424,11 @@ ObjPtr<mirror::Class> GetEnclosingClass(Handle<mirror::Class> klass) {
ObjPtr<mirror::Object> GetEnclosingMethod(Handle<mirror::Class> klass) {
ClassData data(klass);
- const DexFile::AnnotationSetItem* annotation_set = FindAnnotationSetForClass(data);
+ const AnnotationSetItem* annotation_set = FindAnnotationSetForClass(data);
if (annotation_set == nullptr) {
return nullptr;
}
- const DexFile::AnnotationItem* annotation_item =
+ const AnnotationItem* annotation_item =
SearchAnnotationSet(data.GetDexFile(),
annotation_set,
"Ldalvik/annotation/EnclosingMethod;",
@@ -1441,11 +1442,11 @@ ObjPtr<mirror::Object> GetEnclosingMethod(Handle<mirror::Class> klass) {
bool GetInnerClass(Handle<mirror::Class> klass, /*out*/ ObjPtr<mirror::String>* name) {
ClassData data(klass);
- const DexFile::AnnotationSetItem* annotation_set = FindAnnotationSetForClass(data);
+ const AnnotationSetItem* annotation_set = FindAnnotationSetForClass(data);
if (annotation_set == nullptr) {
return false;
}
- const DexFile::AnnotationItem* annotation_item = SearchAnnotationSet(
+ const AnnotationItem* annotation_item = SearchAnnotationSet(
data.GetDexFile(),
annotation_set,
"Ldalvik/annotation/InnerClass;",
@@ -1476,11 +1477,11 @@ bool GetInnerClass(Handle<mirror::Class> klass, /*out*/ ObjPtr<mirror::String>*
bool GetInnerClassFlags(Handle<mirror::Class> klass, uint32_t* flags) {
ClassData data(klass);
- const DexFile::AnnotationSetItem* annotation_set = FindAnnotationSetForClass(data);
+ const AnnotationSetItem* annotation_set = FindAnnotationSetForClass(data);
if (annotation_set == nullptr) {
return false;
}
- const DexFile::AnnotationItem* annotation_item =
+ const AnnotationItem* annotation_item =
SearchAnnotationSet(data.GetDexFile(), annotation_set, "Ldalvik/annotation/InnerClass;",
DexFile::kDexVisibilitySystem);
if (annotation_item == nullptr) {
@@ -1509,7 +1510,7 @@ bool GetInnerClassFlags(Handle<mirror::Class> klass, uint32_t* flags) {
ObjPtr<mirror::ObjectArray<mirror::String>> GetSignatureAnnotationForClass(
Handle<mirror::Class> klass) {
ClassData data(klass);
- const DexFile::AnnotationSetItem* annotation_set = FindAnnotationSetForClass(data);
+ const AnnotationSetItem* annotation_set = FindAnnotationSetForClass(data);
if (annotation_set == nullptr) {
return nullptr;
}
@@ -1526,12 +1527,12 @@ const char* GetSourceDebugExtension(Handle<mirror::Class> klass) {
}
ClassData data(klass);
- const DexFile::AnnotationSetItem* annotation_set = FindAnnotationSetForClass(data);
+ const AnnotationSetItem* annotation_set = FindAnnotationSetForClass(data);
if (annotation_set == nullptr) {
return nullptr;
}
- const DexFile::AnnotationItem* annotation_item = SearchAnnotationSet(
+ const AnnotationItem* annotation_item = SearchAnnotationSet(
data.GetDexFile(),
annotation_set,
"Ldalvik/annotation/SourceDebugExtension;",
@@ -1562,11 +1563,11 @@ const char* GetSourceDebugExtension(Handle<mirror::Class> klass) {
bool IsClassAnnotationPresent(Handle<mirror::Class> klass, Handle<mirror::Class> annotation_class) {
ClassData data(klass);
- const DexFile::AnnotationSetItem* annotation_set = FindAnnotationSetForClass(data);
+ const AnnotationSetItem* annotation_set = FindAnnotationSetForClass(data);
if (annotation_set == nullptr) {
return false;
}
- const DexFile::AnnotationItem* annotation_item = GetAnnotationItemFromAnnotationSet(
+ const AnnotationItem* annotation_item = GetAnnotationItemFromAnnotationSet(
data, annotation_set, DexFile::kDexVisibilityRuntime, annotation_class);
return annotation_item != nullptr;
}
diff --git a/runtime/dex/dex_file_annotations.h b/runtime/dex/dex_file_annotations.h
index bde7891091..3625cee3d4 100644
--- a/runtime/dex/dex_file_annotations.h
+++ b/runtime/dex/dex_file_annotations.h
@@ -18,7 +18,6 @@
#define ART_RUNTIME_DEX_DEX_FILE_ANNOTATIONS_H_
#include "dex/dex_file.h"
-
#include "handle.h"
#include "mirror/dex_cache.h"
#include "mirror/object_array.h"
@@ -84,7 +83,7 @@ bool IsMethodAnnotationPresent(ArtMethod* method,
// @dalvik.annotation.optimization.CriticalNative with build visibility.
// If yes, return the associated access flags, i.e. kAccFastNative or kAccCriticalNative.
uint32_t GetNativeMethodAnnotationAccessFlags(const DexFile& dex_file,
- const DexFile::ClassDef& class_def,
+ const dex::ClassDef& class_def,
uint32_t method_index);
// Class annotations.
@@ -124,7 +123,7 @@ class RuntimeEncodedStaticFieldValueIterator : public EncodedStaticFieldValueIte
RuntimeEncodedStaticFieldValueIterator(Handle<mirror::DexCache> dex_cache,
Handle<mirror::ClassLoader> class_loader,
ClassLinker* linker,
- const DexFile::ClassDef& class_def)
+ const dex::ClassDef& class_def)
REQUIRES_SHARED(Locks::mutator_lock_)
: EncodedStaticFieldValueIterator(*dex_cache->GetDexFile(), class_def),
dex_cache_(dex_cache),
diff --git a/runtime/dex_to_dex_decompiler.cc b/runtime/dex_to_dex_decompiler.cc
index aff9b47a79..d078d6f438 100644
--- a/runtime/dex_to_dex_decompiler.cc
+++ b/runtime/dex_to_dex_decompiler.cc
@@ -32,7 +32,7 @@ namespace optimizer {
class DexDecompiler {
public:
DexDecompiler(const DexFile& dex_file,
- const DexFile::CodeItem& code_item,
+ const dex::CodeItem& code_item,
const ArrayRef<const uint8_t>& quickened_info,
bool decompile_return_instruction)
: code_item_accessor_(dex_file, &code_item),
@@ -194,7 +194,7 @@ bool DexDecompiler::Decompile() {
}
bool ArtDecompileDEX(const DexFile& dex_file,
- const DexFile::CodeItem& code_item,
+ const dex::CodeItem& code_item,
const ArrayRef<const uint8_t>& quickened_info,
bool decompile_return_instruction) {
if (quickened_info.size() == 0 && !decompile_return_instruction) {
diff --git a/runtime/dex_to_dex_decompiler.h b/runtime/dex_to_dex_decompiler.h
index 93711d17db..4b6b0f707a 100644
--- a/runtime/dex_to_dex_decompiler.h
+++ b/runtime/dex_to_dex_decompiler.h
@@ -18,9 +18,15 @@
#define ART_RUNTIME_DEX_TO_DEX_DECOMPILER_H_
#include "base/array_ref.h"
-#include "dex/dex_file.h"
namespace art {
+
+class DexFile;
+
+namespace dex {
+struct CodeItem;
+} // namespace dex
+
namespace optimizer {
// "Decompile", that is unquicken, the code item provided, given the
@@ -30,7 +36,7 @@ namespace optimizer {
// consistent with DexToDexCompiler, but we should really change it to
// DexFile::CodeItem*.
bool ArtDecompileDEX(const DexFile& dex_file,
- const DexFile::CodeItem& code_item,
+ const dex::CodeItem& code_item,
const ArrayRef<const uint8_t>& quickened_data,
bool decompile_return_instruction);
diff --git a/runtime/hidden_api.cc b/runtime/hidden_api.cc
index e0939ddbdb..c146daa809 100644
--- a/runtime/hidden_api.cc
+++ b/runtime/hidden_api.cc
@@ -98,7 +98,7 @@ MemberSignature::MemberSignature(ArtMethod* method) {
MemberSignature::MemberSignature(const ClassAccessor::Field& field) {
const DexFile& dex_file = field.GetDexFile();
- const DexFile::FieldId& field_id = dex_file.GetFieldId(field.GetIndex());
+ const dex::FieldId& field_id = dex_file.GetFieldId(field.GetIndex());
class_name_ = dex_file.GetFieldDeclaringClassDescriptor(field_id);
member_name_ = dex_file.GetFieldName(field_id);
type_signature_ = dex_file.GetFieldTypeDescriptor(field_id);
@@ -107,7 +107,7 @@ MemberSignature::MemberSignature(const ClassAccessor::Field& field) {
MemberSignature::MemberSignature(const ClassAccessor::Method& method) {
const DexFile& dex_file = method.GetDexFile();
- const DexFile::MethodId& method_id = dex_file.GetMethodId(method.GetIndex());
+ const dex::MethodId& method_id = dex_file.GetMethodId(method.GetIndex());
class_name_ = dex_file.GetMethodDeclaringClassDescriptor(method_id);
member_name_ = dex_file.GetMethodName(method_id);
type_signature_ = dex_file.GetMethodSignature(method_id).ToString();
@@ -282,14 +282,14 @@ static ALWAYS_INLINE uint32_t GetMemberDexIndex(ArtMethod* method)
}
static void VisitMembers(const DexFile& dex_file,
- const DexFile::ClassDef& class_def,
+ const dex::ClassDef& class_def,
const std::function<void(const ClassAccessor::Field&)>& fn_visit) {
ClassAccessor accessor(dex_file, class_def, /* parse_hiddenapi_class_data= */ true);
accessor.VisitFields(fn_visit, fn_visit);
}
static void VisitMembers(const DexFile& dex_file,
- const DexFile::ClassDef& class_def,
+ const dex::ClassDef& class_def,
const std::function<void(const ClassAccessor::Method&)>& fn_visit) {
ClassAccessor accessor(dex_file, class_def, /* parse_hiddenapi_class_data= */ true);
accessor.VisitMethods(fn_visit, fn_visit);
@@ -317,7 +317,7 @@ uint32_t GetDexFlags(T* member) REQUIRES_SHARED(Locks::mutator_lock_) {
if (LIKELY(original_dex == nullptr)) {
// Class is not redefined. Find the class def, iterate over its members and
// find the entry corresponding to this `member`.
- const DexFile::ClassDef* class_def = declaring_class->GetClassDef();
+ const dex::ClassDef* class_def = declaring_class->GetClassDef();
if (class_def == nullptr) {
flags = kNoDexFlags;
} else {
@@ -338,7 +338,7 @@ uint32_t GetDexFlags(T* member) REQUIRES_SHARED(Locks::mutator_lock_) {
// to access a hidden member of a JVMTI-redefined class.
uint16_t class_def_idx = ext->GetPreRedefineClassDefIndex();
DCHECK_NE(class_def_idx, DexFile::kDexNoIndex16);
- const DexFile::ClassDef& original_class_def = original_dex->GetClassDef(class_def_idx);
+ const dex::ClassDef& original_class_def = original_dex->GetClassDef(class_def_idx);
MemberSignature member_signature(member);
auto fn_visit = [&](const AccessorType& dex_member) {
MemberSignature cur_signature(dex_member);
diff --git a/runtime/imtable-inl.h b/runtime/imtable-inl.h
index 93346f6151..21e3eb1f23 100644
--- a/runtime/imtable-inl.h
+++ b/runtime/imtable-inl.h
@@ -46,7 +46,7 @@ inline void ImTable::GetImtHashComponents(ArtMethod* method,
}
const DexFile* dex_file = method->GetDexFile();
- const DexFile::MethodId& method_id = dex_file->GetMethodId(method->GetDexMethodIndex());
+ const dex::MethodId& method_id = dex_file->GetMethodId(method->GetDexMethodIndex());
// Class descriptor for the class component.
*class_hash = ComputeModifiedUtf8Hash(dex_file->GetMethodDeclaringClassDescriptor(method_id));
@@ -54,7 +54,7 @@ inline void ImTable::GetImtHashComponents(ArtMethod* method,
// Method name for the method component.
*name_hash = ComputeModifiedUtf8Hash(dex_file->GetMethodName(method_id));
- const DexFile::ProtoId& proto_id = dex_file->GetMethodPrototype(method_id);
+ const dex::ProtoId& proto_id = dex_file->GetMethodPrototype(method_id);
// Read the proto for the signature component.
uint32_t tmp = ComputeModifiedUtf8Hash(
@@ -63,10 +63,10 @@ inline void ImTable::GetImtHashComponents(ArtMethod* method,
// Mix in the argument types.
// Note: we could consider just using the shorty. This would be faster, at the price of
// potential collisions.
- const DexFile::TypeList* param_types = dex_file->GetProtoParameters(proto_id);
+ const dex::TypeList* param_types = dex_file->GetProtoParameters(proto_id);
if (param_types != nullptr) {
for (size_t i = 0; i != param_types->Size(); ++i) {
- const DexFile::TypeItem& type = param_types->GetTypeItem(i);
+ const dex::TypeItem& type = param_types->GetTypeItem(i);
tmp = 31 * tmp + ComputeModifiedUtf8Hash(
dex_file->GetTypeDescriptor(dex_file->GetTypeId(type.type_idx_)));
}
diff --git a/runtime/interpreter/interpreter_common.cc b/runtime/interpreter/interpreter_common.cc
index e52a1c90d3..7a40ab431f 100644
--- a/runtime/interpreter/interpreter_common.cc
+++ b/runtime/interpreter/interpreter_common.cc
@@ -1168,7 +1168,7 @@ static ObjPtr<mirror::MethodType> BuildCallSiteForBootstrapMethod(Thread* self,
const DexFile* dex_file,
uint32_t call_site_idx)
REQUIRES_SHARED(Locks::mutator_lock_) {
- const DexFile::CallSiteIdItem& csi = dex_file->GetCallSiteId(call_site_idx);
+ const dex::CallSiteIdItem& csi = dex_file->GetCallSiteId(call_site_idx);
CallSiteArrayValueIterator it(*dex_file, csi);
DCHECK_GE(it.Size(), 1u);
@@ -1223,7 +1223,7 @@ static ObjPtr<mirror::CallSite> InvokeBootstrapMethod(Thread* self,
static constexpr size_t kMandatoryArgumentsCount = 3;
ArtMethod* referrer = shadow_frame.GetMethod();
const DexFile* dex_file = referrer->GetDexFile();
- const DexFile::CallSiteIdItem& csi = dex_file->GetCallSiteId(call_site_idx);
+ const dex::CallSiteIdItem& csi = dex_file->GetCallSiteId(call_site_idx);
CallSiteArrayValueIterator it(*dex_file, csi);
if (it.Size() < kMandatoryArgumentsCount) {
ThrowBootstrapMethodError("Truncated bootstrap arguments (%zu < %zu)",
@@ -1637,7 +1637,7 @@ static inline bool DoCallCommon(ArtMethod* called_method,
// We need to do runtime check on reference assignment. We need to load the shorty
// to get the exact type of each reference argument.
- const DexFile::TypeList* params = method->GetParameterTypeList();
+ const dex::TypeList* params = method->GetParameterTypeList();
uint32_t shorty_len = 0;
const char* shorty = method->GetShorty(&shorty_len);
diff --git a/runtime/interpreter/interpreter_common.h b/runtime/interpreter/interpreter_common.h
index d1896e6b08..6366035a4c 100644
--- a/runtime/interpreter/interpreter_common.h
+++ b/runtime/interpreter/interpreter_common.h
@@ -621,7 +621,7 @@ void ArtInterpreterToCompiledCodeBridge(Thread* self,
static inline bool IsStringInit(const DexFile* dex_file, uint32_t method_idx)
REQUIRES_SHARED(Locks::mutator_lock_) {
- const DexFile::MethodId& method_id = dex_file->GetMethodId(method_idx);
+ const dex::MethodId& method_id = dex_file->GetMethodId(method_idx);
const char* class_name = dex_file->StringByTypeIdx(method_id.class_idx_);
const char* method_name = dex_file->GetMethodName(method_id);
// Instead of calling ResolveMethod() which has suspend point and can trigger
diff --git a/runtime/mirror/class-inl.h b/runtime/mirror/class-inl.h
index 679ca43e98..bdad412350 100644
--- a/runtime/mirror/class-inl.h
+++ b/runtime/mirror/class-inl.h
@@ -825,7 +825,7 @@ inline bool Class::DescriptorEquals(const char* match) {
return ProxyDescriptorEquals(match);
} else {
const DexFile& dex_file = GetDexFile();
- const DexFile::TypeId& type_id = dex_file.GetTypeId(GetClassDef()->class_idx_);
+ const dex::TypeId& type_id = dex_file.GetTypeId(GetClassDef()->class_idx_);
return strcmp(dex_file.GetTypeDescriptor(type_id), match) == 0;
}
}
@@ -899,7 +899,7 @@ inline uint32_t Class::NumDirectInterfaces() {
ObjectArray<Class>* interfaces = GetProxyInterfaces();
return interfaces != nullptr ? interfaces->GetLength() : 0;
} else {
- const DexFile::TypeList* interfaces = GetInterfaceTypeList();
+ const dex::TypeList* interfaces = GetInterfaceTypeList();
if (interfaces == nullptr) {
return 0;
} else {
diff --git a/runtime/mirror/class.cc b/runtime/mirror/class.cc
index c5ed1bf4dd..515394ab18 100644
--- a/runtime/mirror/class.cc
+++ b/runtime/mirror/class.cc
@@ -493,7 +493,7 @@ ArtMethod* Class::FindInterfaceMethod(ObjPtr<DexCache> dex_cache,
PointerSize pointer_size) {
// We always search by name and signature, ignoring the type index in the MethodId.
const DexFile& dex_file = *dex_cache->GetDexFile();
- const DexFile::MethodId& method_id = dex_file.GetMethodId(dex_method_idx);
+ const dex::MethodId& method_id = dex_file.GetMethodId(dex_method_idx);
StringPiece name = dex_file.StringDataByIdx(method_id.name_idx_);
const Signature signature = dex_file.GetMethodSignature(method_id);
return FindInterfaceMethod(name, signature, pointer_size);
@@ -620,7 +620,7 @@ ArtMethod* Class::FindClassMethod(ObjPtr<DexCache> dex_cache,
}
// If not found, we need to search by name and signature.
const DexFile& dex_file = *dex_cache->GetDexFile();
- const DexFile::MethodId& method_id = dex_file.GetMethodId(dex_method_idx);
+ const dex::MethodId& method_id = dex_file.GetMethodId(dex_method_idx);
const Signature signature = dex_file.GetMethodSignature(method_id);
StringPiece name; // Delay strlen() until actually needed.
// If we do not have a dex_cache match, try to find the declared method in this class now.
@@ -651,7 +651,7 @@ ArtMethod* Class::FindClassMethod(ObjPtr<DexCache> dex_cache,
// Matching dex_cache. We cannot compare the `dex_method_idx` anymore because
// the type index differs, so compare the name index and proto index.
for (ArtMethod& method : declared_methods) {
- const DexFile::MethodId& cmp_method_id = dex_file.GetMethodId(method.GetDexMethodIndex());
+ const dex::MethodId& cmp_method_id = dex_file.GetMethodId(method.GetDexMethodIndex());
if (cmp_method_id.name_idx_ == method_id.name_idx_ &&
cmp_method_id.proto_idx_ == method_id.proto_idx_) {
candidate_method = &method;
@@ -1005,7 +1005,7 @@ const char* Class::GetDescriptor(std::string* storage) {
return storage->c_str();
} else {
const DexFile& dex_file = GetDexFile();
- const DexFile::TypeId& type_id = dex_file.GetTypeId(GetClassDef()->class_idx_);
+ const dex::TypeId& type_id = dex_file.GetTypeId(GetClassDef()->class_idx_);
return dex_file.GetTypeDescriptor(type_id);
}
}
@@ -1018,7 +1018,7 @@ const char* Class::GetArrayDescriptor(std::string* storage) {
return storage->c_str();
}
-const DexFile::ClassDef* Class::GetClassDef() {
+const dex::ClassDef* Class::GetClassDef() {
uint16_t class_def_idx = GetDexClassDefIndex();
if (class_def_idx == DexFile::kDexNoIndex16) {
return nullptr;
@@ -1086,7 +1086,7 @@ ObjPtr<Class> Class::GetCommonSuperClass(Handle<Class> klass) {
const char* Class::GetSourceFile() {
const DexFile& dex_file = GetDexFile();
- const DexFile::ClassDef* dex_class_def = GetClassDef();
+ const dex::ClassDef* dex_class_def = GetClassDef();
if (dex_class_def == nullptr) {
// Generated classes have no class def.
return nullptr;
@@ -1103,8 +1103,8 @@ std::string Class::GetLocation() {
return "generated class";
}
-const DexFile::TypeList* Class::GetInterfaceTypeList() {
- const DexFile::ClassDef* class_def = GetClassDef();
+const dex::TypeList* Class::GetInterfaceTypeList() {
+ const dex::ClassDef* class_def = GetClassDef();
if (class_def == nullptr) {
return nullptr;
}
@@ -1247,7 +1247,7 @@ uint32_t Class::Depth() {
dex::TypeIndex Class::FindTypeIndexInOtherDexFile(const DexFile& dex_file) {
std::string temp;
- const DexFile::TypeId* type_id = dex_file.FindTypeId(GetDescriptor(&temp));
+ const dex::TypeId* type_id = dex_file.FindTypeId(GetDescriptor(&temp));
return (type_id == nullptr) ? dex::TypeIndex() : dex_file.GetIndexForTypeId(*type_id);
}
diff --git a/runtime/mirror/class.h b/runtime/mirror/class.h
index d5aa514432..8e392bcd77 100644
--- a/runtime/mirror/class.h
+++ b/runtime/mirror/class.h
@@ -24,7 +24,7 @@
#include "base/stride_iterator.h"
#include "class_flags.h"
#include "class_status.h"
-#include "dex/dex_file.h"
+#include "dex/dex_file_structs.h"
#include "dex/dex_file_types.h"
#include "dex/modifiers.h"
#include "dex/primitive.h"
@@ -40,6 +40,7 @@ namespace art {
class ArtField;
class ArtMethod;
struct ClassOffsets;
+class DexFile;
template<class T> class Handle;
enum InvokeType : uint32_t;
template<typename T> class LengthPrefixedArray;
@@ -1133,7 +1134,7 @@ class MANAGED Class final : public Object {
bool DescriptorEquals(const char* match) REQUIRES_SHARED(Locks::mutator_lock_);
- const DexFile::ClassDef* GetClassDef() REQUIRES_SHARED(Locks::mutator_lock_);
+ const dex::ClassDef* GetClassDef() REQUIRES_SHARED(Locks::mutator_lock_);
ALWAYS_INLINE uint32_t NumDirectInterfaces() REQUIRES_SHARED(Locks::mutator_lock_);
@@ -1156,7 +1157,7 @@ class MANAGED Class final : public Object {
const DexFile& GetDexFile() REQUIRES_SHARED(Locks::mutator_lock_);
- const DexFile::TypeList* GetInterfaceTypeList() REQUIRES_SHARED(Locks::mutator_lock_);
+ const dex::TypeList* GetInterfaceTypeList() REQUIRES_SHARED(Locks::mutator_lock_);
// Asserts we are initialized or initializing in the given thread.
void AssertInitializedOrInitializingInThread(Thread* self)
diff --git a/runtime/mirror/dex_cache_test.cc b/runtime/mirror/dex_cache_test.cc
index 36c5ae2ab9..f7c1c02325 100644
--- a/runtime/mirror/dex_cache_test.cc
+++ b/runtime/mirror/dex_cache_test.cc
@@ -146,8 +146,8 @@ TEST_F(DexCacheMethodHandlesTest, TestResolvedMethodTypes) {
Handle<mirror::DexCache> dex_cache = hs.NewHandle(
class_linker_->FindDexCache(Thread::Current(), dex_file));
- const DexFile::MethodId& method1_id = dex_file.GetMethodId(method1->GetDexMethodIndex());
- const DexFile::MethodId& method2_id = dex_file.GetMethodId(method2->GetDexMethodIndex());
+ const dex::MethodId& method1_id = dex_file.GetMethodId(method1->GetDexMethodIndex());
+ const dex::MethodId& method2_id = dex_file.GetMethodId(method2->GetDexMethodIndex());
Handle<mirror::MethodType> method1_type = hs.NewHandle(
class_linker_->ResolveMethodType(soa.Self(),
method1_id.proto_idx_,
diff --git a/runtime/mirror/object_test.cc b/runtime/mirror/object_test.cc
index d8c7b1db30..f4b8ba5908 100644
--- a/runtime/mirror/object_test.cc
+++ b/runtime/mirror/object_test.cc
@@ -364,16 +364,16 @@ TEST_F(ObjectTest, StaticFieldFromCode) {
Handle<Class> klass =
hs.NewHandle(class_linker_->FindClass(soa.Self(), "LStaticsFromCode;", loader));
ArtMethod* clinit = klass->FindClassInitializer(kRuntimePointerSize);
- const DexFile::TypeId* klass_type_id = dex_file->FindTypeId("LStaticsFromCode;");
+ const dex::TypeId* klass_type_id = dex_file->FindTypeId("LStaticsFromCode;");
ASSERT_TRUE(klass_type_id != nullptr);
- const DexFile::TypeId* type_type_id = dex_file->FindTypeId("Ljava/lang/Object;");
+ const dex::TypeId* type_type_id = dex_file->FindTypeId("Ljava/lang/Object;");
ASSERT_TRUE(type_type_id != nullptr);
- const DexFile::StringId* name_str_id = dex_file->FindStringId("s0");
+ const dex::StringId* name_str_id = dex_file->FindStringId("s0");
ASSERT_TRUE(name_str_id != nullptr);
- const DexFile::FieldId* field_id = dex_file->FindFieldId(
+ const dex::FieldId* field_id = dex_file->FindFieldId(
*klass_type_id, *name_str_id, *type_type_id);
ASSERT_TRUE(field_id != nullptr);
uint32_t field_idx = dex_file->GetIndexForFieldId(*field_id);
diff --git a/runtime/native/dalvik_system_DexFile.cc b/runtime/native/dalvik_system_DexFile.cc
index 1da91b089d..52482b736d 100644
--- a/runtime/native/dalvik_system_DexFile.cc
+++ b/runtime/native/dalvik_system_DexFile.cc
@@ -383,7 +383,7 @@ static jclass DexFile_defineClassNative(JNIEnv* env,
const std::string descriptor(DotToDescriptor(class_name.c_str()));
const size_t hash(ComputeModifiedUtf8Hash(descriptor.c_str()));
for (auto& dex_file : dex_files) {
- const DexFile::ClassDef* dex_class_def =
+ const dex::ClassDef* dex_class_def =
OatDexFile::FindClassDef(*dex_file, descriptor.c_str(), hash);
if (dex_class_def != nullptr) {
ScopedObjectAccess soa(env);
@@ -440,7 +440,7 @@ static jobjectArray DexFile_getClassNameList(JNIEnv* env, jclass, jobject cookie
std::set<const char*, CharPointerComparator> descriptors;
for (auto& dex_file : dex_files) {
for (size_t i = 0; i < dex_file->NumClassDefs(); ++i) {
- const DexFile::ClassDef& class_def = dex_file->GetClassDef(i);
+ const dex::ClassDef& class_def = dex_file->GetClassDef(i);
const char* descriptor = dex_file->GetClassDescriptor(class_def);
descriptors.insert(descriptor);
}
diff --git a/runtime/native/dalvik_system_VMRuntime.cc b/runtime/native/dalvik_system_VMRuntime.cc
index 892d4cc9e1..d705d5f8c0 100644
--- a/runtime/native/dalvik_system_VMRuntime.cc
+++ b/runtime/native/dalvik_system_VMRuntime.cc
@@ -413,7 +413,7 @@ static void PreloadDexCachesResolveField(ObjPtr<mirror::DexCache> dex_cache,
return; // The entry already contains some ArtField.
}
const DexFile* dex_file = dex_cache->GetDexFile();
- const DexFile::FieldId& field_id = dex_file->GetFieldId(field_idx);
+ const dex::FieldId& field_id = dex_file->GetFieldId(field_idx);
ObjPtr<mirror::Class> klass = Runtime::Current()->GetClassLinker()->LookupResolvedType(
field_id.class_idx_, dex_cache, /* class_loader= */ nullptr);
if (klass == nullptr) {
@@ -439,7 +439,7 @@ static void PreloadDexCachesResolveMethod(ObjPtr<mirror::DexCache> dex_cache, ui
return; // The entry already contains some ArtMethod.
}
const DexFile* dex_file = dex_cache->GetDexFile();
- const DexFile::MethodId& method_id = dex_file->GetMethodId(method_idx);
+ const dex::MethodId& method_id = dex_file->GetMethodId(method_idx);
ClassLinker* class_linker = Runtime::Current()->GetClassLinker();
ObjPtr<mirror::Class> klass = class_linker->LookupResolvedType(
diff --git a/runtime/native/java_lang_Class.cc b/runtime/native/java_lang_Class.cc
index 612a4b33b1..d022c3b631 100644
--- a/runtime/native/java_lang_Class.cc
+++ b/runtime/native/java_lang_Class.cc
@@ -220,7 +220,7 @@ static jobjectArray Class_getInterfacesInternal(JNIEnv* env, jobject javaThis) {
return soa.AddLocalReference<jobjectArray>(klass->GetProxyInterfaces()->Clone(soa.Self()));
}
- const DexFile::TypeList* iface_list = klass->GetInterfaceTypeList();
+ const dex::TypeList* iface_list = klass->GetInterfaceTypeList();
if (iface_list == nullptr) {
return nullptr;
}
diff --git a/runtime/native/java_lang_reflect_Executable.cc b/runtime/native/java_lang_reflect_Executable.cc
index ada0a64608..2ce56b5153 100644
--- a/runtime/native/java_lang_reflect_Executable.cc
+++ b/runtime/native/java_lang_reflect_Executable.cc
@@ -275,8 +275,8 @@ static jint Executable_compareMethodParametersInternal(JNIEnv* env,
this_method = this_method->GetInterfaceMethodIfProxy(kRuntimePointerSize);
other_method = other_method->GetInterfaceMethodIfProxy(kRuntimePointerSize);
- const DexFile::TypeList* this_list = this_method->GetParameterTypeList();
- const DexFile::TypeList* other_list = other_method->GetParameterTypeList();
+ const dex::TypeList* this_list = this_method->GetParameterTypeList();
+ const dex::TypeList* other_list = other_method->GetParameterTypeList();
if (this_list == other_list) {
return 0;
@@ -298,9 +298,9 @@ static jint Executable_compareMethodParametersInternal(JNIEnv* env,
}
for (int32_t i = 0; i < this_size; ++i) {
- const DexFile::TypeId& lhs = this_method->GetDexFile()->GetTypeId(
+ const dex::TypeId& lhs = this_method->GetDexFile()->GetTypeId(
this_list->GetTypeItem(i).type_idx_);
- const DexFile::TypeId& rhs = other_method->GetDexFile()->GetTypeId(
+ const dex::TypeId& rhs = other_method->GetDexFile()->GetTypeId(
other_list->GetTypeItem(i).type_idx_);
uint32_t lhs_len, rhs_len;
@@ -343,7 +343,7 @@ static jobjectArray Executable_getParameterTypesInternal(JNIEnv* env, jobject ja
ArtMethod* method = ArtMethod::FromReflectedMethod(soa, javaMethod);
method = method->GetInterfaceMethodIfProxy(kRuntimePointerSize);
- const DexFile::TypeList* params = method->GetParameterTypeList();
+ const dex::TypeList* params = method->GetParameterTypeList();
if (params == nullptr) {
return nullptr;
}
@@ -378,7 +378,7 @@ static jint Executable_getParameterCountInternal(JNIEnv* env, jobject javaMethod
ArtMethod* method = ArtMethod::FromReflectedMethod(soa, javaMethod);
method = method->GetInterfaceMethodIfProxy(kRuntimePointerSize);
- const DexFile::TypeList* params = method->GetParameterTypeList();
+ const dex::TypeList* params = method->GetParameterTypeList();
return (params == nullptr) ? 0 : params->Size();
}
diff --git a/runtime/oat_file.cc b/runtime/oat_file.cc
index de4826f417..f4a8c50a26 100644
--- a/runtime/oat_file.cc
+++ b/runtime/oat_file.cc
@@ -48,7 +48,9 @@
#include "base/unix_file/fd_file.h"
#include "base/utils.h"
#include "dex/art_dex_file_loader.h"
+#include "dex/dex_file.h"
#include "dex/dex_file_loader.h"
+#include "dex/dex_file_structs.h"
#include "dex/dex_file_types.h"
#include "dex/standard_dex_file.h"
#include "dex/type_lookup_table.h"
@@ -1831,13 +1833,13 @@ OatFile::OatClass OatDexFile::GetOatClass(uint16_t class_def_index) const {
reinterpret_cast<const OatMethodOffsets*>(methods_pointer));
}
-const DexFile::ClassDef* OatDexFile::FindClassDef(const DexFile& dex_file,
- const char* descriptor,
- size_t hash) {
+const dex::ClassDef* OatDexFile::FindClassDef(const DexFile& dex_file,
+ const char* descriptor,
+ size_t hash) {
const OatDexFile* oat_dex_file = dex_file.GetOatDexFile();
DCHECK_EQ(ComputeModifiedUtf8Hash(descriptor), hash);
bool used_lookup_table = false;
- const DexFile::ClassDef* lookup_table_classdef = nullptr;
+ const dex::ClassDef* lookup_table_classdef = nullptr;
if (LIKELY((oat_dex_file != nullptr) && oat_dex_file->GetTypeLookupTable().Valid())) {
used_lookup_table = true;
const uint32_t class_def_idx = oat_dex_file->GetTypeLookupTable().Lookup(descriptor, hash);
@@ -1854,10 +1856,10 @@ const DexFile::ClassDef* OatDexFile::FindClassDef(const DexFile& dex_file,
DCHECK(!used_lookup_table);
return nullptr;
}
- const DexFile::TypeId* type_id = dex_file.FindTypeId(descriptor);
+ const dex::TypeId* type_id = dex_file.FindTypeId(descriptor);
if (type_id != nullptr) {
dex::TypeIndex type_idx = dex_file.GetIndexForTypeId(*type_id);
- const DexFile::ClassDef* found_class_def = dex_file.FindClassDef(type_idx);
+ const dex::ClassDef* found_class_def = dex_file.FindClassDef(type_idx);
if (kIsDebugBuild && used_lookup_table) {
DCHECK_EQ(found_class_def, lookup_table_classdef);
}
diff --git a/runtime/oat_file.h b/runtime/oat_file.h
index ab6e62db97..3e9c01f9c2 100644
--- a/runtime/oat_file.h
+++ b/runtime/oat_file.h
@@ -29,7 +29,6 @@
#include "base/tracking_safe_map.h"
#include "class_status.h"
#include "compiler_filter.h"
-#include "dex/dex_file.h"
#include "dex/dex_file_layout.h"
#include "dex/type_lookup_table.h"
#include "dex/utf.h"
@@ -40,6 +39,7 @@
namespace art {
class BitVector;
+class DexFile;
class ElfFile;
class DexLayoutSections;
template <class MirrorType> class GcRoot;
@@ -50,6 +50,10 @@ class OatMethodOffsets;
class OatQuickMethodHeader;
class VdexFile;
+namespace dex {
+struct ClassDef;
+} // namespace dex
+
namespace gc {
namespace collector {
class DummyOatFile;
@@ -500,9 +504,9 @@ class OatDexFile final {
// Looks up a class definition by its class descriptor. Hash must be
// ComputeModifiedUtf8Hash(descriptor).
- static const DexFile::ClassDef* FindClassDef(const DexFile& dex_file,
- const char* descriptor,
- size_t hash);
+ static const dex::ClassDef* FindClassDef(const DexFile& dex_file,
+ const char* descriptor,
+ size_t hash);
// Madvise the dex file based on the state we are moving to.
static void MadviseDexFile(const DexFile& dex_file, MadviseState state);
diff --git a/runtime/oat_file_manager.cc b/runtime/oat_file_manager.cc
index 9552ca33f1..5aa1ea2593 100644
--- a/runtime/oat_file_manager.cc
+++ b/runtime/oat_file_manager.cc
@@ -186,7 +186,7 @@ class TypeIndexInfo {
static BitVector GenerateTypeIndexes(const DexFile* dex_file) {
BitVector type_indexes(/*start_bits=*/0, /*expandable=*/true, Allocator::GetMallocAllocator());
for (uint16_t i = 0; i < dex_file->NumClassDefs(); ++i) {
- const DexFile::ClassDef& class_def = dex_file->GetClassDef(i);
+ const dex::ClassDef& class_def = dex_file->GetClassDef(i);
uint16_t type_idx = class_def.class_idx_.index_;
type_indexes.SetBit(type_idx);
}
diff --git a/runtime/reflection.cc b/runtime/reflection.cc
index 80118365f0..dfd7e64a08 100644
--- a/runtime/reflection.cc
+++ b/runtime/reflection.cc
@@ -226,7 +226,7 @@ class ArgArray {
ArtMethod* m,
Thread* self)
REQUIRES_SHARED(Locks::mutator_lock_) {
- const DexFile::TypeList* classes = m->GetParameterTypeList();
+ const dex::TypeList* classes = m->GetParameterTypeList();
// Set receiver if non-null (method is not static)
if (receiver != nullptr) {
Append(receiver);
@@ -367,7 +367,7 @@ class ArgArray {
void CheckMethodArguments(JavaVMExt* vm, ArtMethod* m, uint32_t* args)
REQUIRES_SHARED(Locks::mutator_lock_) {
- const DexFile::TypeList* params = m->GetParameterTypeList();
+ const dex::TypeList* params = m->GetParameterTypeList();
if (params == nullptr) {
return; // No arguments so nothing to check.
}
@@ -461,7 +461,7 @@ ALWAYS_INLINE
bool CheckArgsForInvokeMethod(ArtMethod* np_method,
ObjPtr<mirror::ObjectArray<mirror::Object>> objects)
REQUIRES_SHARED(Locks::mutator_lock_) {
- const DexFile::TypeList* classes = np_method->GetParameterTypeList();
+ const dex::TypeList* classes = np_method->GetParameterTypeList();
uint32_t classes_size = (classes == nullptr) ? 0 : classes->Size();
uint32_t arg_count = (objects == nullptr) ? 0 : objects->GetLength();
if (UNLIKELY(arg_count != classes_size)) {
diff --git a/runtime/runtime_callbacks.cc b/runtime/runtime_callbacks.cc
index bf74816f24..da13eb8070 100644
--- a/runtime/runtime_callbacks.cc
+++ b/runtime/runtime_callbacks.cc
@@ -205,14 +205,14 @@ void RuntimeCallbacks::ClassPreDefine(const char* descriptor,
Handle<mirror::Class> temp_class,
Handle<mirror::ClassLoader> loader,
const DexFile& initial_dex_file,
- const DexFile::ClassDef& initial_class_def,
+ const dex::ClassDef& initial_class_def,
/*out*/DexFile const** final_dex_file,
- /*out*/DexFile::ClassDef const** final_class_def) {
+ /*out*/dex::ClassDef const** final_class_def) {
DexFile const* current_dex_file = &initial_dex_file;
- DexFile::ClassDef const* current_class_def = &initial_class_def;
+ dex::ClassDef const* current_class_def = &initial_class_def;
for (ClassLoadCallback* cb : class_callbacks_) {
DexFile const* new_dex_file = nullptr;
- DexFile::ClassDef const* new_class_def = nullptr;
+ dex::ClassDef const* new_class_def = nullptr;
cb->ClassPreDefine(descriptor,
temp_class,
loader,
diff --git a/runtime/runtime_callbacks.h b/runtime/runtime_callbacks.h
index 32ee3aa3b6..41d552ae44 100644
--- a/runtime/runtime_callbacks.h
+++ b/runtime/runtime_callbacks.h
@@ -22,11 +22,14 @@
#include "base/array_ref.h"
#include "base/locks.h"
#include "base/macros.h"
-#include "dex/dex_file.h"
#include "handle.h"
namespace art {
+namespace dex {
+struct ClassDef;
+} // namespace dex
+
namespace mirror {
class Class;
class ClassLoader;
@@ -35,6 +38,7 @@ class Object;
class ArtMethod;
class ClassLoadCallback;
+class DexFile;
class Thread;
class MethodCallback;
class Monitor;
@@ -183,9 +187,9 @@ class RuntimeCallbacks {
Handle<mirror::Class> temp_class,
Handle<mirror::ClassLoader> loader,
const DexFile& initial_dex_file,
- const DexFile::ClassDef& initial_class_def,
+ const dex::ClassDef& initial_class_def,
/*out*/DexFile const** final_dex_file,
- /*out*/DexFile::ClassDef const** final_class_def)
+ /*out*/dex::ClassDef const** final_class_def)
REQUIRES_SHARED(Locks::mutator_lock_);
void AddMethodCallback(MethodCallback* cb) REQUIRES(Locks::mutator_lock_);
diff --git a/runtime/runtime_callbacks_test.cc b/runtime/runtime_callbacks_test.cc
index d08be72402..df06a9fafd 100644
--- a/runtime/runtime_callbacks_test.cc
+++ b/runtime/runtime_callbacks_test.cc
@@ -257,9 +257,9 @@ class ClassLoadCallbackRuntimeCallbacksTest : public RuntimeCallbacksTest {
Handle<mirror::Class> klass ATTRIBUTE_UNUSED,
Handle<mirror::ClassLoader> class_loader ATTRIBUTE_UNUSED,
const DexFile& initial_dex_file,
- const DexFile::ClassDef& initial_class_def ATTRIBUTE_UNUSED,
+ const dex::ClassDef& initial_class_def ATTRIBUTE_UNUSED,
/*out*/DexFile const** final_dex_file ATTRIBUTE_UNUSED,
- /*out*/DexFile::ClassDef const** final_class_def ATTRIBUTE_UNUSED) override
+ /*out*/dex::ClassDef const** final_class_def ATTRIBUTE_UNUSED) override
REQUIRES_SHARED(Locks::mutator_lock_) {
const std::string& location = initial_dex_file.GetLocation();
std::string event =
diff --git a/runtime/transaction_test.cc b/runtime/transaction_test.cc
index 3d9afa0f15..69ded3dd3f 100644
--- a/runtime/transaction_test.cc
+++ b/runtime/transaction_test.cc
@@ -489,7 +489,7 @@ TEST_F(TransactionTest, ResolveString) {
// Go search the dex file to find the string id of our string.
static const char* kResolvedString = "ResolvedString";
- const DexFile::StringId* string_id = dex_file->FindStringId(kResolvedString);
+ const dex::StringId* string_id = dex_file->FindStringId(kResolvedString);
ASSERT_TRUE(string_id != nullptr);
dex::StringIndex string_idx = dex_file->GetIndexForStringId(*string_id);
ASSERT_TRUE(string_idx.IsValid());
diff --git a/runtime/vdex_file.cc b/runtime/vdex_file.cc
index f24711a4a1..72c42b9ee4 100644
--- a/runtime/vdex_file.cc
+++ b/runtime/vdex_file.cc
@@ -281,12 +281,12 @@ void VdexFile::UnquickenDexFile(const DexFile& target_dex_file,
return;
}
// Make sure to not unquicken the same code item multiple times.
- std::unordered_set<const DexFile::CodeItem*> unquickened_code_item;
+ std::unordered_set<const dex::CodeItem*> unquickened_code_item;
CompactOffsetTable::Accessor accessor(GetQuickenInfoOffsetTable(source_dex_begin,
quickening_info));
for (ClassAccessor class_accessor : target_dex_file.GetClasses()) {
for (const ClassAccessor::Method& method : class_accessor.GetMethods()) {
- const DexFile::CodeItem* code_item = method.GetCodeItem();
+ const dex::CodeItem* code_item = method.GetCodeItem();
if (code_item != nullptr && unquickened_code_item.emplace(code_item).second) {
const uint32_t offset = accessor.GetOffset(method.GetIndex());
// Offset being 0 means not quickened.
diff --git a/runtime/verifier/method_verifier.cc b/runtime/verifier/method_verifier.cc
index 0b33a0b3c0..167982124c 100644
--- a/runtime/verifier/method_verifier.cc
+++ b/runtime/verifier/method_verifier.cc
@@ -158,7 +158,7 @@ FailureKind MethodVerifier::VerifyClass(Thread* self,
bool early_failure = false;
std::string failure_message;
const DexFile& dex_file = klass->GetDexFile();
- const DexFile::ClassDef* class_def = klass->GetClassDef();
+ const dex::ClassDef* class_def = klass->GetClassDef();
ObjPtr<mirror::Class> super = klass->GetSuperClass();
std::string temp;
if (super == nullptr && strcmp("Ljava/lang/Object;", klass->GetDescriptor(&temp)) != 0) {
@@ -210,7 +210,7 @@ FailureKind MethodVerifier::VerifyClass(Thread* self,
const DexFile* dex_file,
Handle<mirror::DexCache> dex_cache,
Handle<mirror::ClassLoader> class_loader,
- const DexFile::ClassDef& class_def,
+ const dex::ClassDef& class_def,
CompilerCallbacks* callbacks,
bool allow_soft_failures,
HardFailLogMode log_level,
@@ -319,8 +319,8 @@ MethodVerifier::FailureData MethodVerifier::VerifyMethod(Thread* self,
const DexFile* dex_file,
Handle<mirror::DexCache> dex_cache,
Handle<mirror::ClassLoader> class_loader,
- const DexFile::ClassDef& class_def,
- const DexFile::CodeItem* code_item,
+ const dex::ClassDef& class_def,
+ const dex::CodeItem* code_item,
ArtMethod* method,
uint32_t method_access_flags,
CompilerCallbacks* callbacks,
@@ -462,8 +462,8 @@ MethodVerifier* MethodVerifier::VerifyMethodAndDump(Thread* self,
const DexFile* dex_file,
Handle<mirror::DexCache> dex_cache,
Handle<mirror::ClassLoader> class_loader,
- const DexFile::ClassDef& class_def,
- const DexFile::CodeItem* code_item,
+ const dex::ClassDef& class_def,
+ const dex::CodeItem* code_item,
ArtMethod* method,
uint32_t method_access_flags,
uint32_t api_level) {
@@ -500,8 +500,8 @@ MethodVerifier::MethodVerifier(Thread* self,
const DexFile* dex_file,
Handle<mirror::DexCache> dex_cache,
Handle<mirror::ClassLoader> class_loader,
- const DexFile::ClassDef& class_def,
- const DexFile::CodeItem* code_item,
+ const dex::ClassDef& class_def,
+ const dex::CodeItem* code_item,
uint32_t dex_method_idx,
ArtMethod* method,
uint32_t method_access_flags,
@@ -602,7 +602,7 @@ void MethodVerifier::FindLocksAtDexPc() {
bool MethodVerifier::Verify() {
// Some older code doesn't correctly mark constructors as such. Test for this case by looking at
// the name.
- const DexFile::MethodId& method_id = dex_file_->GetMethodId(dex_method_idx_);
+ const dex::MethodId& method_id = dex_file_->GetMethodId(dex_method_idx_);
const char* method_name = dex_file_->StringDataByIdx(method_id.name_idx_);
bool instance_constructor_by_name = strcmp("<init>", method_name) == 0;
bool static_constructor_by_name = strcmp("<clinit>", method_name) == 0;
@@ -917,7 +917,7 @@ bool MethodVerifier::ScanTryCatchBlocks() {
return true;
}
const uint32_t insns_size = code_item_accessor_.InsnsSizeInCodeUnits();
- for (const DexFile::TryItem& try_item : code_item_accessor_.TryItems()) {
+ for (const dex::TryItem& try_item : code_item_accessor_.TryItems()) {
const uint32_t start = try_item.start_addr_;
const uint32_t end = start + try_item.insn_count_;
if ((start >= end) || (start >= insns_size) || (end > insns_size)) {
@@ -1637,7 +1637,7 @@ bool MethodVerifier::SetTypesFromSignature() {
cur_arg++;
}
- const DexFile::ProtoId& proto_id =
+ const dex::ProtoId& proto_id =
dex_file_->GetMethodPrototype(dex_file_->GetMethodId(dex_method_idx_));
DexFileParameterIterator iterator(*dex_file_, proto_id);
@@ -1876,7 +1876,7 @@ bool MethodVerifier::CodeFlowVerifyMethod() {
// Returns the index of the first final instance field of the given class, or kDexNoIndex if there
// is no such field.
static uint32_t GetFirstFinalInstanceFieldIndex(const DexFile& dex_file, dex::TypeIndex type_idx) {
- const DexFile::ClassDef* class_def = dex_file.FindClassDef(type_idx);
+ const dex::ClassDef* class_def = dex_file.FindClassDef(type_idx);
DCHECK(class_def != nullptr);
ClassAccessor accessor(dex_file, *class_def);
for (const ClassAccessor::Field& field : accessor.GetInstanceFields()) {
@@ -2885,7 +2885,7 @@ bool MethodVerifier::CodeFlowVerifyInstruction(uint32_t* start_guess) {
}
if (return_type == nullptr) {
uint32_t method_idx = GetMethodIdxOfInvoke(inst);
- const DexFile::MethodId& method_id = dex_file_->GetMethodId(method_idx);
+ const dex::MethodId& method_id = dex_file_->GetMethodId(method_idx);
dex::TypeIndex return_type_idx =
dex_file_->GetProtoId(method_id.proto_idx_).return_type_idx_;
const char* descriptor = dex_file_->StringByTypeIdx(return_type_idx);
@@ -2908,7 +2908,7 @@ bool MethodVerifier::CodeFlowVerifyInstruction(uint32_t* start_guess) {
const RegType* return_type = nullptr;
if (called_method == nullptr) {
uint32_t method_idx = (is_range) ? inst->VRegB_3rc() : inst->VRegB_35c();
- const DexFile::MethodId& method_id = dex_file_->GetMethodId(method_idx);
+ const dex::MethodId& method_id = dex_file_->GetMethodId(method_idx);
is_constructor = strcmp("<init>", dex_file_->StringDataByIdx(method_id.name_idx_)) == 0;
dex::TypeIndex return_type_idx =
dex_file_->GetProtoId(method_id.proto_idx_).return_type_idx_;
@@ -2986,7 +2986,7 @@ bool MethodVerifier::CodeFlowVerifyInstruction(uint32_t* start_guess) {
const char* descriptor;
if (called_method == nullptr) {
uint32_t method_idx = (is_range) ? inst->VRegB_3rc() : inst->VRegB_35c();
- const DexFile::MethodId& method_id = dex_file_->GetMethodId(method_idx);
+ const dex::MethodId& method_id = dex_file_->GetMethodId(method_idx);
dex::TypeIndex return_type_idx =
dex_file_->GetProtoId(method_id.proto_idx_).return_type_idx_;
descriptor = dex_file_->StringByTypeIdx(return_type_idx);
@@ -3041,7 +3041,7 @@ bool MethodVerifier::CodeFlowVerifyInstruction(uint32_t* start_guess) {
const char* descriptor;
if (abs_method == nullptr) {
uint32_t method_idx = (is_range) ? inst->VRegB_3rc() : inst->VRegB_35c();
- const DexFile::MethodId& method_id = dex_file_->GetMethodId(method_idx);
+ const dex::MethodId& method_id = dex_file_->GetMethodId(method_idx);
dex::TypeIndex return_type_idx =
dex_file_->GetProtoId(method_id.proto_idx_).return_type_idx_;
descriptor = dex_file_->StringByTypeIdx(return_type_idx);
@@ -3106,7 +3106,7 @@ bool MethodVerifier::CodeFlowVerifyInstruction(uint32_t* start_guess) {
// method handle produced by step 1. The dex file verifier has checked ranges for
// the first three arguments and CheckCallSite has checked the method handle type.
const dex::ProtoIndex proto_idx = dex_file_->GetProtoIndexForCallSite(call_site_idx);
- const DexFile::ProtoId& proto_id = dex_file_->GetProtoId(proto_idx);
+ const dex::ProtoId& proto_id = dex_file_->GetProtoId(proto_idx);
DexFileParameterIterator param_it(*dex_file_, proto_id);
// Treat method as static as it has yet to be determined.
VerifyInvocationArgsFromIterator(&param_it, inst, METHOD_STATIC, is_range, nullptr);
@@ -3497,7 +3497,7 @@ bool MethodVerifier::CodeFlowVerifyInstruction(uint32_t* start_guess) {
*/
if ((opcode_flags & Instruction::kThrow) != 0 && GetInstructionFlags(work_insn_idx_).IsInTry()) {
bool has_catch_all_handler = false;
- const DexFile::TryItem* try_item = code_item_accessor_.FindTryItem(work_insn_idx_);
+ const dex::TryItem* try_item = code_item_accessor_.FindTryItem(work_insn_idx_);
CHECK(try_item != nullptr);
CatchHandlerIterator iterator(code_item_accessor_, *try_item);
@@ -3749,7 +3749,7 @@ const RegType& MethodVerifier::GetCaughtExceptionType() {
ArtMethod* MethodVerifier::ResolveMethodAndCheckAccess(
uint32_t dex_method_idx, MethodType method_type) {
- const DexFile::MethodId& method_id = dex_file_->GetMethodId(dex_method_idx);
+ const dex::MethodId& method_id = dex_file_->GetMethodId(dex_method_idx);
const RegType& klass_type = ResolveClass<CheckAccess::kYes>(method_id.class_idx_);
if (klass_type.IsConflict()) {
std::string append(" in attempt to access method ");
@@ -4093,7 +4093,7 @@ bool MethodVerifier::CheckCallSite(uint32_t call_site_idx) {
}
// Check method handle kind is valid.
- const DexFile::MethodHandleItem& mh = dex_file_->GetMethodHandle(index[0]);
+ const dex::MethodHandleItem& mh = dex_file_->GetMethodHandle(index[0]);
if (mh.method_handle_type_ != static_cast<uint16_t>(DexFile::MethodHandleType::kInvokeStatic)) {
Fail(VERIFY_ERROR_BAD_CLASS_HARD) << "Call site #" << call_site_idx
<< " argument 0 method handle type is not InvokeStatic: "
@@ -4125,7 +4125,7 @@ class MethodParamListDescriptorIterator {
private:
ArtMethod* res_method_;
size_t pos_;
- const DexFile::TypeList* params_;
+ const dex::TypeList* params_;
const size_t params_size_;
};
@@ -4231,7 +4231,7 @@ bool MethodVerifier::CheckSignaturePolymorphicMethod(ArtMethod* method) {
return false;
}
- const DexFile::TypeList* types = method->GetParameterTypeList();
+ const dex::TypeList* types = method->GetParameterTypeList();
if (types->Size() != 1) {
Fail(VERIFY_ERROR_BAD_CLASS_HARD)
<< "Signature polymorphic method has too many arguments " << types->Size() << " != 1";
@@ -4553,7 +4553,7 @@ void MethodVerifier::VerifyAPut(const Instruction* inst,
}
ArtField* MethodVerifier::GetStaticField(int field_idx) {
- const DexFile::FieldId& field_id = dex_file_->GetFieldId(field_idx);
+ const dex::FieldId& field_id = dex_file_->GetFieldId(field_idx);
// Check access to class
const RegType& klass_type = ResolveClass<CheckAccess::kYes>(field_id.class_idx_);
if (klass_type.IsConflict()) { // bad class
@@ -4596,7 +4596,7 @@ ArtField* MethodVerifier::GetStaticField(int field_idx) {
}
ArtField* MethodVerifier::GetInstanceField(const RegType& obj_type, int field_idx) {
- const DexFile::FieldId& field_id = dex_file_->GetFieldId(field_idx);
+ const dex::FieldId& field_id = dex_file_->GetFieldId(field_idx);
// Check access to class.
const RegType& klass_type = ResolveClass<CheckAccess::kYes>(field_id.class_idx_);
if (klass_type.IsConflict()) {
@@ -4756,7 +4756,7 @@ void MethodVerifier::VerifyISFieldAccess(const Instruction* inst, const RegType&
//
// Note: see b/34966607. This and above may be changed in the future.
if (kAccType == FieldAccessType::kAccPut) {
- const DexFile::FieldId& field_id = dex_file_->GetFieldId(field_idx);
+ const dex::FieldId& field_id = dex_file_->GetFieldId(field_idx);
const char* field_class_descriptor = dex_file_->GetFieldDeclaringClassDescriptor(field_id);
const RegType* field_class_type = &reg_types_.FromDescriptor(GetClassLoader(),
field_class_descriptor,
@@ -4772,7 +4772,7 @@ void MethodVerifier::VerifyISFieldAccess(const Instruction* inst, const RegType&
}
}
if (field_type == nullptr) {
- const DexFile::FieldId& field_id = dex_file_->GetFieldId(field_idx);
+ const dex::FieldId& field_id = dex_file_->GetFieldId(field_idx);
const char* descriptor = dex_file_->GetFieldTypeDescriptor(field_id);
field_type = &reg_types_.FromDescriptor(GetClassLoader(), descriptor, false);
}
@@ -4935,8 +4935,8 @@ const RegType& MethodVerifier::GetMethodReturnType() {
}
}
if (return_type_ == nullptr) {
- const DexFile::MethodId& method_id = dex_file_->GetMethodId(dex_method_idx_);
- const DexFile::ProtoId& proto_id = dex_file_->GetMethodPrototype(method_id);
+ const dex::MethodId& method_id = dex_file_->GetMethodId(dex_method_idx_);
+ const dex::ProtoId& proto_id = dex_file_->GetMethodPrototype(method_id);
dex::TypeIndex return_type_idx = proto_id.return_type_idx_;
const char* descriptor = dex_file_->GetTypeDescriptor(dex_file_->GetTypeId(return_type_idx));
return_type_ = &reg_types_.FromDescriptor(GetClassLoader(), descriptor, false);
@@ -4947,7 +4947,7 @@ const RegType& MethodVerifier::GetMethodReturnType() {
const RegType& MethodVerifier::GetDeclaringClass() {
if (declaring_class_ == nullptr) {
- const DexFile::MethodId& method_id = dex_file_->GetMethodId(dex_method_idx_);
+ const dex::MethodId& method_id = dex_file_->GetMethodId(dex_method_idx_);
const char* descriptor
= dex_file_->GetTypeDescriptor(dex_file_->GetTypeId(method_id.class_idx_));
if (method_being_verified_ != nullptr) {
diff --git a/runtime/verifier/method_verifier.h b/runtime/verifier/method_verifier.h
index eef22807ec..c178df05a4 100644
--- a/runtime/verifier/method_verifier.h
+++ b/runtime/verifier/method_verifier.h
@@ -26,7 +26,6 @@
#include "base/scoped_arena_containers.h"
#include "base/value_object.h"
#include "dex/code_item_accessors.h"
-#include "dex/dex_file.h"
#include "dex/dex_file_types.h"
#include "dex/method_reference.h"
#include "handle.h"
@@ -39,11 +38,17 @@ namespace art {
class ClassLinker;
class CompilerCallbacks;
+class DexFile;
class Instruction;
struct ReferenceMap2Visitor;
class Thread;
class VariableIndentationOutputStream;
+namespace dex {
+struct ClassDef;
+struct CodeItem;
+} // namespace dex
+
namespace mirror {
class DexCache;
} // namespace mirror
@@ -107,7 +112,7 @@ class MethodVerifier {
const DexFile* dex_file,
Handle<mirror::DexCache> dex_cache,
Handle<mirror::ClassLoader> class_loader,
- const DexFile::ClassDef& class_def,
+ const dex::ClassDef& class_def,
CompilerCallbacks* callbacks,
bool allow_soft_failures,
HardFailLogMode log_level,
@@ -121,8 +126,8 @@ class MethodVerifier {
const DexFile* dex_file,
Handle<mirror::DexCache> dex_cache,
Handle<mirror::ClassLoader> class_loader,
- const DexFile::ClassDef& class_def,
- const DexFile::CodeItem* code_item, ArtMethod* method,
+ const dex::ClassDef& class_def,
+ const dex::CodeItem* code_item, ArtMethod* method,
uint32_t method_access_flags,
uint32_t api_level)
REQUIRES_SHARED(Locks::mutator_lock_);
@@ -238,8 +243,8 @@ class MethodVerifier {
const DexFile* dex_file,
Handle<mirror::DexCache> dex_cache,
Handle<mirror::ClassLoader> class_loader,
- const DexFile::ClassDef& class_def,
- const DexFile::CodeItem* code_item,
+ const dex::ClassDef& class_def,
+ const dex::CodeItem* code_item,
uint32_t method_idx,
ArtMethod* method,
uint32_t access_flags,
@@ -297,8 +302,8 @@ class MethodVerifier {
const DexFile* dex_file,
Handle<mirror::DexCache> dex_cache,
Handle<mirror::ClassLoader> class_loader,
- const DexFile::ClassDef& class_def_idx,
- const DexFile::CodeItem* code_item,
+ const dex::ClassDef& class_def_idx,
+ const dex::CodeItem* code_item,
ArtMethod* method,
uint32_t method_access_flags,
CompilerCallbacks* callbacks,
@@ -716,7 +721,7 @@ class MethodVerifier {
Handle<mirror::DexCache> dex_cache_ GUARDED_BY(Locks::mutator_lock_);
// The class loader for the declaring class of the method.
Handle<mirror::ClassLoader> class_loader_ GUARDED_BY(Locks::mutator_lock_);
- const DexFile::ClassDef& class_def_; // The class def of the declaring class of the method.
+ const dex::ClassDef& class_def_; // The class def of the declaring class of the method.
const CodeItemDataAccessor code_item_accessor_;
const RegType* declaring_class_; // Lazily computed reg type of the method's declaring class.
// Instruction widths and flags, one entry per code unit.
diff --git a/runtime/verifier/method_verifier_test.cc b/runtime/verifier/method_verifier_test.cc
index 7519257cae..36890a6382 100644
--- a/runtime/verifier/method_verifier_test.cc
+++ b/runtime/verifier/method_verifier_test.cc
@@ -57,7 +57,7 @@ class MethodVerifierTest : public CommonRuntimeTest {
REQUIRES_SHARED(Locks::mutator_lock_) {
// Verify all the classes defined in this file
for (size_t i = 0; i < dex.NumClassDefs(); i++) {
- const DexFile::ClassDef& class_def = dex.GetClassDef(i);
+ const dex::ClassDef& class_def = dex.GetClassDef(i);
const char* descriptor = dex.GetClassDescriptor(class_def);
VerifyClass(descriptor);
}
diff --git a/runtime/verifier/verifier_deps.cc b/runtime/verifier/verifier_deps.cc
index d346a95e82..bdcadd9fa6 100644
--- a/runtime/verifier/verifier_deps.cc
+++ b/runtime/verifier/verifier_deps.cc
@@ -99,9 +99,9 @@ dex::StringIndex VerifierDeps::GetClassDescriptorStringId(const DexFile& dex_fil
DCHECK(dex_cache != nullptr) << klass->PrettyClass();
if (dex_cache->GetDexFile() == &dex_file) {
// FindStringId is slow, try to go through the class def if we have one.
- const DexFile::ClassDef* class_def = klass->GetClassDef();
+ const dex::ClassDef* class_def = klass->GetClassDef();
DCHECK(class_def != nullptr) << klass->PrettyClass();
- const DexFile::TypeId& type_id = dex_file.GetTypeId(class_def->class_idx_);
+ const dex::TypeId& type_id = dex_file.GetTypeId(class_def->class_idx_);
if (kIsDebugBuild) {
std::string temp;
CHECK_EQ(GetIdFromString(dex_file, klass->GetDescriptor(&temp)), type_id.descriptor_idx_);
@@ -119,9 +119,9 @@ static dex::StringIndex TryGetClassDescriptorStringId(const DexFile& dex_file,
ObjPtr<mirror::Class> klass)
REQUIRES_SHARED(Locks::mutator_lock_) {
if (!klass->IsArrayClass()) {
- const DexFile::TypeId& type_id = dex_file.GetTypeId(type_idx);
+ const dex::TypeId& type_id = dex_file.GetTypeId(type_idx);
const DexFile& klass_dex = klass->GetDexFile();
- const DexFile::TypeId& klass_type_id = klass_dex.GetTypeId(klass->GetClassDef()->class_idx_);
+ const dex::TypeId& klass_type_id = klass_dex.GetTypeId(klass->GetClassDef()->class_idx_);
if (strcmp(dex_file.GetTypeDescriptor(type_id),
klass_dex.GetTypeDescriptor(klass_type_id)) == 0) {
return type_id.descriptor_idx_;
@@ -201,7 +201,7 @@ static bool FindExistingStringId(const std::vector<std::string>& strings,
}
dex::StringIndex VerifierDeps::GetIdFromString(const DexFile& dex_file, const std::string& str) {
- const DexFile::StringId* string_id = dex_file.FindStringId(str.c_str());
+ const dex::StringId* string_id = dex_file.FindStringId(str.c_str());
if (string_id != nullptr) {
// String is in the DEX file. Return its ID.
return dex_file.GetIndexForStringId(*string_id);
@@ -805,7 +805,7 @@ void VerifierDeps::Dump(VariableIndentationOutputStream* vios) const {
}
for (const FieldResolution& entry : dep.second->fields_) {
- const DexFile::FieldId& field_id = dex_file.GetFieldId(entry.GetDexFieldIndex());
+ const dex::FieldId& field_id = dex_file.GetFieldId(entry.GetDexFieldIndex());
vios->Stream()
<< dex_file.GetFieldDeclaringClassDescriptor(field_id) << "->"
<< dex_file.GetFieldName(field_id) << ":"
@@ -823,7 +823,7 @@ void VerifierDeps::Dump(VariableIndentationOutputStream* vios) const {
}
for (const MethodResolution& method : dep.second->methods_) {
- const DexFile::MethodId& method_id = dex_file.GetMethodId(method.GetDexMethodIndex());
+ const dex::MethodId& method_id = dex_file.GetMethodId(method.GetDexMethodIndex());
vios->Stream()
<< dex_file.GetMethodDeclaringClassDescriptor(method_id) << "->"
<< dex_file.GetMethodName(method_id)
@@ -949,7 +949,7 @@ bool VerifierDeps::VerifyClasses(Handle<mirror::ClassLoader> class_loader,
}
static std::string GetFieldDescription(const DexFile& dex_file, uint32_t index) {
- const DexFile::FieldId& field_id = dex_file.GetFieldId(index);
+ const dex::FieldId& field_id = dex_file.GetFieldId(index);
return std::string(dex_file.GetFieldDeclaringClassDescriptor(field_id))
+ "->"
+ dex_file.GetFieldName(field_id)
@@ -965,7 +965,7 @@ bool VerifierDeps::VerifyFields(Handle<mirror::ClassLoader> class_loader,
// and have the same recorded flags.
ClassLinker* class_linker = Runtime::Current()->GetClassLinker();
for (const auto& entry : fields) {
- const DexFile::FieldId& field_id = dex_file.GetFieldId(entry.GetDexFieldIndex());
+ const dex::FieldId& field_id = dex_file.GetFieldId(entry.GetDexFieldIndex());
StringPiece name(dex_file.StringDataByIdx(field_id.name_idx_));
StringPiece type(dex_file.StringDataByIdx(dex_file.GetTypeId(field_id.type_idx_).descriptor_idx_));
// Only use field_id.class_idx_ when the entry is unresolved, which is rare.
@@ -1011,7 +1011,7 @@ bool VerifierDeps::VerifyFields(Handle<mirror::ClassLoader> class_loader,
}
static std::string GetMethodDescription(const DexFile& dex_file, uint32_t index) {
- const DexFile::MethodId& method_id = dex_file.GetMethodId(index);
+ const dex::MethodId& method_id = dex_file.GetMethodId(index);
return std::string(dex_file.GetMethodDeclaringClassDescriptor(method_id))
+ "->"
+ dex_file.GetMethodName(method_id)
@@ -1026,7 +1026,7 @@ bool VerifierDeps::VerifyMethods(Handle<mirror::ClassLoader> class_loader,
PointerSize pointer_size = class_linker->GetImagePointerSize();
for (const auto& entry : methods) {
- const DexFile::MethodId& method_id = dex_file.GetMethodId(entry.GetDexMethodIndex());
+ const dex::MethodId& method_id = dex_file.GetMethodId(entry.GetDexMethodIndex());
const char* name = dex_file.GetMethodName(method_id);
const Signature signature = dex_file.GetMethodSignature(method_id);
diff --git a/tools/dexanalyze/dexanalyze_bytecode.cc b/tools/dexanalyze/dexanalyze_bytecode.cc
index 88db672ad7..ae88f379c0 100644
--- a/tools/dexanalyze/dexanalyze_bytecode.cc
+++ b/tools/dexanalyze/dexanalyze_bytecode.cc
@@ -360,7 +360,7 @@ void NewRegisterInstructions::ProcessCodeItem(const DexFile& dex_file,
case Instruction::INVOKE_INTERFACE:
case Instruction::INVOKE_SUPER: {
const uint32_t method_idx = DexMethodIndex(inst.Inst());
- const DexFile::MethodId& method = dex_file.GetMethodId(method_idx);
+ const dex::MethodId& method = dex_file.GetMethodId(method_idx);
const dex::TypeIndex receiver_type = method.class_idx_;
if (Enabled(kExperimentInvoke)) {
if (count_types) {
diff --git a/tools/hiddenapi/hiddenapi.cc b/tools/hiddenapi/hiddenapi.cc
index 3e38b97889..6af822d6b6 100644
--- a/tools/hiddenapi/hiddenapi.cc
+++ b/tools/hiddenapi/hiddenapi.cc
@@ -113,7 +113,7 @@ class DexClass : public ClassAccessor {
std::set<std::string> GetInterfaceDescriptors() const {
std::set<std::string> list;
- const DexFile::TypeList* ifaces = dex_file_.GetInterfacesList(GetClassDef());
+ const dex::TypeList* ifaces = dex_file_.GetInterfacesList(GetClassDef());
for (uint32_t i = 0; ifaces != nullptr && i < ifaces->Size(); ++i) {
list.insert(dex_file_.StringByTypeIdx(ifaces->GetTypeItem(i).type_idx_));
}
@@ -201,12 +201,12 @@ class DexMember {
return down_cast<const ClassAccessor::Method&>(item_);
}
- inline const DexFile::MethodId& GetMethodId() const {
+ inline const dex::MethodId& GetMethodId() const {
DCHECK(IsMethod());
return item_.GetDexFile().GetMethodId(item_.GetIndex());
}
- inline const DexFile::FieldId& GetFieldId() const {
+ inline const dex::FieldId& GetFieldId() const {
DCHECK(!IsMethod());
return item_.GetDexFile().GetFieldId(item_.GetIndex());
}
@@ -665,7 +665,7 @@ class DexFileEditor final {
}
// Find the old MapList, find its size.
- const DexFile::MapList* old_map = old_dex_.GetMapList();
+ const dex::MapList* old_map = old_dex_.GetMapList();
CHECK_LT(old_map->size_, std::numeric_limits<uint32_t>::max());
// Compute the size of the new dex file. We append the HiddenapiClassData,
@@ -674,7 +674,7 @@ class DexFileEditor final {
<< "End of input dex file is not 4-byte aligned, possibly because its MapList is not "
<< "at the end of the file.";
size_t size_delta =
- RoundUp(hiddenapi_class_data_.size(), kMapListAlignment) + sizeof(DexFile::MapItem);
+ RoundUp(hiddenapi_class_data_.size(), kMapListAlignment) + sizeof(dex::MapItem);
size_t new_size = old_dex_.Size() + size_delta;
AllocateMemory(new_size);
@@ -742,7 +742,7 @@ class DexFileEditor final {
// Load the location of header and map list before we start editing the file.
loaded_dex_header_ = const_cast<DexFile::Header*>(&loaded_dex_->GetHeader());
- loaded_dex_maplist_ = const_cast<DexFile::MapList*>(loaded_dex_->GetMapList());
+ loaded_dex_maplist_ = const_cast<dex::MapList*>(loaded_dex_->GetMapList());
}
DexFile::Header& GetHeader() const {
@@ -750,7 +750,7 @@ class DexFileEditor final {
return *loaded_dex_header_;
}
- DexFile::MapList& GetMapList() const {
+ dex::MapList& GetMapList() const {
CHECK(loaded_dex_maplist_ != nullptr);
return *loaded_dex_maplist_;
}
@@ -804,16 +804,16 @@ class DexFileEditor final {
InsertPadding(/* alignment= */ kMapListAlignment);
size_t new_map_offset = offset_;
- DexFile::MapList* map = Append(old_dex_.GetMapList(), old_dex_.GetMapList()->Size());
+ dex::MapList* map = Append(old_dex_.GetMapList(), old_dex_.GetMapList()->Size());
// Check last map entry is a pointer to itself.
- DexFile::MapItem& old_item = map->list_[map->size_ - 1];
+ dex::MapItem& old_item = map->list_[map->size_ - 1];
CHECK(old_item.type_ == DexFile::kDexTypeMapList);
CHECK_EQ(old_item.size_, 1u);
CHECK_EQ(old_item.offset_, GetHeader().map_off_);
// Create a new MapItem entry with new MapList details.
- DexFile::MapItem new_item;
+ dex::MapItem new_item;
new_item.type_ = old_item.type_;
new_item.unused_ = 0u; // initialize to ensure dex output is deterministic (b/119308882)
new_item.size_ = old_item.size_;
@@ -824,7 +824,7 @@ class DexFileEditor final {
// Append a new MapItem and return its pointer.
map->size_++;
- Append(&new_item, sizeof(DexFile::MapItem));
+ Append(&new_item, sizeof(dex::MapItem));
// Change penultimate entry to point to metadata.
old_item.type_ = DexFile::kDexTypeHiddenapiClassData;
@@ -853,7 +853,7 @@ class DexFileEditor final {
std::unique_ptr<const DexFile> loaded_dex_;
DexFile::Header* loaded_dex_header_;
- DexFile::MapList* loaded_dex_maplist_;
+ dex::MapList* loaded_dex_maplist_;
};
class HiddenApi final {
diff --git a/tools/hiddenapi/hiddenapi_test.cc b/tools/hiddenapi/hiddenapi_test.cc
index f10d3f4e12..2689eedc10 100644
--- a/tools/hiddenapi/hiddenapi_test.cc
+++ b/tools/hiddenapi/hiddenapi_test.cc
@@ -113,17 +113,17 @@ class HiddenApiTest : public CommonRuntimeTest {
return ofs;
}
- const DexFile::ClassDef& FindClass(const char* desc, const DexFile& dex_file) {
- const DexFile::TypeId* type_id = dex_file.FindTypeId(desc);
+ const dex::ClassDef& FindClass(const char* desc, const DexFile& dex_file) {
+ const dex::TypeId* type_id = dex_file.FindTypeId(desc);
CHECK(type_id != nullptr) << "Could not find class " << desc;
- const DexFile::ClassDef* found = dex_file.FindClassDef(dex_file.GetIndexForTypeId(*type_id));
+ const dex::ClassDef* found = dex_file.FindClassDef(dex_file.GetIndexForTypeId(*type_id));
CHECK(found != nullptr) << "Could not find class " << desc;
return *found;
}
hiddenapi::ApiList GetFieldHiddenFlags(const char* name,
uint32_t expected_visibility,
- const DexFile::ClassDef& class_def,
+ const dex::ClassDef& class_def,
const DexFile& dex_file) {
ClassAccessor accessor(dex_file, class_def, /* parse hiddenapi flags */ true);
CHECK(accessor.HasClassData()) << "Class " << accessor.GetDescriptor() << " has no data";
@@ -133,7 +133,7 @@ class HiddenApiTest : public CommonRuntimeTest {
}
for (const ClassAccessor::Field& field : accessor.GetFields()) {
- const DexFile::FieldId& fid = dex_file.GetFieldId(field.GetIndex());
+ const dex::FieldId& fid = dex_file.GetFieldId(field.GetIndex());
if (strcmp(name, dex_file.GetFieldName(fid)) == 0) {
const uint32_t actual_visibility = field.GetAccessFlags() & kAccVisibilityFlags;
CHECK_EQ(actual_visibility, expected_visibility)
@@ -150,7 +150,7 @@ class HiddenApiTest : public CommonRuntimeTest {
hiddenapi::ApiList GetMethodHiddenFlags(const char* name,
uint32_t expected_visibility,
bool expected_native,
- const DexFile::ClassDef& class_def,
+ const dex::ClassDef& class_def,
const DexFile& dex_file) {
ClassAccessor accessor(dex_file, class_def, /* parse hiddenapi flags */ true);
CHECK(accessor.HasClassData()) << "Class " << accessor.GetDescriptor() << " has no data";
@@ -160,7 +160,7 @@ class HiddenApiTest : public CommonRuntimeTest {
}
for (const ClassAccessor::Method& method : accessor.GetMethods()) {
- const DexFile::MethodId& mid = dex_file.GetMethodId(method.GetIndex());
+ const dex::MethodId& mid = dex_file.GetMethodId(method.GetIndex());
if (strcmp(name, dex_file.GetMethodName(mid)) == 0) {
CHECK_EQ(expected_native, method.MemberIsNative())
<< "Method " << name << " in class " << accessor.GetDescriptor();
diff --git a/tools/veridex/flow_analysis.cc b/tools/veridex/flow_analysis.cc
index 1fca7e1ae7..65f236325e 100644
--- a/tools/veridex/flow_analysis.cc
+++ b/tools/veridex/flow_analysis.cc
@@ -131,15 +131,15 @@ const RegisterValue& VeriFlowAnalysis::GetRegister(uint32_t dex_register) const
RegisterValue VeriFlowAnalysis::GetReturnType(uint32_t method_index) {
const DexFile& dex_file = resolver_->GetDexFile();
- const DexFile::MethodId& method_id = dex_file.GetMethodId(method_index);
- const DexFile::ProtoId& proto_id = dex_file.GetMethodPrototype(method_id);
+ const dex::MethodId& method_id = dex_file.GetMethodId(method_index);
+ const dex::ProtoId& proto_id = dex_file.GetMethodPrototype(method_id);
VeriClass* cls = resolver_->GetVeriClass(proto_id.return_type_idx_);
return RegisterValue(RegisterSource::kMethod, DexFileReference(&dex_file, method_index), cls);
}
RegisterValue VeriFlowAnalysis::GetFieldType(uint32_t field_index) {
const DexFile& dex_file = resolver_->GetDexFile();
- const DexFile::FieldId& field_id = dex_file.GetFieldId(field_index);
+ const dex::FieldId& field_id = dex_file.GetFieldId(field_index);
VeriClass* cls = resolver_->GetVeriClass(field_id.type_idx_);
return RegisterValue(RegisterSource::kField, DexFileReference(&dex_file, field_index), cls);
}
@@ -716,7 +716,7 @@ RegisterValue FlowAnalysisCollector::AnalyzeInvoke(const Instruction& instructio
RegisterValue obj = GetRegister(GetParameterAt(instruction, is_range, args, 0));
const VeriClass* cls = obj.GetType();
if (cls != nullptr && cls->GetClassDef() != nullptr) {
- const DexFile::ClassDef* def = cls->GetClassDef();
+ const dex::ClassDef* def = cls->GetClassDef();
return RegisterValue(
RegisterSource::kClass,
DexFileReference(&resolver_->GetDexFileOf(*cls), def->class_idx_.index_),
diff --git a/tools/veridex/hidden_api.cc b/tools/veridex/hidden_api.cc
index 6a04365a3a..2af7b50a73 100644
--- a/tools/veridex/hidden_api.cc
+++ b/tools/veridex/hidden_api.cc
@@ -78,7 +78,7 @@ void HiddenApi::AddSignatureToApiList(const std::string& signature, hiddenapi::A
std::string HiddenApi::GetApiMethodName(const DexFile& dex_file, uint32_t method_index) {
std::stringstream ss;
- const DexFile::MethodId& method_id = dex_file.GetMethodId(method_index);
+ const dex::MethodId& method_id = dex_file.GetMethodId(method_index);
ss << dex_file.StringByTypeIdx(method_id.class_idx_)
<< "->"
<< dex_file.GetMethodName(method_id)
@@ -88,7 +88,7 @@ std::string HiddenApi::GetApiMethodName(const DexFile& dex_file, uint32_t method
std::string HiddenApi::GetApiFieldName(const DexFile& dex_file, uint32_t field_index) {
std::stringstream ss;
- const DexFile::FieldId& field_id = dex_file.GetFieldId(field_index);
+ const dex::FieldId& field_id = dex_file.GetFieldId(field_index);
ss << dex_file.StringByTypeIdx(field_id.class_idx_)
<< "->"
<< dex_file.GetFieldName(field_id)
diff --git a/tools/veridex/resolver.cc b/tools/veridex/resolver.cc
index 56729fffd0..0d769cda31 100644
--- a/tools/veridex/resolver.cc
+++ b/tools/veridex/resolver.cc
@@ -46,7 +46,7 @@ void VeridexResolver::Run() {
}
static bool HasSameNameAndSignature(const DexFile& dex_file,
- const DexFile::MethodId& method_id,
+ const dex::MethodId& method_id,
const char* method_name,
const char* type) {
return strcmp(method_name, dex_file.GetMethodName(method_id)) == 0 &&
@@ -54,7 +54,7 @@ static bool HasSameNameAndSignature(const DexFile& dex_file,
}
static bool HasSameNameAndSignature(const DexFile& dex_file,
- const DexFile::MethodId& method_id,
+ const dex::MethodId& method_id,
const char* method_name,
const Signature& signature) {
return strcmp(method_name, dex_file.GetMethodName(method_id)) == 0 &&
@@ -62,7 +62,7 @@ static bool HasSameNameAndSignature(const DexFile& dex_file,
}
static bool HasSameNameAndType(const DexFile& dex_file,
- const DexFile::FieldId& field_id,
+ const dex::FieldId& field_id,
const char* field_name,
const char* field_type) {
return strcmp(field_name, dex_file.GetFieldName(field_id)) == 0 &&
@@ -139,7 +139,7 @@ VeriMethod VeridexResolver::LookupMethodIn(const VeriClass& kls,
const DexFile& other_dex_file = resolver->dex_file_;
ClassAccessor other_dex_accessor(other_dex_file, *kls.GetClassDef());
for (const ClassAccessor::Method& method : other_dex_accessor.GetMethods()) {
- const DexFile::MethodId& other_method_id = other_dex_file.GetMethodId(method.GetIndex());
+ const dex::MethodId& other_method_id = other_dex_file.GetMethodId(method.GetIndex());
if (HasSameNameAndSignature(other_dex_file,
other_method_id,
method_name,
@@ -160,7 +160,7 @@ VeriMethod VeridexResolver::LookupMethodIn(const VeriClass& kls,
}
// Look at methods in `kls`'s interface hierarchy.
- const DexFile::TypeList* interfaces = other_dex_file.GetInterfacesList(*kls.GetClassDef());
+ const dex::TypeList* interfaces = other_dex_file.GetInterfacesList(*kls.GetClassDef());
if (interfaces != nullptr) {
for (size_t i = 0; i < interfaces->Size(); i++) {
dex::TypeIndex idx = interfaces->GetTypeItem(i).type_idx_;
@@ -194,7 +194,7 @@ VeriField VeridexResolver::LookupFieldIn(const VeriClass& kls,
const DexFile& other_dex_file = resolver->dex_file_;
ClassAccessor other_dex_accessor(other_dex_file, *kls.GetClassDef());
for (const ClassAccessor::Field& field : other_dex_accessor.GetFields()) {
- const DexFile::FieldId& other_field_id = other_dex_file.GetFieldId(field.GetIndex());
+ const dex::FieldId& other_field_id = other_dex_file.GetFieldId(field.GetIndex());
if (HasSameNameAndType(other_dex_file,
other_field_id,
field_name,
@@ -204,7 +204,7 @@ VeriField VeridexResolver::LookupFieldIn(const VeriClass& kls,
}
// Look at fields in `kls`'s interface hierarchy.
- const DexFile::TypeList* interfaces = other_dex_file.GetInterfacesList(*kls.GetClassDef());
+ const dex::TypeList* interfaces = other_dex_file.GetInterfacesList(*kls.GetClassDef());
if (interfaces != nullptr) {
for (size_t i = 0; i < interfaces->Size(); i++) {
dex::TypeIndex idx = interfaces->GetTypeItem(i).type_idx_;
@@ -258,7 +258,7 @@ VeriMethod VeridexResolver::GetMethod(uint32_t method_index) {
VeriMethod method_info = method_infos_[method_index];
if (method_info == nullptr) {
// Method is defined in another dex file.
- const DexFile::MethodId& method_id = dex_file_.GetMethodId(method_index);
+ const dex::MethodId& method_id = dex_file_.GetMethodId(method_index);
VeriClass* kls = GetVeriClass(method_id.class_idx_);
if (kls == nullptr) {
return nullptr;
@@ -276,7 +276,7 @@ VeriField VeridexResolver::GetField(uint32_t field_index) {
VeriField field_info = field_infos_[field_index];
if (field_info == nullptr) {
// Field is defined in another dex file.
- const DexFile::FieldId& field_id = dex_file_.GetFieldId(field_index);
+ const dex::FieldId& field_id = dex_file_.GetFieldId(field_index);
VeriClass* kls = GetVeriClass(field_id.class_idx_);
if (kls == nullptr) {
return nullptr;
diff --git a/tools/veridex/veridex.h b/tools/veridex/veridex.h
index e0d82616ae..f02de96150 100644
--- a/tools/veridex/veridex.h
+++ b/tools/veridex/veridex.h
@@ -19,11 +19,14 @@
#include <map>
-#include "dex/dex_file.h"
#include "dex/primitive.h"
namespace art {
+namespace dex {
+struct ClassDef;
+} // namespace dex
+
static int gTargetSdkVersion = 1000; // Will be initialized after parsing options.
/**
@@ -45,7 +48,7 @@ using VeriMethod = const uint8_t*;
class VeriClass {
public:
VeriClass() = default;
- VeriClass(Primitive::Type k, uint8_t dims, const DexFile::ClassDef* cl)
+ VeriClass(Primitive::Type k, uint8_t dims, const dex::ClassDef* cl)
: kind_(k), dimensions_(dims), class_def_(cl) {}
bool IsUninitialized() const {
@@ -62,7 +65,7 @@ class VeriClass {
Primitive::Type GetKind() const { return kind_; }
uint8_t GetDimensions() const { return dimensions_; }
- const DexFile::ClassDef* GetClassDef() const { return class_def_; }
+ const dex::ClassDef* GetClassDef() const { return class_def_; }
static VeriClass* object_;
static VeriClass* class_;
@@ -92,7 +95,7 @@ class VeriClass {
private:
Primitive::Type kind_;
uint8_t dimensions_;
- const DexFile::ClassDef* class_def_;
+ const dex::ClassDef* class_def_;
};
inline bool IsGetMethod(VeriMethod method) {