OSDN Git Service

am beeeb788: am 05fa5fd5: Merge "Simplify merges of the annotation code."
[android-x86/dalvik.git] / vm / Exception.cpp
index de6d9a9..ca76140 100644 (file)
@@ -1271,13 +1271,10 @@ void dvmThrowChainedClassNotFoundException(const char* name, Object* cause) {
 void dvmThrowExceptionInInitializerError()
 {
     /*
-     * TODO: Do we want to wrap it if the original is an Error rather than
-     * an Exception?
-     *
      * TODO: Should this just use dvmWrapException()?
      */
 
-    if (gDvm.exExceptionInInitializerError == NULL) {
+    if (gDvm.exExceptionInInitializerError == NULL || gDvm.exError == NULL) {
         /*
          * ExceptionInInitializerError isn't itself initialized. This
          * can happen very early during VM startup if there is a
@@ -1294,6 +1291,11 @@ void dvmThrowExceptionInInitializerError()
     Thread* self = dvmThreadSelf();
     Object* exception = dvmGetException(self);
 
+    // We only wrap non-Error exceptions; an Error can just be used as-is.
+    if (dvmInstanceof(exception->clazz, gDvm.exError)) {
+        return;
+    }
+
     dvmAddTrackedAlloc(exception, self);
     dvmClearException(self);