diff options
| author | 2013-12-13 17:39:59 -0800 | |
|---|---|---|
| committer | 2013-12-13 17:49:00 -0800 | |
| commit | 2d7e5aa6c707537f1906ed77b0ff29ec3dd261f7 (patch) | |
| tree | ede87a07e14bc8f596604639b06c6b133ee1be0f | |
| parent | 03d7e9af6ccec24c12f63c0e6b777de412cbb8b1 (diff) | |
Add classes that fail verification early to rejected class list.
Change-Id: I5e06ec2dc3dfd061fcd6c099e10991482a1aaf65
| -rw-r--r-- | runtime/verifier/method_verifier.cc | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/runtime/verifier/method_verifier.cc b/runtime/verifier/method_verifier.cc index 9183b5f53c..59ead892e1 100644 --- a/runtime/verifier/method_verifier.cc +++ b/runtime/verifier/method_verifier.cc @@ -90,28 +90,28 @@ MethodVerifier::FailureKind MethodVerifier::VerifyClass(const mirror::Class* kla if (klass->IsVerified()) { return kNoFailure; } - mirror::Class* super = klass->GetSuperClass(); - if (super == NULL && strcmp("Ljava/lang/Object;", ClassHelper(klass).GetDescriptor()) != 0) { - *error = "Verifier rejected class "; - *error += PrettyDescriptor(klass); - *error += " that has no super class"; - return kHardFailure; - } - if (super != NULL && super->IsFinal()) { - *error = "Verifier rejected class "; - *error += PrettyDescriptor(klass); - *error += " that attempts to sub-class final class "; - *error += PrettyDescriptor(super); - return kHardFailure; - } + bool early_failure = false; + std::string failure_message; ClassHelper kh(klass); const DexFile& dex_file = kh.GetDexFile(); const DexFile::ClassDef* class_def = kh.GetClassDef(); - if (class_def == NULL) { - *error = "Verifier rejected class "; - *error += PrettyDescriptor(klass); - *error += " that isn't present in dex file "; - *error += dex_file.GetLocation(); + mirror::Class* super = klass->GetSuperClass(); + if (super == NULL && strcmp("Ljava/lang/Object;", kh.GetDescriptor()) != 0) { + early_failure = true; + failure_message = " that has no super class"; + } else if (super != NULL && super->IsFinal()) { + early_failure = true; + failure_message = " that attempts to sub-class final class " + PrettyDescriptor(super); + } else if (class_def == NULL) { + early_failure = true; + failure_message = " that isn't present in dex file " + dex_file.GetLocation(); + } + if (early_failure) { + *error = "Verifier rejected class " + PrettyDescriptor(klass) + failure_message; + if (Runtime::Current()->IsCompiler()) { + ClassReference ref(&dex_file, klass->GetDexClassDefIndex()); + AddRejectedClass(ref); + } return kHardFailure; } Thread* self = Thread::Current(); |