Implement DexFile_getClassNameList
Change-Id: I9b48628e338a5346bc3ac21f3469e4e3d224a956
diff --git a/src/dalvik_system_DexFile.cc b/src/dalvik_system_DexFile.cc
index 67ff27f..cad1acd 100644
--- a/src/dalvik_system_DexFile.cc
+++ b/src/dalvik_system_DexFile.cc
@@ -19,6 +19,7 @@
#include "dex_file.h"
#include "logging.h"
#include "runtime.h"
+#include "toStringArray.h"
#include "ScopedUtfChars.h"
#include "JniConstants.h" // Last to avoid problems with LOG redefinition.
@@ -144,13 +145,23 @@
if (dex_file == NULL) {
return NULL;
}
- UNIMPLEMENTED(ERROR);
- return NULL;
+
+ std::vector<std::string> class_names;
+ for (size_t i = 0; i < dex_file->NumClassDefs(); ++i) {
+ const DexFile::ClassDef& class_def = dex_file->GetClassDef(i);
+ const char* descriptor = dex_file->GetClassDescriptor(class_def);
+ class_names.push_back(DescriptorToDot(descriptor));
+ }
+ return toStringArray(env, class_names);
}
jboolean DexFile_isDexOptNeeded(JNIEnv* env, jclass, jstring javaFilename) {
- // TODO: run dex2oat?
- UNIMPLEMENTED(WARNING);
+ ScopedUtfChars filename(env, javaFilename);
+ if (filename.c_str() == NULL) {
+ return JNI_FALSE;
+ }
+ // TODO: return true if we need to extract dex or run dex2oat
+ UNIMPLEMENTED(WARNING) << filename.c_str();
return JNI_FALSE;
}
diff --git a/src/runtime_support.cc b/src/runtime_support.cc
index 8608eff..ba3e1b4 100644
--- a/src/runtime_support.cc
+++ b/src/runtime_support.cc
@@ -182,7 +182,7 @@
const DexFile& dex_file = class_linker->FindDexFile(method->GetDeclaringClass()->GetDexCache());
const DexFile::FieldId& id = dex_file.GetFieldId(ref);
- std::string class_name(PrettyDescriptor(dex_file.dexStringByTypeIdx(id.class_idx_)));
+ std::string class_name(PrettyDescriptor(dex_file.GetFieldClassDescriptor(id)));
const char* field_name = dex_file.dexStringById(id.name_idx_);
if (!access) {
return class_name + "." + field_name;
@@ -204,7 +204,7 @@
const DexFile& dex_file = class_linker->FindDexFile(method->GetDeclaringClass()->GetDexCache());
const DexFile::MethodId& id = dex_file.GetMethodId(ref);
- std::string class_name(PrettyDescriptor(dex_file.dexStringByTypeIdx(id.class_idx_)));
+ std::string class_name(PrettyDescriptor(dex_file.GetMethodClassDescriptor(id)));
const char* method_name = dex_file.dexStringById(id.name_idx_);
if (!access) {
return class_name + "." + method_name;