From 72ab684871f870aead76b23cb67deb046107b380 Mon Sep 17 00:00:00 2001 From: Vladimir Marko Date: Fri, 20 Jan 2017 19:32:50 +0000 Subject: Add class status for resolved erroneous classes. Split the old ambiguous status mirror::Class::kStatusError into kStatusErrorUnresolved and kStatusErrorResolved. Once a class has been resolved, IsResolved() shall return true even if the class later becomes erroneous. Allow returning erroneous class from ClassLinker::EnsureResolved() if it has been previously resolved. This allows consistent behavior for retrieving classes, immune to multi-threaded races and multi-dex weirdness. It also allows JVMTI to properly report "prepared" (i.e. resolved) classes that are also erroneous. The new behavior is consistent with the RI. Add regression tests to 008-exceptions for inconsistent behavior for multi-dex retrieval of erroneous resolved class (wrapping or not wrapping the old exception based on which dex file is used for lookup) and for a CHECK(IsResolved()) crash in ClassLinker::LoadSuperAndInterfaces() (without any tests for similar checks that could have previously failed only due to extremely unlikely race conditions; these should now also be fixed). Inconsistency still remains for class verification as shown by the new exceptionsForSuperClassInitFailure() test in 008-exceptions, where interpreter and Optimizing still cause different exceptions to be thrown. Note: This is partially changing behavior implemented for bug 28787733. Since we allow the class loader to retrieve an erroneous resolved class, the ExceptionInInitializerError is not thrown at all from VMClassLoader_findLoadedClass(), so there is nothing to wrap in ClassNotFoundException. Test: m test-art-host Bug: 30627598 Bug: 28787733 Change-Id: I86cdca00f35a0d6221d2559e3026ac0428a3613c --- .../src-multidex/MultiDexBadInitWrapper2.java | 24 ++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 test/008-exceptions/src-multidex/MultiDexBadInitWrapper2.java (limited to 'test/008-exceptions/src-multidex/MultiDexBadInitWrapper2.java') diff --git a/test/008-exceptions/src-multidex/MultiDexBadInitWrapper2.java b/test/008-exceptions/src-multidex/MultiDexBadInitWrapper2.java new file mode 100644 index 0000000000..f3953bd4c7 --- /dev/null +++ b/test/008-exceptions/src-multidex/MultiDexBadInitWrapper2.java @@ -0,0 +1,24 @@ +/* + * Copyright (C) 2016 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +class MultiDexBadInitWrapper2 { + public static void setDummy(int value) { + if (doThrow) { throw new Error(); } + MultiDexBadInit.dummy = value; + } + + public static boolean doThrow = false; +} -- cgit v1.2.3