Address various dex2oat hangs
class_linker.cc - add support for no such field error
dex_verifier.cc - address cases where type information isn't available
due to verification errors
dex_verifier.h - support for monitor nesting upto 64 deep
These changes address Bug: 5742499, Bug: 5743100, Bug: 5742810
Change-Id: I2e9a77059314c84f21ad5d194bad77c7f2fa2ee9
diff --git a/src/class_linker.cc b/src/class_linker.cc
index e32f8a5..04a368d8 100644
--- a/src/class_linker.cc
+++ b/src/class_linker.cc
@@ -59,13 +59,12 @@
va_end(args);
}
-void ThrowNoSuchMethodError(const char* kind,
- Class* c, const StringPiece& name, const StringPiece& signature) {
+void ThrowNoSuchMethodError(bool is_direct, Class* c, const StringPiece& name,
+ const StringPiece& signature) {
ClassHelper kh(c);
std::ostringstream msg;
- msg << "no " << kind << " method " << name << "." << signature
- << " in class " << kh.GetDescriptor()
- << " or its superclasses";
+ msg << "no " << (is_direct ? "direct" : "virtual") << " method " << name << "." << signature
+ << " in class " << kh.GetDescriptor() << " or its superclasses";
std::string location(kh.GetLocation());
if (!location.empty()) {
msg << " (defined in " << location << ")";
@@ -73,6 +72,19 @@
Thread::Current()->ThrowNewException("Ljava/lang/NoSuchMethodError;", msg.str().c_str());
}
+void ThrowNoSuchFieldError(bool is_static, Class* c, const StringPiece& type,
+ const StringPiece& name) {
+ ClassHelper kh(c);
+ std::ostringstream msg;
+ msg << "no " << (is_static ? "static": "instance") << " field " << name << " of type " << type
+ << " in class " << kh.GetDescriptor() << " or its superclasses";
+ std::string location(kh.GetLocation());
+ if (!location.empty()) {
+ msg << " (defined in " << location << ")";
+ }
+ Thread::Current()->ThrowNewException("Ljava/lang/NoSuchFieldError;", msg.str().c_str());
+}
+
void ThrowEarlierClassFailure(Class* c) {
/*
* The class failed to initialize on a previous attempt, so we want to throw
@@ -2770,7 +2782,7 @@
if (resolved != NULL) {
dex_cache->SetResolvedMethod(method_idx, resolved);
} else {
- ThrowNoSuchMethodError(is_direct ? "direct" : "virtual", klass, name, signature);
+ ThrowNoSuchMethodError(is_direct, klass, name, signature);
}
return resolved;
}
@@ -2787,6 +2799,7 @@
const DexFile::FieldId& field_id = dex_file.GetFieldId(field_idx);
Class* klass = ResolveType(dex_file, field_id.class_idx_, dex_cache, class_loader);
if (klass == NULL) {
+ DCHECK(Thread::Current()->IsExceptionPending());
return NULL;
}
@@ -2800,9 +2813,7 @@
if (resolved != NULL) {
dex_cache->SetResolvedField(field_idx, resolved);
} else {
- // TODO: this check fails when the app class path contains a class from the boot class path
- CHECK(Thread::Current()->IsExceptionPending())
- << PrettyClass(klass) << " " << name << " " << type << " " << is_static;
+ ThrowNoSuchFieldError(is_static, klass, type, name);
}
return resolved;
}