From 9139e008abe30b7beaf4afd6533228a1dd9b202c Mon Sep 17 00:00:00 2001 From: Alex Light Date: Fri, 9 Oct 2015 15:59:48 -0700 Subject: Correct exception behavior for default methods Default methods are defined to throw an IncompatibleClassChangeError (ICCE) when they are called and there is no "best" implementation. Previously we would simply throw an ICCE during class loading as soon as we noticed that this would happen if called. This makes us wait until we actually attempt to execute the method. Furthermore, this allows us to use other, non-conflicting, methods on the object as normal. Furthermore, this makes us correctly throw AbstractMethodErrors in cases where all default implementations of a method are overridden by abstract declarations. Adds 3 tests for this new behavior. Bug: 24618811 Change-Id: Id891958a81f9b3862b2ce5919636aabef7d3422e --- compiler/driver/compiler_driver-inl.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'compiler/driver/compiler_driver-inl.h') diff --git a/compiler/driver/compiler_driver-inl.h b/compiler/driver/compiler_driver-inl.h index 14ba81d193..10841e6700 100644 --- a/compiler/driver/compiler_driver-inl.h +++ b/compiler/driver/compiler_driver-inl.h @@ -329,7 +329,7 @@ inline int CompilerDriver::IsFastInvoke( resolved_method->GetMethodIndex() < methods_class->GetVTableLength() && (methods_class->GetVTableEntry( resolved_method->GetMethodIndex(), pointer_size) == resolved_method) && - !resolved_method->IsAbstract(); + resolved_method->IsInvokable(); if (can_sharpen_virtual_based_on_type || can_sharpen_super_based_on_type) { // Sharpen a virtual call into a direct call. The method_idx is into referrer's @@ -374,7 +374,7 @@ inline int CompilerDriver::IsFastInvoke( class_loader, nullptr, kVirtual); } CHECK(called_method != nullptr); - CHECK(!called_method->IsAbstract()); + CHECK(called_method->IsInvokable()); int stats_flags = kFlagMethodResolved; GetCodeAndMethodForDirectCall(/*out*/invoke_type, kDirect, // Sharp type -- cgit v1.2.3-59-g8ed1b