Merge "Revert "Remove dexCacheResolvedMethods from Method/Constructor"" into dalvik-dev
diff --git a/src/dalvik_system_DexFile.cc b/src/dalvik_system_DexFile.cc
index a255141..713639f 100644
--- a/src/dalvik_system_DexFile.cc
+++ b/src/dalvik_system_DexFile.cc
@@ -124,7 +124,8 @@
delete dex_file;
}
-jclass DexFile_defineClass(JNIEnv* env, jclass, jstring javaName, jobject javaLoader, jint cookie) {
+jclass DexFile_defineClassNative(JNIEnv* env, jclass, jstring javaName, jobject javaLoader,
+ jint cookie) {
ScopedThreadStateChange tsc(Thread::Current(), Thread::kRunnable);
const DexFile* dex_file = toDexFile(env, cookie);
if (dex_file == NULL) {
@@ -145,20 +146,6 @@
ClassLinker* class_linker = Runtime::Current()->GetClassLinker();
class_linker->RegisterDexFile(*dex_file);
Class* result = class_linker->DefineClass(descriptor, class_loader, *dex_file, *dex_class_def);
- if (env->ExceptionCheck()) {
- // Swallow any ClassNotFoundException or NoClassDefFoundError; the contract with the caller
- // is that we return null if the class is not found.
- jthrowable exception = env->ExceptionOccurred();
- env->ExceptionClear();
-
- static jclass ClassNotFoundException_class = CacheClass(env, "java/lang/ClassNotFoundException");
- static jclass NoClassDefFoundError_class = CacheClass(env, "java/lang/NoClassDefFoundError");
-
- if (!env->IsInstanceOf(exception, ClassNotFoundException_class) && !env->IsInstanceOf(exception, NoClassDefFoundError_class)) {
- env->Throw(exception);
- }
- return NULL;
- }
return AddLocalReference<jclass>(env, result);
}
@@ -223,7 +210,7 @@
static JNINativeMethod gMethods[] = {
NATIVE_METHOD(DexFile, closeDexFile, "(I)V"),
- NATIVE_METHOD(DexFile, defineClass, "(Ljava/lang/String;Ljava/lang/ClassLoader;I)Ljava/lang/Class;"),
+ NATIVE_METHOD(DexFile, defineClassNative, "(Ljava/lang/String;Ljava/lang/ClassLoader;I)Ljava/lang/Class;"),
NATIVE_METHOD(DexFile, getClassNameList, "(I)[Ljava/lang/String;"),
NATIVE_METHOD(DexFile, isDexOptNeeded, "(Ljava/lang/String;)Z"),
NATIVE_METHOD(DexFile, openDexFile, "(Ljava/lang/String;Ljava/lang/String;I)I"),
diff --git a/src/debugger.cc b/src/debugger.cc
index 4c47e00..40405eb 100644
--- a/src/debugger.cc
+++ b/src/debugger.cc
@@ -612,13 +612,14 @@
return 0;
}
-bool Dbg::GetSignature(JDWP::RefTypeId refTypeId, std::string& signature) {
- Object* o = gRegistry->Get<Object*>(refTypeId);
- if (o == NULL || !o->IsClass()) {
- return false;
+JDWP::JdwpError Dbg::GetSignature(JDWP::RefTypeId refTypeId, std::string& signature) {
+ JDWP::JdwpError status;
+ Class* c = DecodeClass(refTypeId, status);
+ if (c == NULL) {
+ return status;
}
- signature = ClassHelper(o->AsClass()).GetDescriptor();
- return true;
+ signature = ClassHelper(c).GetDescriptor();
+ return JDWP::ERR_NONE;
}
bool Dbg::GetSourceFile(JDWP::RefTypeId refTypeId, std::string& result) {
diff --git a/src/debugger.h b/src/debugger.h
index b92fbfe..8a702a1 100644
--- a/src/debugger.h
+++ b/src/debugger.h
@@ -140,7 +140,7 @@
static void FindLoadedClassBySignature(const char* descriptor, std::vector<JDWP::RefTypeId>& ids);
static void GetObjectType(JDWP::ObjectId objectId, JDWP::JdwpTypeTag* pRefTypeTag, JDWP::RefTypeId* pRefTypeId);
static uint8_t GetClassObjectType(JDWP::RefTypeId refTypeId);
- static bool GetSignature(JDWP::RefTypeId refTypeId, std::string& signature);
+ static JDWP::JdwpError GetSignature(JDWP::RefTypeId refTypeId, std::string& signature);
static bool GetSourceFile(JDWP::RefTypeId refTypeId, std::string& source_file);
static uint8_t GetObjectTag(JDWP::ObjectId objectId);
static size_t GetTagWidth(JDWP::JdwpTag tag);
diff --git a/src/jdwp/jdwp_handler.cc b/src/jdwp/jdwp_handler.cc
index 5e4487c..99916bd 100644
--- a/src/jdwp/jdwp_handler.cc
+++ b/src/jdwp/jdwp_handler.cc
@@ -416,10 +416,7 @@
return ERR_NONE;
}
-/*
- * Cough up the complete list of classes.
- */
-static JdwpError handleVM_AllClassesWithGeneric(JdwpState* state, const uint8_t* buf, int dataLen, ExpandBuf* pReply) {
+static JdwpError handleVM_AllClasses(JdwpState* state, const uint8_t* buf, int dataLen, ExpandBuf* pReply, bool generic) {
std::vector<JDWP::RefTypeId> classes;
Dbg::GetClassList(classes);
@@ -437,13 +434,23 @@
expandBufAdd1(pReply, refTypeTag);
expandBufAddRefTypeId(pReply, classes[i]);
expandBufAddUtf8String(pReply, descriptor);
- expandBufAddUtf8String(pReply, genericSignature);
+ if (generic) {
+ expandBufAddUtf8String(pReply, genericSignature);
+ }
expandBufAdd4BE(pReply, status);
}
return ERR_NONE;
}
+static JdwpError handleVM_AllClasses(JdwpState* state, const uint8_t* buf, int dataLen, ExpandBuf* pReply) {
+ return handleVM_AllClasses(state, buf, dataLen, pReply, false);
+}
+
+static JdwpError handleVM_AllClassesWithGeneric(JdwpState* state, const uint8_t* buf, int dataLen, ExpandBuf* pReply) {
+ return handleVM_AllClasses(state, buf, dataLen, pReply, true);
+}
+
/*
* Given a referenceTypeID, return a string with the JNI reference type
* signature (e.g. "Ljava/lang/Error;").
@@ -453,8 +460,10 @@
VLOG(jdwp) << StringPrintf(" Req for signature of refTypeId=0x%llx", refTypeId);
std::string signature;
- if (!Dbg::GetSignature(refTypeId, signature)) {
- return ERR_INVALID_CLASS;
+
+ JdwpError status = Dbg::GetSignature(refTypeId, signature);
+ if (status != ERR_NONE) {
+ return status;
}
expandBufAddUtf8String(pReply, signature);
return ERR_NONE;
@@ -1563,7 +1572,7 @@
/* VirtualMachine command set (1) */
{ 1, 1, handleVM_Version, "VirtualMachine.Version" },
{ 1, 2, handleVM_ClassesBySignature, "VirtualMachine.ClassesBySignature" },
- { 1, 3, NULL, "VirtualMachine.AllClasses" },
+ { 1, 3, handleVM_AllClasses, "VirtualMachine.AllClasses" },
{ 1, 4, handleVM_AllThreads, "VirtualMachine.AllThreads" },
{ 1, 5, handleVM_TopLevelThreadGroups, "VirtualMachine.TopLevelThreadGroups" },
{ 1, 6, handleVM_Dispose, "VirtualMachine.Dispose" },