Merge "Fix Class.getDeclaringClass bug"
diff --git a/vm/native/java_lang_Class.cpp b/vm/native/java_lang_Class.cpp
index e68be7b..8687138 100644
--- a/vm/native/java_lang_Class.cpp
+++ b/vm/native/java_lang_Class.cpp
@@ -577,21 +577,6 @@
}
/*
- * public Class getDeclaringClass()
- *
- * Get the class that encloses this class (if any).
- */
-static void Dalvik_java_lang_Class_getDeclaringClass(const u4* args,
- JValue* pResult)
-{
- ClassObject* clazz = (ClassObject*) args[0];
-
- ClassObject* enclosing = dvmGetDeclaringClass(clazz);
- dvmReleaseTrackedAlloc((Object*) enclosing, NULL);
- RETURN_PTR(enclosing);
-}
-
-/*
* public Class getEnclosingClass()
*
* Get the class that encloses this class (if any).
@@ -699,6 +684,27 @@
}
/*
+ * public Class getDeclaringClass()
+ *
+ * Get the class that encloses this class (if any).
+ */
+static void Dalvik_java_lang_Class_getDeclaringClass(const u4* args,
+ JValue* pResult)
+{
+ JValue isAnonymousClass;
+ Dalvik_java_lang_Class_isAnonymousClass(args, &isAnonymousClass);
+ if (isAnonymousClass.z) {
+ RETURN_PTR(NULL);
+ }
+
+ ClassObject* clazz = (ClassObject*) args[0];
+
+ ClassObject* enclosing = dvmGetDeclaringClass(clazz);
+ dvmReleaseTrackedAlloc((Object*) enclosing, NULL);
+ RETURN_PTR(enclosing);
+}
+
+/*
* private Annotation[] getDeclaredAnnotations()
*
* Return the annotations declared on this class.