1 /* 2 * Copyright (C) 2017 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #ifndef ART_RUNTIME_CLASS_LOADER_UTILS_H_ 18 #define ART_RUNTIME_CLASS_LOADER_UTILS_H_ 19 20 #include "handle_scope.h" 21 #include "mirror/class_loader.h" 22 #include "scoped_thread_state_change-inl.h" 23 #include "well_known_classes.h" 24 25 namespace art { 26 27 // Returns true if the given class loader is either a PathClassLoader or a DexClassLoader. 28 // (they both have the same behaviour with respect to class lockup order) IsPathOrDexClassLoader(ScopedObjectAccessAlreadyRunnable & soa,Handle<mirror::ClassLoader> class_loader)29static bool IsPathOrDexClassLoader(ScopedObjectAccessAlreadyRunnable& soa, 30 Handle<mirror::ClassLoader> class_loader) 31 REQUIRES_SHARED(Locks::mutator_lock_) { 32 mirror::Class* class_loader_class = class_loader->GetClass(); 33 return 34 (class_loader_class == 35 soa.Decode<mirror::Class>(WellKnownClasses::dalvik_system_PathClassLoader)) || 36 (class_loader_class == 37 soa.Decode<mirror::Class>(WellKnownClasses::dalvik_system_DexClassLoader)); 38 } 39 IsDelegateLastClassLoader(ScopedObjectAccessAlreadyRunnable & soa,Handle<mirror::ClassLoader> class_loader)40static bool IsDelegateLastClassLoader(ScopedObjectAccessAlreadyRunnable& soa, 41 Handle<mirror::ClassLoader> class_loader) 42 REQUIRES_SHARED(Locks::mutator_lock_) { 43 mirror::Class* class_loader_class = class_loader->GetClass(); 44 return class_loader_class == 45 soa.Decode<mirror::Class>(WellKnownClasses::dalvik_system_DelegateLastClassLoader); 46 } 47 48 } // namespace art 49 50 #endif // ART_RUNTIME_CLASS_LOADER_UTILS_H_ 51