Revert "Plug leak in class initialization."
This reverts commit d07cf9d69dddeebb91386a88f7b6d2323cf125a9.
Bug: 2664424
Change-Id: I1a36469757f2f20fb29b3bcf04e2a23aa7b72dca
diff --git a/vm/oo/Class.c b/vm/oo/Class.c
index 958bb52..625a572 100644
--- a/vm/oo/Class.c
+++ b/vm/oo/Class.c
@@ -4207,11 +4207,6 @@
*
* We will often be called recursively, e.g. when the <clinit> code resolves
* one of its fields, the field resolution will try to initialize the class.
- * In that case we will return "true" even though the class isn't actually
- * ready to go. The ambiguity can be resolved with dvmIsClassInitializing().
- * (TODO: consider having this return an enum to avoid the extra call --
- * return -1 on failure, 0 on success, 1 on still-initializing. Looks like
- * dvmIsClassInitializing() is always paired with *Initialized())
*
* This can get very interesting if a class has a static field initialized
* to a new instance of itself. <clinit> will end up calling <init> on
diff --git a/vm/oo/Resolve.c b/vm/oo/Resolve.c
index 513a282..68fdd51 100644
--- a/vm/oo/Resolve.c
+++ b/vm/oo/Resolve.c
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
/*
* Resolve classes, methods, fields, and strings.
*
@@ -257,21 +256,10 @@
}
/*
- * If the class has been initialized, add a pointer to our data structure
- * so we don't have to jump through the hoops again. If this is a
- * static method and the defining class is still initializing (i.e. this
- * thread is executing <clinit>), don't do the store, otherwise other
- * threads could call the method without waiting for class init to finish.
+ * The class is initialized, the method has been found. Add a pointer
+ * to our data structure so we don't have to jump through the hoops again.
*/
- if (methodType == METHOD_STATIC && !dvmIsClassInitialized(resMethod->clazz))
- {
- LOGVV("--- not caching resolved method %s.%s (class init=%d/%d)\n",
- resMethod->clazz->descriptor, resMethod->name,
- dvmIsClassInitializing(resMethod->clazz),
- dvmIsClassInitialized(resMethod->clazz));
- } else {
- dvmDexSetResolvedMethod(pDvmDex, methodIdx, resMethod);
- }
+ dvmDexSetResolvedMethod(pDvmDex, methodIdx, resMethod);
return resMethod;
}
@@ -378,11 +366,8 @@
//assert(dvmIsClassInitialized(resMethod->clazz));
/*
- * Add a pointer to our data structure so we don't have to jump
- * through the hoops again.
- *
- * As noted above, no need to worry about whether the interface that
- * defines the method has been or is currently executing <clinit>.
+ * The class is initialized, the method has been found. Add a pointer
+ * to our data structure so we don't have to jump through the hoops again.
*/
dvmDexSetResolvedMethod(pDvmDex, methodIdx, resMethod);
@@ -434,14 +419,8 @@
dvmIsClassInitializing(resField->field.clazz));
/*
- * The class is initialized (or initializing), the field has been
- * found. Add a pointer to our data structure so we don't have to
- * jump through the hoops again.
- *
- * Anything that uses the resolved table entry must have an instance
- * of the class, so any class init activity has already happened (or
- * been deliberately bypassed when <clinit> created an instance).
- * So it's always okay to update the table.
+ * The class is initialized, the method has been found. Add a pointer
+ * to our data structure so we don't have to jump through the hoops again.
*/
dvmDexSetResolvedField(pDvmDex, ifieldIdx, (Field*)resField);
LOGVV(" field %u is %s.%s\n",
@@ -497,20 +476,10 @@
}
/*
- * If the class has been initialized, add a pointer to our data structure
- * so we don't have to jump through the hoops again. If it's still
- * initializing (i.e. this thread is executing <clinit>), don't do
- * the store, otherwise other threads could use the field without waiting
- * for class init to finish.
+ * The class is initialized, the method has been found. Add a pointer
+ * to our data structure so we don't have to jump through the hoops again.
*/
- if (dvmIsClassInitialized(resField->field.clazz)) {
- dvmDexSetResolvedField(pDvmDex, sfieldIdx, (Field*) resField);
- } else {
- LOGVV("--- not caching resolved field %s.%s (class init=%d/%d)\n",
- resField->field.clazz->descriptor, resField->field.name,
- dvmIsClassInitializing(resField->field.clazz),
- dvmIsClassInitialized(resField->field.clazz));
- }
+ dvmDexSetResolvedField(pDvmDex, sfieldIdx, (Field*) resField);
return resField;
}