From b878f2133a04593643228eb1d47993092528b963 Mon Sep 17 00:00:00 2001 From: Jeff Hao Date: Thu, 24 Apr 2014 16:25:36 -0700 Subject: Make unresolved exception types cause soft verification errors. Before, the verifier would allow the first exception it finds for a catch block to be unresolved, but this causes problems if it merges other exceptions later. The verifier should soft fail for any unresolved exception type it finds. Bug: 14256107 Change-Id: I22563ebfe8c9680cc676b73516d5b48bc9c4ecf3 --- runtime/verifier/method_verifier.cc | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'runtime') diff --git a/runtime/verifier/method_verifier.cc b/runtime/verifier/method_verifier.cc index 535c76d..b6fe4d5 100644 --- a/runtime/verifier/method_verifier.cc +++ b/runtime/verifier/method_verifier.cc @@ -2865,11 +2865,7 @@ const RegType& MethodVerifier::GetCaughtExceptionType() { common_super = ®_types_.JavaLangThrowable(false); } else { const RegType& exception = ResolveClassAndCheckAccess(iterator.GetHandlerTypeIndex()); - if (common_super == NULL) { - // Unconditionally assign for the first handler. We don't assert this is a Throwable - // as that is caught at runtime - common_super = &exception; - } else if (!reg_types_.JavaLangThrowable(false).IsAssignableFrom(exception)) { + if (!reg_types_.JavaLangThrowable(false).IsAssignableFrom(exception)) { if (exception.IsUnresolvedTypes()) { // We don't know enough about the type. Fail here and let runtime handle it. Fail(VERIFY_ERROR_NO_CLASS) << "unresolved exception class " << exception; @@ -2878,6 +2874,8 @@ const RegType& MethodVerifier::GetCaughtExceptionType() { Fail(VERIFY_ERROR_BAD_CLASS_SOFT) << "unexpected non-exception class " << exception; return reg_types_.Conflict(); } + } else if (common_super == nullptr) { + common_super = &exception; } else if (common_super->Equals(exception)) { // odd case, but nothing to do } else { -- cgit v1.1