blob: 0d32271389a78f6a4d683de67ef0bcda33c7fe55 [file] [log] [blame]
Elliott Hughes418d20f2011-09-22 14:00:39 -07001/*
2 * Copyright (C) 2011 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 */
Carl Shapiro0e5d75d2011-07-06 18:28:37 -070016
Brian Carlstromfc0e3212013-07-17 14:40:12 -070017#ifndef ART_RUNTIME_CLASS_LINKER_H_
18#define ART_RUNTIME_CLASS_LINKER_H_
Carl Shapiro0e5d75d2011-07-06 18:28:37 -070019
Andreas Gampe49b74a82019-01-07 10:19:49 -080020#include <list>
Vladimir Marko86c87522020-05-11 16:55:55 +010021#include <map>
Mathieu Chartierc5dd3192015-12-09 16:38:30 -080022#include <set>
Ian Rogers6d4d9fc2011-11-30 16:24:48 -080023#include <string>
Nicolas Geoffray4ac0e152019-09-18 06:14:50 +000024#include <type_traits>
David Srbecky6fbcc292021-02-23 01:05:32 +000025#include <unordered_map>
Carl Shapiro0e5d75d2011-07-06 18:28:37 -070026#include <utility>
27#include <vector>
28
Andreas Gampe542451c2016-07-26 09:02:02 -070029#include "base/enums.h"
Vladimir Marko782fb712020-12-23 12:47:31 +000030#include "base/hash_map.h"
Vladimir Markobf121912019-06-04 13:49:05 +010031#include "base/intrusive_forward_list.h"
Andreas Gampe7fbc4a52018-11-28 08:26:47 -080032#include "base/locks.h"
Elliott Hughes76160052012-12-12 16:31:20 -080033#include "base/macros.h"
Santiago Aboy Solanes970ba212021-10-21 10:52:47 +010034#include "base/mutex.h"
Mathieu Chartier1f1cb9f2018-06-04 09:22:46 -070035#include "dex/class_accessor.h"
David Sehr9e734c72018-01-04 17:56:19 -080036#include "dex/dex_file_types.h"
Hiroshi Yamauchi94f7b492014-07-22 18:08:23 -070037#include "gc_root.h"
Andreas Gampe0f01b582017-01-18 15:22:37 -080038#include "handle.h"
Mathieu Chartier590fee92013-09-13 13:46:47 -070039#include "jni.h"
Vladimir Marko97d7e1c2016-10-04 14:44:28 +010040#include "mirror/class.h"
Vladimir Marko43354742021-02-03 15:37:01 +000041#include "mirror/object.h"
Santiago Aboy Solanes970ba212021-10-21 10:52:47 +010042#include "oat_file.h"
Andreas Gampe6d7abbd2017-04-24 13:19:09 -070043#include "verifier/verifier_enums.h"
Carl Shapiro0e5d75d2011-07-06 18:28:37 -070044
45namespace art {
Mingyao Yang98d1cc82014-05-15 17:02:16 -070046
Vladimir Marko86c87522020-05-11 16:55:55 +010047class ArtField;
48class ArtMethod;
49class ClassHierarchyAnalysis;
50enum class ClassRoot : uint32_t;
51class ClassTable;
52class DexFile;
53template<class T> class Handle;
54class ImtConflictTable;
55template<typename T> class LengthPrefixedArray;
56template<class T> class MutableHandle;
57class InternTable;
58class LinearAlloc;
59class OatFile;
60template<class T> class ObjectLock;
61class Runtime;
62class ScopedObjectAccessAlreadyRunnable;
Calin Juravle33787682019-07-26 14:27:18 -070063class SdkChecker;
Vladimir Marko86c87522020-05-11 16:55:55 +010064template<size_t kNumReferences> class PACKED(4) StackHandleScope;
65class Thread;
66
67enum VisitRootFlags : uint8_t;
68
Andreas Gampe3f1dcd32018-12-28 09:39:56 -080069namespace dex {
70struct ClassDef;
Andreas Gampe62629592019-01-03 16:08:31 -080071struct MethodHandleItem;
Andreas Gampe3f1dcd32018-12-28 09:39:56 -080072} // namespace dex
73
Ian Rogers1d54e732013-05-02 21:10:01 -070074namespace gc {
75namespace space {
Igor Murashkin2ffb7032017-11-08 13:35:21 -080076class ImageSpace;
Ian Rogers1d54e732013-05-02 21:10:01 -070077} // namespace space
78} // namespace gc
Vladimir Marko74527972016-11-29 15:57:32 +000079
80namespace linker {
Igor Murashkin2ffb7032017-11-08 13:35:21 -080081struct CompilationHelper;
82class ImageWriter;
83class OatWriter;
Vladimir Marko74527972016-11-29 15:57:32 +000084} // namespace linker
85
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080086namespace mirror {
Igor Murashkin2ffb7032017-11-08 13:35:21 -080087class ClassLoader;
88class DexCache;
89class DexCachePointerArray;
90class DexCacheMethodHandlesTest_Open_Test;
91class DexCacheTest_Open_Test;
92class IfTable;
93class MethodHandle;
94class MethodHandlesLookup;
95class MethodType;
96template<class T> class ObjectArray;
97class StackTraceElement;
Ian Rogers33e95662013-05-20 20:29:14 -070098} // namespace mirror
Ian Rogers1d54e732013-05-02 21:10:01 -070099
Nicolas Geoffray5b0b2e12021-03-19 14:48:40 +0000100namespace verifier {
101class VerifierDeps;
102}
103
Mathieu Chartier1aa8ec22016-02-01 10:34:47 -0800104class ClassVisitor {
105 public:
106 virtual ~ClassVisitor() {}
107 // Return true to continue visiting.
Mathieu Chartier28357fa2016-10-18 16:27:40 -0700108 virtual bool operator()(ObjPtr<mirror::Class> klass) = 0;
Mathieu Chartier1aa8ec22016-02-01 10:34:47 -0800109};
110
Alex Light3f0dca12020-01-27 17:20:28 -0800111template <typename Func>
112class ClassFuncVisitor final : public ClassVisitor {
113 public:
114 explicit ClassFuncVisitor(Func func) : func_(func) {}
115 bool operator()(ObjPtr<mirror::Class> klass) override REQUIRES_SHARED(Locks::mutator_lock_) {
116 return func_(klass);
117 }
118
119 private:
120 Func func_;
121};
122
Mathieu Chartier9b1c71e2015-09-02 18:51:54 -0700123class ClassLoaderVisitor {
124 public:
125 virtual ~ClassLoaderVisitor() {}
Mathieu Chartier28357fa2016-10-18 16:27:40 -0700126 virtual void Visit(ObjPtr<mirror::ClassLoader> class_loader)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700127 REQUIRES_SHARED(Locks::classlinker_classes_lock_, Locks::mutator_lock_) = 0;
Mathieu Chartier9b1c71e2015-09-02 18:51:54 -0700128};
129
Alex Lightabd8f052019-12-06 10:49:17 -0800130template <typename Func>
131class ClassLoaderFuncVisitor final : public ClassLoaderVisitor {
132 public:
133 explicit ClassLoaderFuncVisitor(Func func) : func_(func) {}
134 void Visit(ObjPtr<mirror::ClassLoader> cl) override REQUIRES_SHARED(Locks::mutator_lock_) {
135 func_(cl);
136 }
137
138 private:
139 Func func_;
140};
141
Alexey Grebenkin252a4e42018-04-02 18:18:01 +0300142class AllocatorVisitor {
143 public:
144 virtual ~AllocatorVisitor() {}
145 // Return true to continue visiting.
146 virtual bool Visit(LinearAlloc* alloc)
147 REQUIRES_SHARED(Locks::classlinker_classes_lock_, Locks::mutator_lock_) = 0;
148};
149
Carl Shapiro0e5d75d2011-07-06 18:28:37 -0700150class ClassLinker {
151 public:
Chris Wailes55c880e2018-10-24 13:10:35 -0700152 static constexpr bool kAppImageMayContainStrings = true;
Mathieu Chartier0933cc52018-03-23 14:25:08 -0700153
Andreas Gampe87658f32019-04-18 18:39:02 +0000154 explicit ClassLinker(InternTable* intern_table,
155 bool fast_class_not_found_exceptions = true);
Chang Xing605fe242017-07-20 15:57:21 -0700156 virtual ~ClassLinker();
Carl Shapiro565f5072011-07-10 13:39:43 -0700157
Alex Light64ad14d2014-08-19 14:23:13 -0700158 // Initialize class linker by bootstraping from dex files.
Andreas Gampe3db9c5d2015-11-17 11:52:46 -0800159 bool InitWithoutImage(std::vector<std::unique_ptr<const DexFile>> boot_class_path,
160 std::string* error_msg)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700161 REQUIRES_SHARED(Locks::mutator_lock_)
Andreas Gampecc1b5352016-12-01 16:58:38 -0800162 REQUIRES(!Locks::dex_lock_);
Mathieu Chartier590fee92013-09-13 13:46:47 -0700163
Mathieu Chartierfbc31082016-01-24 11:59:56 -0800164 // Initialize class linker from one or more boot images.
165 bool InitFromBootImage(std::string* error_msg)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700166 REQUIRES_SHARED(Locks::mutator_lock_)
Andreas Gampecc1b5352016-12-01 16:58:38 -0800167 REQUIRES(!Locks::dex_lock_);
Mathieu Chartier590fee92013-09-13 13:46:47 -0700168
Vladimir Marko0ace5632018-12-14 11:11:47 +0000169 // Add boot class path dex files that were not included in the boot image.
170 // ClassLinker takes ownership of these dex files.
171 void AddExtraBootDexFiles(Thread* self,
172 std::vector<std::unique_ptr<const DexFile>>&& additional_dex_files)
173 REQUIRES_SHARED(Locks::mutator_lock_);
174
Mathieu Chartierfbc31082016-01-24 11:59:56 -0800175 // Add an image space to the class linker, may fix up classloader fields and dex cache fields.
176 // The dex files that were newly opened for the space are placed in the out argument
177 // out_dex_files. Returns true if the operation succeeded.
178 // The space must be already added to the heap before calling AddImageSpace since we need to
179 // properly handle read barriers and object marking.
180 bool AddImageSpace(gc::space::ImageSpace* space,
181 Handle<mirror::ClassLoader> class_loader,
Mathieu Chartierfbc31082016-01-24 11:59:56 -0800182 std::vector<std::unique_ptr<const DexFile>>* out_dex_files,
183 std::string* error_msg)
Andreas Gampecc1b5352016-12-01 16:58:38 -0800184 REQUIRES(!Locks::dex_lock_)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700185 REQUIRES_SHARED(Locks::mutator_lock_);
Mathieu Chartierfbc31082016-01-24 11:59:56 -0800186
Mathieu Chartier0b4cbd02016-03-08 16:49:58 -0800187 bool OpenImageDexFiles(gc::space::ImageSpace* space,
188 std::vector<std::unique_ptr<const DexFile>>* out_dex_files,
189 std::string* error_msg)
Andreas Gampecc1b5352016-12-01 16:58:38 -0800190 REQUIRES(!Locks::dex_lock_)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700191 REQUIRES_SHARED(Locks::mutator_lock_);
Mathieu Chartier0b4cbd02016-03-08 16:49:58 -0800192
Elliott Hughes64bf5a32011-09-20 14:43:12 -0700193 // Finds a class by its descriptor, loading it if necessary.
Brian Carlstrom74eb46a2011-08-02 20:10:14 -0700194 // If class_loader is null, searches boot_class_path_.
Vladimir Markoa8bba7d2018-05-30 15:18:48 +0100195 ObjPtr<mirror::Class> FindClass(Thread* self,
196 const char* descriptor,
197 Handle<mirror::ClassLoader> class_loader)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700198 REQUIRES_SHARED(Locks::mutator_lock_)
Andreas Gampecc1b5352016-12-01 16:58:38 -0800199 REQUIRES(!Locks::dex_lock_);
Brian Carlstromaded5f72011-10-07 17:15:04 -0700200
Ian Rogers98379392014-02-24 16:53:16 -0800201 // Finds a class by its descriptor using the "system" class loader, ie by searching the
202 // boot_class_path_.
Vladimir Markoa8bba7d2018-05-30 15:18:48 +0100203 ObjPtr<mirror::Class> FindSystemClass(Thread* self, const char* descriptor)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700204 REQUIRES_SHARED(Locks::mutator_lock_)
Andreas Gampec6ea7d02017-02-01 16:46:28 -0800205 REQUIRES(!Locks::dex_lock_) {
206 return FindClass(self, descriptor, ScopedNullHandle<mirror::ClassLoader>());
207 }
Ian Rogers98379392014-02-24 16:53:16 -0800208
209 // Finds the array class given for the element class.
Vladimir Markobcf17522018-06-01 13:14:32 +0100210 ObjPtr<mirror::Class> FindArrayClass(Thread* self, ObjPtr<mirror::Class> element_class)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700211 REQUIRES_SHARED(Locks::mutator_lock_)
Andreas Gampecc1b5352016-12-01 16:58:38 -0800212 REQUIRES(!Locks::dex_lock_);
Brian Carlstromaded5f72011-10-07 17:15:04 -0700213
Ian Rogers63557452014-06-04 16:57:15 -0700214 // Returns true if the class linker is initialized.
Ian Rogers7b078e82014-09-10 14:44:24 -0700215 bool IsInitialized() const {
216 return init_done_;
217 }
Mathieu Chartier590fee92013-09-13 13:46:47 -0700218
Brian Carlstromaded5f72011-10-07 17:15:04 -0700219 // Define a new a class based on a ClassDef from a DexFile
Vladimir Markoa8bba7d2018-05-30 15:18:48 +0100220 ObjPtr<mirror::Class> DefineClass(Thread* self,
221 const char* descriptor,
222 size_t hash,
223 Handle<mirror::ClassLoader> class_loader,
224 const DexFile& dex_file,
Andreas Gampe3f1dcd32018-12-28 09:39:56 -0800225 const dex::ClassDef& dex_class_def)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700226 REQUIRES_SHARED(Locks::mutator_lock_)
Andreas Gampecc1b5352016-12-01 16:58:38 -0800227 REQUIRES(!Locks::dex_lock_);
Elliott Hughes64bf5a32011-09-20 14:43:12 -0700228
Mathieu Chartier2cebb242015-04-21 16:50:40 -0700229 // Finds a class by its descriptor, returning null if it isn't wasn't loaded
Elliott Hughes64bf5a32011-09-20 14:43:12 -0700230 // by the given 'class_loader'.
Vladimir Markoa8bba7d2018-05-30 15:18:48 +0100231 ObjPtr<mirror::Class> LookupClass(Thread* self,
232 const char* descriptor,
233 ObjPtr<mirror::ClassLoader> class_loader)
Mathieu Chartier90443472015-07-16 20:32:27 -0700234 REQUIRES(!Locks::classlinker_classes_lock_)
Andreas Gampe2ff3b972017-06-05 18:14:53 -0700235 REQUIRES_SHARED(Locks::mutator_lock_);
Carl Shapiro0e5d75d2011-07-06 18:28:37 -0700236
Elliott Hughes6fa602d2011-12-02 17:54:25 -0800237 // Finds all the classes with the given descriptor, regardless of ClassLoader.
Mathieu Chartier28357fa2016-10-18 16:27:40 -0700238 void LookupClasses(const char* descriptor, std::vector<ObjPtr<mirror::Class>>& classes)
Mathieu Chartier90443472015-07-16 20:32:27 -0700239 REQUIRES(!Locks::classlinker_classes_lock_)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700240 REQUIRES_SHARED(Locks::mutator_lock_);
Elliott Hughes6fa602d2011-12-02 17:54:25 -0800241
Vladimir Marko9186b182018-11-06 14:55:54 +0000242 ObjPtr<mirror::Class> LookupPrimitiveClass(char type) REQUIRES_SHARED(Locks::mutator_lock_);
Vladimir Markoa8bba7d2018-05-30 15:18:48 +0100243 ObjPtr<mirror::Class> FindPrimitiveClass(char type) REQUIRES_SHARED(Locks::mutator_lock_);
Elliott Hughesd8ddfd52011-08-15 14:32:53 -0700244
Mathieu Chartierc77f3ab2015-09-03 19:41:50 -0700245 void DumpForSigQuit(std::ostream& os) REQUIRES(!Locks::classlinker_classes_lock_);
Elliott Hughescac6cc72011-11-03 20:31:21 -0700246
Ian Rogers7dfb28c2013-08-22 08:18:36 -0700247 size_t NumLoadedClasses()
Mathieu Chartierc77f3ab2015-09-03 19:41:50 -0700248 REQUIRES(!Locks::classlinker_classes_lock_)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700249 REQUIRES_SHARED(Locks::mutator_lock_);
Elliott Hughese27955c2011-08-26 15:21:24 -0700250
Vladimir Marko18090d12018-06-01 16:53:12 +0100251 // Resolve a String with the given index from the DexFile associated with the given `referrer`,
252 // storing the result in the DexCache. The `referrer` is used to identify the target DexCache
253 // to use for resolution.
254 ObjPtr<mirror::String> ResolveString(dex::StringIndex string_idx,
255 ArtField* referrer)
256 REQUIRES_SHARED(Locks::mutator_lock_);
257 ObjPtr<mirror::String> ResolveString(dex::StringIndex string_idx,
258 ArtMethod* referrer)
259 REQUIRES_SHARED(Locks::mutator_lock_);
260
Vladimir Markoa64b52d2017-12-08 16:27:49 +0000261 // Resolve a String with the given index from the DexFile associated with the given DexCache,
262 // storing the result in the DexCache.
263 ObjPtr<mirror::String> ResolveString(dex::StringIndex string_idx,
Vladimir Marko28e012a2017-12-07 11:22:59 +0000264 Handle<mirror::DexCache> dex_cache)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700265 REQUIRES_SHARED(Locks::mutator_lock_);
Brian Carlstrom9ea1cb12011-08-24 23:18:18 -0700266
Vladimir Markoa64b52d2017-12-08 16:27:49 +0000267 // Find a String with the given index from the DexFile associated with the given DexCache,
268 // storing the result in the DexCache if found. Return null if not found.
269 ObjPtr<mirror::String> LookupString(dex::StringIndex string_idx,
Vladimir Marko28e012a2017-12-07 11:22:59 +0000270 ObjPtr<mirror::DexCache> dex_cache)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700271 REQUIRES_SHARED(Locks::mutator_lock_);
Vladimir Markocac5a7e2016-02-22 10:39:50 +0000272
Vladimir Marko666ee3d2017-12-11 18:37:36 +0000273 // Resolve a Type with the given index from the DexFile associated with the given `referrer`,
274 // storing the result in the DexCache. The `referrer` is used to identify the target DexCache
275 // and ClassLoader to use for resolution.
276 ObjPtr<mirror::Class> ResolveType(dex::TypeIndex type_idx, ObjPtr<mirror::Class> referrer)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700277 REQUIRES_SHARED(Locks::mutator_lock_)
Andreas Gampecc1b5352016-12-01 16:58:38 -0800278 REQUIRES(!Locks::dex_lock_, !Roles::uninterruptible_);
Vladimir Marko09c5ca42018-05-31 15:15:31 +0100279 ObjPtr<mirror::Class> ResolveType(dex::TypeIndex type_idx, ArtField* referrer)
280 REQUIRES_SHARED(Locks::mutator_lock_)
281 REQUIRES(!Locks::dex_lock_, !Roles::uninterruptible_);
Vladimir Marko28e012a2017-12-07 11:22:59 +0000282 ObjPtr<mirror::Class> ResolveType(dex::TypeIndex type_idx, ArtMethod* referrer)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700283 REQUIRES_SHARED(Locks::mutator_lock_)
Andreas Gampecc1b5352016-12-01 16:58:38 -0800284 REQUIRES(!Locks::dex_lock_, !Roles::uninterruptible_);
Ian Rogers0cfe1fb2011-08-26 03:29:44 -0700285
Vladimir Marko666ee3d2017-12-11 18:37:36 +0000286 // Resolve a type with the given index from the DexFile associated with the given DexCache
287 // and ClassLoader, storing the result in DexCache. The ClassLoader is used to search for
288 // the type, since it may be referenced from but not contained within the DexFile.
289 ObjPtr<mirror::Class> ResolveType(dex::TypeIndex type_idx,
Vladimir Marko28e012a2017-12-07 11:22:59 +0000290 Handle<mirror::DexCache> dex_cache,
291 Handle<mirror::ClassLoader> class_loader)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700292 REQUIRES_SHARED(Locks::mutator_lock_)
Andreas Gampecc1b5352016-12-01 16:58:38 -0800293 REQUIRES(!Locks::dex_lock_, !Roles::uninterruptible_);
Brian Carlstrom9ea1cb12011-08-24 23:18:18 -0700294
Vladimir Marko666ee3d2017-12-11 18:37:36 +0000295 // Look up a resolved type with the given index from the DexFile associated with the given
296 // `referrer`, storing the result in the DexCache. The `referrer` is used to identify the
297 // target DexCache and ClassLoader to use for lookup.
298 ObjPtr<mirror::Class> LookupResolvedType(dex::TypeIndex type_idx,
299 ObjPtr<mirror::Class> referrer)
300 REQUIRES_SHARED(Locks::mutator_lock_);
Vladimir Marko09c5ca42018-05-31 15:15:31 +0100301 ObjPtr<mirror::Class> LookupResolvedType(dex::TypeIndex type_idx, ArtField* referrer)
302 REQUIRES_SHARED(Locks::mutator_lock_);
Vladimir Marko666ee3d2017-12-11 18:37:36 +0000303 ObjPtr<mirror::Class> LookupResolvedType(dex::TypeIndex type_idx, ArtMethod* referrer)
304 REQUIRES_SHARED(Locks::mutator_lock_);
305
306 // Look up a resolved type with the given index from the DexFile associated with the given
307 // DexCache and ClassLoader. The ClassLoader is used to search for the type, since it may
308 // be referenced from but not contained within the DexFile.
309 ObjPtr<mirror::Class> LookupResolvedType(dex::TypeIndex type_idx,
310 ObjPtr<mirror::DexCache> dex_cache,
311 ObjPtr<mirror::ClassLoader> class_loader)
312 REQUIRES_SHARED(Locks::mutator_lock_);
313
Vladimir Markoc63d9672021-03-31 15:50:39 +0100314 // Look up a resolved type with the given descriptor associated with the given ClassLoader.
315 ObjPtr<mirror::Class> LookupResolvedType(const char* descriptor,
316 ObjPtr<mirror::ClassLoader> class_loader)
317 REQUIRES_SHARED(Locks::mutator_lock_);
318
Andreas Gampe42ef8ab2015-12-03 17:27:32 -0800319 // Determine whether a dex cache result should be trusted, or an IncompatibleClassChangeError
Vladimir Markoba118822017-06-12 15:41:56 +0100320 // check and IllegalAccessError check should be performed even after a hit.
321 enum class ResolveMode { // private.
322 kNoChecks,
323 kCheckICCEAndIAE
Andreas Gampe42ef8ab2015-12-03 17:27:32 -0800324 };
325
Vladimir Marko07bfbac2017-07-06 14:55:02 +0100326 // Look up a previously resolved method with the given index.
327 ArtMethod* LookupResolvedMethod(uint32_t method_idx,
328 ObjPtr<mirror::DexCache> dex_cache,
329 ObjPtr<mirror::ClassLoader> class_loader)
330 REQUIRES_SHARED(Locks::mutator_lock_);
331
Nicolas Geoffrayea179f42018-02-08 22:30:18 +0000332 // Find a method with the given index from class `klass`, and update the dex cache.
333 ArtMethod* FindResolvedMethod(ObjPtr<mirror::Class> klass,
334 ObjPtr<mirror::DexCache> dex_cache,
335 ObjPtr<mirror::ClassLoader> class_loader,
336 uint32_t method_idx)
337 REQUIRES_SHARED(Locks::mutator_lock_);
338
David Brazdil4525e0b2018-04-05 16:57:32 +0100339 // Find a method using the wrong lookup mechanism. If `klass` is an interface,
340 // search for a class method. If it is a class, search for an interface method.
341 // This is useful when throwing IncompatibleClassChangeError.
342 ArtMethod* FindIncompatibleMethod(ObjPtr<mirror::Class> klass,
343 ObjPtr<mirror::DexCache> dex_cache,
344 ObjPtr<mirror::ClassLoader> class_loader,
345 uint32_t method_idx)
346 REQUIRES_SHARED(Locks::mutator_lock_);
347
Vladimir Marko89011192017-12-11 13:45:05 +0000348 // Resolve a method with a given ID from the DexFile associated with the given DexCache
349 // and ClassLoader, storing the result in DexCache. The ClassLinker and ClassLoader are
350 // used as in ResolveType. What is unique is the method type argument which is used to
351 // determine if this method is a direct, static, or virtual method.
Andreas Gampe42ef8ab2015-12-03 17:27:32 -0800352 template <ResolveMode kResolveMode>
Vladimir Marko89011192017-12-11 13:45:05 +0000353 ArtMethod* ResolveMethod(uint32_t method_idx,
Mathieu Chartiere401d142015-04-22 13:56:20 -0700354 Handle<mirror::DexCache> dex_cache,
Mathieu Chartierc77f3ab2015-09-03 19:41:50 -0700355 Handle<mirror::ClassLoader> class_loader,
356 ArtMethod* referrer,
Mathieu Chartiere401d142015-04-22 13:56:20 -0700357 InvokeType type)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700358 REQUIRES_SHARED(Locks::mutator_lock_)
Andreas Gampecc1b5352016-12-01 16:58:38 -0800359 REQUIRES(!Locks::dex_lock_, !Roles::uninterruptible_);
Brian Carlstrom9ea1cb12011-08-24 23:18:18 -0700360
Vladimir Markoba118822017-06-12 15:41:56 +0100361 template <InvokeType type, ResolveMode kResolveMode>
Mathieu Chartiere401d142015-04-22 13:56:20 -0700362 ArtMethod* GetResolvedMethod(uint32_t method_idx, ArtMethod* referrer)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700363 REQUIRES_SHARED(Locks::mutator_lock_);
Alex Lightfedd91d2016-01-07 14:49:16 -0800364
Andreas Gampe42ef8ab2015-12-03 17:27:32 -0800365 template <ResolveMode kResolveMode>
David Srbecky9cc67b12018-10-25 10:10:35 +0000366 ArtMethod* ResolveMethod(Thread* self, uint32_t method_idx, ArtMethod* referrer, InvokeType type)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700367 REQUIRES_SHARED(Locks::mutator_lock_)
Andreas Gampecc1b5352016-12-01 16:58:38 -0800368 REQUIRES(!Locks::dex_lock_, !Roles::uninterruptible_);
Vladimir Marko89011192017-12-11 13:45:05 +0000369 ArtMethod* ResolveMethodWithoutInvokeType(uint32_t method_idx,
Jeff Hao0042c6d2015-07-29 20:14:10 -0700370 Handle<mirror::DexCache> dex_cache,
371 Handle<mirror::ClassLoader> class_loader)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700372 REQUIRES_SHARED(Locks::mutator_lock_)
Andreas Gampecc1b5352016-12-01 16:58:38 -0800373 REQUIRES(!Locks::dex_lock_, !Roles::uninterruptible_);
Brian Carlstrom16192862011-09-12 17:50:06 -0700374
Vladimir Markof44d36c2017-03-14 14:18:46 +0000375 ArtField* LookupResolvedField(uint32_t field_idx, ArtMethod* referrer, bool is_static)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700376 REQUIRES_SHARED(Locks::mutator_lock_);
Mathieu Chartiere401d142015-04-22 13:56:20 -0700377 ArtField* ResolveField(uint32_t field_idx, ArtMethod* referrer, bool is_static)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700378 REQUIRES_SHARED(Locks::mutator_lock_)
Andreas Gampecc1b5352016-12-01 16:58:38 -0800379 REQUIRES(!Locks::dex_lock_, !Roles::uninterruptible_);
Brian Carlstromb9edb842011-08-28 16:31:06 -0700380
Vladimir Markoe11dd502017-12-08 14:09:45 +0000381 // Resolve a field with a given ID from the DexFile associated with the given DexCache
382 // and ClassLoader, storing the result in DexCache. The ClassLinker and ClassLoader
383 // are used as in ResolveType. What is unique is the is_static argument which is used
384 // to determine if we are resolving a static or non-static field.
385 ArtField* ResolveField(uint32_t field_idx,
Mathieu Chartier90443472015-07-16 20:32:27 -0700386 Handle<mirror::DexCache> dex_cache,
Vladimir Markoe11dd502017-12-08 14:09:45 +0000387 Handle<mirror::ClassLoader> class_loader,
388 bool is_static)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700389 REQUIRES_SHARED(Locks::mutator_lock_)
Andreas Gampecc1b5352016-12-01 16:58:38 -0800390 REQUIRES(!Locks::dex_lock_, !Roles::uninterruptible_);
Brian Carlstrom9ea1cb12011-08-24 23:18:18 -0700391
Vladimir Markoe11dd502017-12-08 14:09:45 +0000392 // Resolve a field with a given ID from the DexFile associated with the given DexCache
393 // and ClassLoader, storing the result in DexCache. The ClassLinker and ClassLoader
394 // are used as in ResolveType. No is_static argument is provided so that Java
Ian Rogersb067ac22011-12-13 18:05:09 -0800395 // field resolution semantics are followed.
Vladimir Markoe11dd502017-12-08 14:09:45 +0000396 ArtField* ResolveFieldJLS(uint32_t field_idx,
Mathieu Chartiere401d142015-04-22 13:56:20 -0700397 Handle<mirror::DexCache> dex_cache,
398 Handle<mirror::ClassLoader> class_loader)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700399 REQUIRES_SHARED(Locks::mutator_lock_)
Andreas Gampecc1b5352016-12-01 16:58:38 -0800400 REQUIRES(!Locks::dex_lock_, !Roles::uninterruptible_);
Ian Rogersb067ac22011-12-13 18:05:09 -0800401
David Brazdil1ab0fa82018-05-04 11:28:03 +0100402 // Find a field with a given ID from the DexFile associated with the given DexCache
403 // and ClassLoader, storing the result in DexCache. The declaring class is assumed
404 // to have been already resolved into `klass`. The `is_static` argument is used to
405 // determine if we are resolving a static or non-static field.
406 ArtField* FindResolvedField(ObjPtr<mirror::Class> klass,
407 ObjPtr<mirror::DexCache> dex_cache,
408 ObjPtr<mirror::ClassLoader> class_loader,
409 uint32_t field_idx,
410 bool is_static)
411 REQUIRES_SHARED(Locks::mutator_lock_);
412
413 // Find a field with a given ID from the DexFile associated with the given DexCache
414 // and ClassLoader, storing the result in DexCache. The declaring class is assumed
415 // to have been already resolved into `klass`. No is_static argument is provided
416 // so that Java field resolution semantics are followed.
417 ArtField* FindResolvedFieldJLS(ObjPtr<mirror::Class> klass,
418 ObjPtr<mirror::DexCache> dex_cache,
419 ObjPtr<mirror::ClassLoader> class_loader,
420 uint32_t field_idx)
421 REQUIRES_SHARED(Locks::mutator_lock_);
422
Vladimir Markoaf940202017-12-08 15:01:18 +0000423 // Resolve a method type with a given ID from the DexFile associated with a given DexCache
424 // and ClassLoader, storing the result in the DexCache.
425 ObjPtr<mirror::MethodType> ResolveMethodType(Thread* self,
Orion Hodson06d10a72018-05-14 08:53:38 +0100426 dex::ProtoIndex proto_idx,
Vladimir Markoaf940202017-12-08 15:01:18 +0000427 Handle<mirror::DexCache> dex_cache,
428 Handle<mirror::ClassLoader> class_loader)
Narayan Kamath25352fc2016-08-03 12:46:58 +0100429 REQUIRES_SHARED(Locks::mutator_lock_)
Andreas Gampecc1b5352016-12-01 16:58:38 -0800430 REQUIRES(!Locks::dex_lock_, !Roles::uninterruptible_);
Ian Rogersad25ac52011-10-04 19:13:33 -0700431
Vladimir Markoaf940202017-12-08 15:01:18 +0000432 ObjPtr<mirror::MethodType> ResolveMethodType(Thread* self,
Orion Hodson06d10a72018-05-14 08:53:38 +0100433 dex::ProtoIndex proto_idx,
Vladimir Markoaf940202017-12-08 15:01:18 +0000434 ArtMethod* referrer)
Orion Hodson2e599942017-09-22 16:17:41 +0100435 REQUIRES_SHARED(Locks::mutator_lock_);
436
Orion Hodsonc069a302017-01-18 09:23:12 +0000437 // Resolve a method handle with a given ID from the DexFile. The
438 // result is not cached in the DexCache as the instance will only be
439 // used once in most circumstances.
Vladimir Markoaf940202017-12-08 15:01:18 +0000440 ObjPtr<mirror::MethodHandle> ResolveMethodHandle(Thread* self,
441 uint32_t method_handle_idx,
442 ArtMethod* referrer)
Orion Hodsonc069a302017-01-18 09:23:12 +0000443 REQUIRES_SHARED(Locks::mutator_lock_);
444
Elliott Hughesf4c21c92011-08-19 17:31:31 -0700445 // Returns true on success, false if there's an exception pending.
Brian Carlstrom25c33252011-09-18 15:58:35 -0700446 // can_run_clinit=false allows the compiler to attempt to init a class,
447 // given the restriction that no <clinit> execution is possible.
Mathieu Chartierc77f3ab2015-09-03 19:41:50 -0700448 bool EnsureInitialized(Thread* self,
449 Handle<mirror::Class> c,
450 bool can_init_fields,
Ian Rogers7b078e82014-09-10 14:44:24 -0700451 bool can_init_parents)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700452 REQUIRES_SHARED(Locks::mutator_lock_)
Andreas Gampecc1b5352016-12-01 16:58:38 -0800453 REQUIRES(!Locks::dex_lock_, !Roles::uninterruptible_);
Carl Shapiro0e5d75d2011-07-06 18:28:37 -0700454
Elliott Hughes2a20cfd2011-09-23 19:30:41 -0700455 // Initializes classes that have instances in the image but that have
456 // <clinit> methods so they could not be initialized by the compiler.
Vladimir Markodcfcce42018-06-27 10:00:28 +0000457 void RunRootClinits(Thread* self)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700458 REQUIRES_SHARED(Locks::mutator_lock_)
Andreas Gampecc1b5352016-12-01 16:58:38 -0800459 REQUIRES(!Locks::dex_lock_, !Roles::uninterruptible_);
Elliott Hughes2a20cfd2011-09-23 19:30:41 -0700460
Alex Light07f06212017-06-01 14:01:43 -0700461 // Directly register an already existing dex cache. RegisterDexFile should be preferred since that
462 // reduplicates DexCaches when possible. The DexCache given to this function must already be fully
463 // initialized and not already registered.
464 void RegisterExistingDexCache(ObjPtr<mirror::DexCache> cache,
465 ObjPtr<mirror::ClassLoader> class_loader)
466 REQUIRES(!Locks::dex_lock_)
467 REQUIRES_SHARED(Locks::mutator_lock_);
Vladimir Markocd556b02017-02-03 11:47:34 +0000468 ObjPtr<mirror::DexCache> RegisterDexFile(const DexFile& dex_file,
469 ObjPtr<mirror::ClassLoader> class_loader)
Andreas Gampecc1b5352016-12-01 16:58:38 -0800470 REQUIRES(!Locks::dex_lock_)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700471 REQUIRES_SHARED(Locks::mutator_lock_);
Carl Shapiro0e5d75d2011-07-06 18:28:37 -0700472
Brian Carlstrom8a487412011-08-29 20:08:52 -0700473 const std::vector<const DexFile*>& GetBootClassPath() {
474 return boot_class_path_;
475 }
476
Mathieu Chartiere0671ce2015-07-28 17:23:28 -0700477 void VisitClasses(ClassVisitor* visitor)
Mathieu Chartierc77f3ab2015-09-03 19:41:50 -0700478 REQUIRES(!Locks::classlinker_classes_lock_)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700479 REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogersdbf3be02014-08-29 15:40:08 -0700480
481 // Less efficient variant of VisitClasses that copies the class_table_ into secondary storage
482 // so that it can visit individual classes without holding the doesn't hold the
483 // Locks::classlinker_classes_lock_. As the Locks::classlinker_classes_lock_ isn't held this code
484 // can race with insertion and deletion of classes while the visitor is being called.
Mathieu Chartiere0671ce2015-07-28 17:23:28 -0700485 void VisitClassesWithoutClassesLock(ClassVisitor* visitor)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700486 REQUIRES_SHARED(Locks::mutator_lock_)
Andreas Gampecc1b5352016-12-01 16:58:38 -0800487 REQUIRES(!Locks::dex_lock_);
Elliott Hughesa2155262011-11-16 16:26:58 -0800488
Mathieu Chartierbb87e0f2015-04-03 11:21:55 -0700489 void VisitClassRoots(RootVisitor* visitor, VisitRootFlags flags)
Andreas Gamped98b4ed2016-11-04 20:27:24 -0700490 REQUIRES(!Locks::classlinker_classes_lock_, !Locks::trace_lock_)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700491 REQUIRES_SHARED(Locks::mutator_lock_);
Mathieu Chartierbb87e0f2015-04-03 11:21:55 -0700492 void VisitRoots(RootVisitor* visitor, VisitRootFlags flags)
Andreas Gampecc1b5352016-12-01 16:58:38 -0800493 REQUIRES(!Locks::dex_lock_, !Locks::classlinker_classes_lock_, !Locks::trace_lock_)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700494 REQUIRES_SHARED(Locks::mutator_lock_);
Alex Lightabd8f052019-12-06 10:49:17 -0800495 // Visits all dex-files accessible by any class-loader or the BCP.
496 template<typename Visitor>
497 void VisitKnownDexFiles(Thread* self, Visitor visitor) REQUIRES(Locks::mutator_lock_);
Brian Carlstrom75cb3b42011-07-28 02:13:36 -0700498
Vladimir Markocd556b02017-02-03 11:47:34 +0000499 bool IsDexFileRegistered(Thread* self, const DexFile& dex_file)
500 REQUIRES(!Locks::dex_lock_)
501 REQUIRES_SHARED(Locks::mutator_lock_);
502 ObjPtr<mirror::DexCache> FindDexCache(Thread* self, const DexFile& dex_file)
503 REQUIRES(!Locks::dex_lock_)
504 REQUIRES_SHARED(Locks::mutator_lock_);
Santiago Aboy Solanes4b8ea5d2021-11-19 10:14:54 +0000505 ObjPtr<mirror::DexCache> FindDexCache(Thread* self, const OatDexFile& oat_dex_file)
Santiago Aboy Solanes970ba212021-10-21 10:52:47 +0100506 REQUIRES(!Locks::dex_lock_) REQUIRES_SHARED(Locks::mutator_lock_);
Vladimir Markocd556b02017-02-03 11:47:34 +0000507 ClassTable* FindClassTable(Thread* self, ObjPtr<mirror::DexCache> dex_cache)
Andreas Gampecc1b5352016-12-01 16:58:38 -0800508 REQUIRES(!Locks::dex_lock_)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700509 REQUIRES_SHARED(Locks::mutator_lock_);
Brian Carlstrom1d9f52b2011-10-13 10:50:45 -0700510
Mathieu Chartier951ec2c2015-09-22 08:50:05 -0700511 LengthPrefixedArray<ArtField>* AllocArtFieldArray(Thread* self,
512 LinearAlloc* allocator,
513 size_t length);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800514
Mathieu Chartier951ec2c2015-09-22 08:50:05 -0700515 LengthPrefixedArray<ArtMethod>* AllocArtMethodArray(Thread* self,
516 LinearAlloc* allocator,
517 size_t length);
Mathieu Chartiere401d142015-04-22 13:56:20 -0700518
Nicolas Geoffray4ac0e152019-09-18 06:14:50 +0000519 // Convenience AllocClass() overload that uses mirror::Class::InitializeClassVisitor
520 // for the class initialization and uses the `java_lang_Class` from class roots
521 // instead of an explicit argument.
522 ObjPtr<mirror::Class> AllocClass(Thread* self, uint32_t class_size)
523 REQUIRES_SHARED(Locks::mutator_lock_)
524 REQUIRES(!Roles::uninterruptible_);
525
526 // Setup the classloader, class def index, type idx so that we can insert this class in the class
527 // table.
528 void SetupClass(const DexFile& dex_file,
529 const dex::ClassDef& dex_class_def,
530 Handle<mirror::Class> klass,
531 ObjPtr<mirror::ClassLoader> class_loader)
532 REQUIRES_SHARED(Locks::mutator_lock_);
533
534 void LoadClass(Thread* self,
535 const DexFile& dex_file,
536 const dex::ClassDef& dex_class_def,
537 Handle<mirror::Class> klass)
538 REQUIRES_SHARED(Locks::mutator_lock_);
539
540 // Link the class and place it into the class-table using the given descriptor. NB if the
541 // descriptor is null the class will not be placed in any class-table. This is useful implementing
542 // obsolete classes and should not be used otherwise.
543 bool LinkClass(Thread* self,
544 const char* descriptor,
545 Handle<mirror::Class> klass,
546 Handle<mirror::ObjectArray<mirror::Class>> interfaces,
547 MutableHandle<mirror::Class>* h_new_class_out)
548 REQUIRES_SHARED(Locks::mutator_lock_)
549 REQUIRES(!Locks::classlinker_classes_lock_);
550
Vladimir Markobcf17522018-06-01 13:14:32 +0100551 ObjPtr<mirror::PointerArray> AllocPointerArray(Thread* self, size_t length)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700552 REQUIRES_SHARED(Locks::mutator_lock_)
Mathieu Chartierc77f3ab2015-09-03 19:41:50 -0700553 REQUIRES(!Roles::uninterruptible_);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800554
Vladimir Markoa8bba7d2018-05-30 15:18:48 +0100555 ObjPtr<mirror::IfTable> AllocIfTable(Thread* self, size_t ifcount)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700556 REQUIRES_SHARED(Locks::mutator_lock_)
Mathieu Chartierc77f3ab2015-09-03 19:41:50 -0700557 REQUIRES(!Roles::uninterruptible_);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800558
Vladimir Markobcf17522018-06-01 13:14:32 +0100559 ObjPtr<mirror::ObjectArray<mirror::StackTraceElement>> AllocStackTraceElementArray(Thread* self,
560 size_t length)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700561 REQUIRES_SHARED(Locks::mutator_lock_)
Mathieu Chartierc77f3ab2015-09-03 19:41:50 -0700562 REQUIRES(!Roles::uninterruptible_);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800563
Andreas Gampe6d7abbd2017-04-24 13:19:09 -0700564 verifier::FailureKind VerifyClass(
Nicolas Geoffray08025182016-10-25 17:20:18 +0100565 Thread* self,
Nicolas Geoffray5b0b2e12021-03-19 14:48:40 +0000566 verifier::VerifierDeps* verifier_deps,
Nicolas Geoffray08025182016-10-25 17:20:18 +0100567 Handle<mirror::Class> klass,
568 verifier::HardFailLogMode log_level = verifier::HardFailLogMode::kLogNone)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700569 REQUIRES_SHARED(Locks::mutator_lock_)
Andreas Gampecc1b5352016-12-01 16:58:38 -0800570 REQUIRES(!Locks::dex_lock_);
Nicolas Geoffray6df45112021-02-07 21:51:58 +0000571 bool VerifyClassUsingOatFile(Thread* self,
572 const DexFile& dex_file,
573 Handle<mirror::Class> klass,
Vladimir Marko2c64a832018-01-04 11:31:56 +0000574 ClassStatus& oat_file_class_status)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700575 REQUIRES_SHARED(Locks::mutator_lock_)
Andreas Gampecc1b5352016-12-01 16:58:38 -0800576 REQUIRES(!Locks::dex_lock_);
Alex Light5a559862016-01-29 12:24:48 -0800577 void ResolveClassExceptionHandlerTypes(Handle<mirror::Class> klass)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700578 REQUIRES_SHARED(Locks::mutator_lock_)
Andreas Gampecc1b5352016-12-01 16:58:38 -0800579 REQUIRES(!Locks::dex_lock_);
Alex Light5a559862016-01-29 12:24:48 -0800580 void ResolveMethodExceptionHandlerTypes(ArtMethod* klass)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700581 REQUIRES_SHARED(Locks::mutator_lock_)
Andreas Gampecc1b5352016-12-01 16:58:38 -0800582 REQUIRES(!Locks::dex_lock_);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800583
Vladimir Markoa8bba7d2018-05-30 15:18:48 +0100584 ObjPtr<mirror::Class> CreateProxyClass(ScopedObjectAccessAlreadyRunnable& soa,
585 jstring name,
586 jobjectArray interfaces,
587 jobject loader,
588 jobjectArray methods,
589 jobjectArray throws)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700590 REQUIRES_SHARED(Locks::mutator_lock_);
Jesse Wilson95caa792011-10-12 18:14:17 -0400591
Brian Carlstrom7934ac22013-07-26 10:54:15 -0700592 pid_t GetClassesLockOwner(); // For SignalCatcher.
593 pid_t GetDexLockOwner(); // For SignalCatcher.
Brian Carlstrom24a3c2e2011-10-17 18:07:52 -0700594
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700595 // Is the given entry point quick code to run the resolution stub?
596 bool IsQuickResolutionStub(const void* entry_point) const;
Jeff Hao88474b42013-10-23 16:24:40 -0700597
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700598 // Is the given entry point quick code to bridge into the interpreter?
599 bool IsQuickToInterpreterBridge(const void* entry_point) const;
600
601 // Is the given entry point quick code to run the generic JNI stub?
602 bool IsQuickGenericJniStub(const void* entry_point) const;
Vladimir Marko8a630572014-04-09 18:45:35 +0100603
David Sehra49e0532017-08-25 08:05:29 -0700604 // Is the given entry point the JNI dlsym lookup stub?
605 bool IsJniDlsymLookupStub(const void* entry_point) const;
606
Vladimir Markofa458ac2020-02-12 14:08:07 +0000607 // Is the given entry point the JNI dlsym lookup critical stub?
608 bool IsJniDlsymLookupCriticalStub(const void* entry_point) const;
609
Nicolas Geoffrayc39af942021-01-25 08:43:57 +0000610 // Is the given entry point the nterp trampoline?
611 bool IsNterpTrampoline(const void* entry_point) const {
612 return nterp_trampoline_ == entry_point;
613 }
614
Vladimir Marko97d7e1c2016-10-04 14:44:28 +0100615 const void* GetQuickToInterpreterBridgeTrampoline() const {
616 return quick_to_interpreter_bridge_trampoline_;
617 }
618
Jeff Hao88474b42013-10-23 16:24:40 -0700619 InternTable* GetInternTable() const {
620 return intern_table_;
621 }
622
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700623 // Set the entrypoints up for method to the enter the interpreter.
Mathieu Chartiere401d142015-04-22 13:56:20 -0700624 void SetEntryPointsToInterpreter(ArtMethod* method) const
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700625 REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700626
Alex Lightdb01a092017-04-03 15:39:55 -0700627 // Set the entrypoints up for an obsolete method.
628 void SetEntryPointsForObsoleteMethod(ArtMethod* method) const
629 REQUIRES_SHARED(Locks::mutator_lock_);
630
Mathieu Chartier2cebb242015-04-21 16:50:40 -0700631 // Attempts to insert a class into a class table. Returns null if
Ian Rogers848871b2013-08-05 10:56:33 -0700632 // the class was inserted, otherwise returns an existing class with
633 // the same descriptor and ClassLoader.
Vladimir Markoa8bba7d2018-05-30 15:18:48 +0100634 ObjPtr<mirror::Class> InsertClass(const char* descriptor,
635 ObjPtr<mirror::Class> klass,
636 size_t hash)
Mathieu Chartier90443472015-07-16 20:32:27 -0700637 REQUIRES(!Locks::classlinker_classes_lock_)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700638 REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogers848871b2013-08-05 10:56:33 -0700639
Vladimir Marko1998cd02017-01-13 13:02:58 +0000640 // Add an oat file with .bss GC roots to be visited again at the end of GC
641 // for collector types that need it.
642 void WriteBarrierForBootOatFileBssRoots(const OatFile* oat_file)
643 REQUIRES(!Locks::classlinker_classes_lock_)
644 REQUIRES_SHARED(Locks::mutator_lock_);
645
Vladimir Markob4eb1b12018-05-24 11:09:38 +0100646 template <ReadBarrierOption kReadBarrierOption = kWithReadBarrier>
Andreas Gampe88dbad32018-06-26 19:54:12 -0700647 ObjPtr<mirror::ObjectArray<mirror::Class>> GetClassRoots() REQUIRES_SHARED(Locks::mutator_lock_);
Mingyao Yang98d1cc82014-05-15 17:02:16 -0700648
Mathieu Chartierc2e20622014-11-03 11:41:47 -0800649 // Move the class table to the pre-zygote table to reduce memory usage. This works by ensuring
650 // that no more classes are ever added to the pre zygote table which makes it that the pages
651 // always remain shared dirty instead of private dirty.
652 void MoveClassTableToPreZygote()
Mathieu Chartier90443472015-07-16 20:32:27 -0700653 REQUIRES(!Locks::classlinker_classes_lock_)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700654 REQUIRES_SHARED(Locks::mutator_lock_);
Mathieu Chartierc2e20622014-11-03 11:41:47 -0800655
Calin Juravle7865ac72017-06-28 11:03:12 -0700656 // Creates a GlobalRef PathClassLoader or DelegateLastClassLoader (specified by loader_class)
657 // that can be used to load classes from the given dex files. The parent of the class loader
658 // will be set to `parent_loader`. If `parent_loader` is null the parent will be
659 // the boot class loader.
660 // If class_loader points to a different class than PathClassLoader or DelegateLastClassLoader
661 // this method will abort.
Andreas Gampe81c6f8d2015-03-25 17:19:53 -0700662 // Note: the objects are not completely set up. Do not use this outside of tests and the compiler.
Calin Juravle7865ac72017-06-28 11:03:12 -0700663 jobject CreateWellKnownClassLoader(Thread* self,
664 const std::vector<const DexFile*>& dex_files,
665 jclass loader_class,
Nicolas Geoffraye1672732018-11-30 01:09:49 +0000666 jobject parent_loader,
Brad Stenning9c924e82021-10-11 19:09:00 -0700667 jobject shared_libraries = nullptr,
668 jobject shared_libraries_after = nullptr)
Calin Juravle7865ac72017-06-28 11:03:12 -0700669 REQUIRES_SHARED(Locks::mutator_lock_)
670 REQUIRES(!Locks::dex_lock_);
671
672 // Calls CreateWellKnownClassLoader(self,
673 // dex_files,
674 // WellKnownClasses::dalvik_system_PathClassLoader,
675 // nullptr)
Jeff Haof0192c82016-03-28 20:39:50 -0700676 jobject CreatePathClassLoader(Thread* self, const std::vector<const DexFile*>& dex_files)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700677 REQUIRES_SHARED(Locks::mutator_lock_)
Andreas Gampecc1b5352016-12-01 16:58:38 -0800678 REQUIRES(!Locks::dex_lock_);
Andreas Gampe81c6f8d2015-03-25 17:19:53 -0700679
Nicolas Geoffray6b9fd8c2018-11-16 10:25:42 +0000680 // Non-GlobalRef version of CreateWellKnownClassLoader
681 ObjPtr<mirror::ClassLoader> CreateWellKnownClassLoader(
682 Thread* self,
683 const std::vector<const DexFile*>& dex_files,
684 Handle<mirror::Class> loader_class,
Nicolas Geoffraye1672732018-11-30 01:09:49 +0000685 Handle<mirror::ClassLoader> parent_loader,
Brad Stenning9c924e82021-10-11 19:09:00 -0700686 Handle<mirror::ObjectArray<mirror::ClassLoader>> shared_libraries,
687 Handle<mirror::ObjectArray<mirror::ClassLoader>> shared_libraries_after)
Nicolas Geoffray6b9fd8c2018-11-16 10:25:42 +0000688 REQUIRES_SHARED(Locks::mutator_lock_)
689 REQUIRES(!Locks::dex_lock_);
690
Andreas Gampe542451c2016-07-26 09:02:02 -0700691 PointerSize GetImagePointerSize() const {
Mathieu Chartiere401d142015-04-22 13:56:20 -0700692 return image_pointer_size_;
693 }
694
Andreas Gampe8ac75952015-06-02 21:01:45 -0700695 // Clear the ArrayClass cache. This is necessary when cleaning up for the image, as the cache
696 // entries are roots, but potentially not image classes.
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700697 void DropFindArrayClassCache() REQUIRES_SHARED(Locks::mutator_lock_);
Andreas Gampe8ac75952015-06-02 21:01:45 -0700698
Mathieu Chartier951ec2c2015-09-22 08:50:05 -0700699 // Clean up class loaders, this needs to happen after JNI weak globals are cleared.
700 void CleanupClassLoaders()
Mathieu Chartier00310e02015-10-17 12:46:42 -0700701 REQUIRES(!Locks::classlinker_classes_lock_)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700702 REQUIRES_SHARED(Locks::mutator_lock_);
Mathieu Chartier951ec2c2015-09-22 08:50:05 -0700703
Mathieu Chartier32cc9ee2015-10-15 09:19:15 -0700704 // Unlike GetOrCreateAllocatorForClassLoader, GetAllocatorForClassLoader asserts that the
705 // allocator for this class loader is already created.
Mathieu Chartier28357fa2016-10-18 16:27:40 -0700706 LinearAlloc* GetAllocatorForClassLoader(ObjPtr<mirror::ClassLoader> class_loader)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700707 REQUIRES_SHARED(Locks::mutator_lock_);
Mathieu Chartier951ec2c2015-09-22 08:50:05 -0700708
Mathieu Chartierd57d4542015-10-14 10:55:30 -0700709 // Return the linear alloc for a class loader if it is already allocated, otherwise allocate and
710 // set it. TODO: Consider using a lock other than classlinker_classes_lock_.
Mathieu Chartier28357fa2016-10-18 16:27:40 -0700711 LinearAlloc* GetOrCreateAllocatorForClassLoader(ObjPtr<mirror::ClassLoader> class_loader)
Mathieu Chartier00310e02015-10-17 12:46:42 -0700712 REQUIRES(!Locks::classlinker_classes_lock_)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700713 REQUIRES_SHARED(Locks::mutator_lock_);
Mathieu Chartier00310e02015-10-17 12:46:42 -0700714
Mathieu Chartier6d25cf62016-04-12 16:54:48 -0700715 // May be called with null class_loader due to legacy code. b/27954959
Mathieu Chartierbc5a7952016-10-17 15:46:31 -0700716 void InsertDexFileInToClassLoader(ObjPtr<mirror::Object> dex_file,
717 ObjPtr<mirror::ClassLoader> class_loader)
Mathieu Chartier00310e02015-10-17 12:46:42 -0700718 REQUIRES(!Locks::classlinker_classes_lock_)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700719 REQUIRES_SHARED(Locks::mutator_lock_);
Mathieu Chartierd57d4542015-10-14 10:55:30 -0700720
Tamas Berghammerdd5e5e92016-02-12 16:29:00 +0000721 static bool ShouldUseInterpreterEntrypoint(ArtMethod* method, const void* quick_code)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700722 REQUIRES_SHARED(Locks::mutator_lock_);
Tamas Berghammerdd5e5e92016-02-12 16:29:00 +0000723
Jeff Haof0192c82016-03-28 20:39:50 -0700724 static bool IsBootClassLoader(ScopedObjectAccessAlreadyRunnable& soa,
Mathieu Chartier28357fa2016-10-18 16:27:40 -0700725 ObjPtr<mirror::ClassLoader> class_loader)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700726 REQUIRES_SHARED(Locks::mutator_lock_);
Jeff Haof0192c82016-03-28 20:39:50 -0700727
Mathieu Chartier28357fa2016-10-18 16:27:40 -0700728 ArtMethod* AddMethodToConflictTable(ObjPtr<mirror::Class> klass,
Mathieu Chartier7f98c9a2016-04-14 10:49:19 -0700729 ArtMethod* conflict_method,
730 ArtMethod* interface_method,
Nicolas Geoffray47213e42020-12-30 15:12:00 +0000731 ArtMethod* method)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700732 REQUIRES_SHARED(Locks::mutator_lock_);
Mathieu Chartier7f98c9a2016-04-14 10:49:19 -0700733
Mathieu Chartiere42888f2016-04-14 10:49:19 -0700734 // Create a conflict table with a specified capacity.
735 ImtConflictTable* CreateImtConflictTable(size_t count, LinearAlloc* linear_alloc);
736
737 // Static version for when the class linker is not yet created.
738 static ImtConflictTable* CreateImtConflictTable(size_t count,
739 LinearAlloc* linear_alloc,
Andreas Gampe542451c2016-07-26 09:02:02 -0700740 PointerSize pointer_size);
Mathieu Chartiere42888f2016-04-14 10:49:19 -0700741
742
743 // Create the IMT and conflict tables for a class.
Mathieu Chartier28357fa2016-10-18 16:27:40 -0700744 void FillIMTAndConflictTables(ObjPtr<mirror::Class> klass) REQUIRES_SHARED(Locks::mutator_lock_);
Mathieu Chartiere42888f2016-04-14 10:49:19 -0700745
Mathieu Chartier72041a02017-07-14 18:23:25 -0700746 // Visit all of the class tables. This is used by dex2oat to allow pruning dex caches.
747 template <class Visitor>
748 void VisitClassTables(const Visitor& visitor)
Mathieu Chartier696632e2016-06-03 17:47:32 -0700749 REQUIRES(!Locks::classlinker_classes_lock_)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700750 REQUIRES_SHARED(Locks::mutator_lock_);
Mathieu Chartiere42888f2016-04-14 10:49:19 -0700751
Alexey Grebenkin252a4e42018-04-02 18:18:01 +0300752 // Visit all of the allocators that belong to classloaders except boot classloader.
753 // This is used by 616-cha-unloading test to confirm memory reuse.
754 void VisitAllocators(AllocatorVisitor* visitor) const
755 REQUIRES_SHARED(Locks::classlinker_classes_lock_, Locks::mutator_lock_);
756
Jeff Haoc92a7a12016-06-06 11:09:20 -0700757 // Throw the class initialization failure recorded when first trying to initialize the given
758 // class.
Andreas Gampe7b3063b2019-01-07 14:12:52 -0800759 void ThrowEarlierClassFailure(ObjPtr<mirror::Class> c,
760 bool wrap_in_no_class_def = false,
761 bool log = false)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700762 REQUIRES_SHARED(Locks::mutator_lock_)
Andreas Gampecc1b5352016-12-01 16:58:38 -0800763 REQUIRES(!Locks::dex_lock_);
Jeff Haoc92a7a12016-06-06 11:09:20 -0700764
Mathieu Chartier65975772016-08-05 10:46:36 -0700765 // Get the actual holding class for a copied method. Pretty slow, don't call often.
Vladimir Markoa8bba7d2018-05-30 15:18:48 +0100766 ObjPtr<mirror::Class> GetHoldingClassOfCopiedMethod(ArtMethod* method)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700767 REQUIRES_SHARED(Locks::mutator_lock_);
Mathieu Chartier65975772016-08-05 10:46:36 -0700768
Andreas Gampe70f16392017-01-16 14:20:10 -0800769 // Returns null if not found.
Andreas Gampe2af99022017-04-25 08:32:59 -0700770 // This returns a pointer to the class-table, without requiring any locking - including the
771 // boot class-table. It is the caller's responsibility to access this under lock, if required.
Andreas Gampe70f16392017-01-16 14:20:10 -0800772 ClassTable* ClassTableForClassLoader(ObjPtr<mirror::ClassLoader> class_loader)
Andreas Gampe2af99022017-04-25 08:32:59 -0700773 REQUIRES_SHARED(Locks::mutator_lock_)
774 NO_THREAD_SAFETY_ANALYSIS;
Andreas Gampe70f16392017-01-16 14:20:10 -0800775
Mathieu Chartier0a19e212019-11-27 14:35:24 -0800776 void AppendToBootClassPath(Thread* self, const DexFile* dex_file)
Andreas Gampece7732b2017-01-17 15:50:26 -0800777 REQUIRES_SHARED(Locks::mutator_lock_)
778 REQUIRES(!Locks::dex_lock_);
779
Mathieu Chartier06bed302017-07-13 13:23:18 -0700780 // Visit all of the class loaders in the class linker.
781 void VisitClassLoaders(ClassLoaderVisitor* visitor) const
782 REQUIRES_SHARED(Locks::classlinker_classes_lock_, Locks::mutator_lock_);
783
Jeff Hao0cb17282017-07-12 14:51:49 -0700784 // Checks that a class and its superclass from another class loader have the same virtual methods.
785 bool ValidateSuperClassDescriptors(Handle<mirror::Class> klass)
786 REQUIRES_SHARED(Locks::mutator_lock_);
787
Andreas Gampec1ac9ee2017-07-24 22:35:49 -0700788 ClassHierarchyAnalysis* GetClassHierarchyAnalysis() {
789 return cha_.get();
790 }
791
Vladimir Markobf121912019-06-04 13:49:05 +0100792 void MakeInitializedClassesVisiblyInitialized(Thread* self, bool wait);
793
Vladimir Marko86c87522020-05-11 16:55:55 +0100794 // Registers the native method and returns the new entry point. NB The returned entry point
795 // might be different from the native_method argument if some MethodCallback modifies it.
796 const void* RegisterNative(Thread* self, ArtMethod* method, const void* native_method)
797 REQUIRES_SHARED(Locks::mutator_lock_) WARN_UNUSED;
798
799 // Unregister native code for a method.
800 void UnregisterNative(Thread* self, ArtMethod* method) REQUIRES_SHARED(Locks::mutator_lock_);
801
802 // Get the registered native method entrypoint, if any, otherwise null.
803 const void* GetRegisteredNative(Thread* self, ArtMethod* method)
804 REQUIRES_SHARED(Locks::mutator_lock_)
805 REQUIRES(!critical_native_code_with_clinit_check_lock_);
806
Hiroshi Yamauchi04302db2015-11-11 23:45:34 -0800807 struct DexCacheData {
Vladimir Markocd556b02017-02-03 11:47:34 +0000808 // Construct an invalid data object.
David Srbecky6fbcc292021-02-23 01:05:32 +0000809 DexCacheData() : weak_root(nullptr), class_table(nullptr) {
810 static std::atomic_uint64_t s_registration_count(0);
811 registration_index = s_registration_count.fetch_add(1, std::memory_order_seq_cst);
Vladimir Markocd556b02017-02-03 11:47:34 +0000812 }
David Srbecky6fbcc292021-02-23 01:05:32 +0000813 DexCacheData(DexCacheData&&) = default;
Vladimir Markocd556b02017-02-03 11:47:34 +0000814
Hiroshi Yamauchi04302db2015-11-11 23:45:34 -0800815 // Weak root to the DexCache. Note: Do not decode this unnecessarily or else class unloading may
816 // not work properly.
817 jweak weak_root;
Vladimir Markocd556b02017-02-03 11:47:34 +0000818 // Identify the associated class loader's class table. This is used to make sure that
819 // the Java call to native DexCache.setResolvedType() inserts the resolved type in that
820 // class table. It is also used to make sure we don't register the same dex cache with
821 // multiple class loaders.
822 ClassTable* class_table;
David Srbecky6fbcc292021-02-23 01:05:32 +0000823 // Monotonically increasing integer which records the order in which DexFiles were registered.
824 // Used only to preserve determinism when creating compiled image.
825 uint64_t registration_index;
826
827 private:
828 DISALLOW_COPY_AND_ASSIGN(DexCacheData);
Hiroshi Yamauchi04302db2015-11-11 23:45:34 -0800829 };
830
Alex Lightfb119572019-09-18 15:04:53 -0700831 // Forces a class to be marked as initialized without actually running initializers. Should only
832 // be used by plugin code when creating new classes directly.
833 void ForceClassInitialized(Thread* self, Handle<mirror::Class> klass)
834 REQUIRES_SHARED(Locks::mutator_lock_)
835 REQUIRES(!Locks::dex_lock_, !Roles::uninterruptible_);
836
Calin Juravle33787682019-07-26 14:27:18 -0700837 // Verifies if the method is accesible according to the SdkChecker (if installed).
Calin Juravle2c2724c2021-01-14 19:54:23 -0800838 virtual bool DenyAccessBasedOnPublicSdk(ArtMethod* art_method) const
Calin Juravle33787682019-07-26 14:27:18 -0700839 REQUIRES_SHARED(Locks::mutator_lock_);
840 // Verifies if the field is accesible according to the SdkChecker (if installed).
Calin Juravle2c2724c2021-01-14 19:54:23 -0800841 virtual bool DenyAccessBasedOnPublicSdk(ArtField* art_field) const
Calin Juravle33787682019-07-26 14:27:18 -0700842 REQUIRES_SHARED(Locks::mutator_lock_);
843 // Verifies if the descriptor is accesible according to the SdkChecker (if installed).
Calin Juravle2c2724c2021-01-14 19:54:23 -0800844 virtual bool DenyAccessBasedOnPublicSdk(const char* type_descriptor) const;
845 // Enable or disable public sdk checks.
846 virtual void SetEnablePublicSdkChecks(bool enabled);
Calin Juravle33787682019-07-26 14:27:18 -0700847
Chang Xing605fe242017-07-20 15:57:21 -0700848 protected:
849 virtual bool InitializeClass(Thread* self,
850 Handle<mirror::Class> klass,
851 bool can_run_clinit,
852 bool can_init_parents)
853 REQUIRES_SHARED(Locks::mutator_lock_)
854 REQUIRES(!Locks::dex_lock_);
855
Mathieu Chartier9e050df2017-08-09 10:05:47 -0700856 virtual verifier::FailureKind PerformClassVerification(Thread* self,
Nicolas Geoffray5b0b2e12021-03-19 14:48:40 +0000857 verifier::VerifierDeps* verifier_deps,
Mathieu Chartier9e050df2017-08-09 10:05:47 -0700858 Handle<mirror::Class> klass,
859 verifier::HardFailLogMode log_level,
860 std::string* error_msg)
861 REQUIRES_SHARED(Locks::mutator_lock_);
862
Chang Xing0c2c2222017-08-04 14:36:17 -0700863 virtual bool CanAllocClass() REQUIRES_SHARED(Locks::mutator_lock_) REQUIRES(!Locks::dex_lock_) {
864 return true;
865 }
866
Mathieu Chartier951ec2c2015-09-22 08:50:05 -0700867 private:
Vladimir Marko42bee502021-01-28 14:58:35 +0000868 class LinkFieldsHelper;
Vladimir Markobc893672021-11-10 15:25:46 +0000869 class LinkMethodsHelper;
Vladimir Marko782fb712020-12-23 12:47:31 +0000870 class MethodTranslation;
Vladimir Markobf121912019-06-04 13:49:05 +0100871 class VisiblyInitializedCallback;
Vladimir Marko921094a2017-01-12 18:37:06 +0000872
Mathieu Chartier951ec2c2015-09-22 08:50:05 -0700873 struct ClassLoaderData {
Mathieu Chartierc3fcd412015-09-25 16:54:59 -0700874 jweak weak_root; // Weak root to enable class unloading.
Mathieu Chartier951ec2c2015-09-22 08:50:05 -0700875 ClassTable* class_table;
876 LinearAlloc* allocator;
877 };
878
Vladimir Markobf121912019-06-04 13:49:05 +0100879 void VisiblyInitializedCallbackDone(Thread* self, VisiblyInitializedCallback* callback);
880 VisiblyInitializedCallback* MarkClassInitialized(Thread* self, Handle<mirror::Class> klass)
881 REQUIRES_SHARED(Locks::mutator_lock_);
882
Alex Lightf1f10492015-10-07 16:08:36 -0700883 // Ensures that the supertype of 'klass' ('supertype') is verified. Returns false and throws
884 // appropriate exceptions if verification failed hard. Returns true for successful verification or
885 // soft-failures.
886 bool AttemptSupertypeVerification(Thread* self,
Nicolas Geoffray5b0b2e12021-03-19 14:48:40 +0000887 verifier::VerifierDeps* verifier_deps,
Alex Lightf1f10492015-10-07 16:08:36 -0700888 Handle<mirror::Class> klass,
889 Handle<mirror::Class> supertype)
Andreas Gampecc1b5352016-12-01 16:58:38 -0800890 REQUIRES(!Locks::dex_lock_)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700891 REQUIRES_SHARED(Locks::mutator_lock_);
Alex Lightf1f10492015-10-07 16:08:36 -0700892
Alexey Grebenkinbe4c2bd2018-02-01 19:09:59 +0300893 void DeleteClassLoader(Thread* self, const ClassLoaderData& data, bool cleanup_cha)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700894 REQUIRES_SHARED(Locks::mutator_lock_);
Nicolas Geoffray1dad3f62015-10-23 14:59:54 +0100895
Mathieu Chartiere0671ce2015-07-28 17:23:28 -0700896 void VisitClassesInternal(ClassVisitor* visitor)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700897 REQUIRES_SHARED(Locks::classlinker_classes_lock_, Locks::mutator_lock_);
Mathieu Chartiercc5ebdf2015-07-27 11:19:43 -0700898
899 // Returns the number of zygote and image classes.
Mathieu Chartier6b069532015-08-05 15:08:12 -0700900 size_t NumZygoteClasses() const
901 REQUIRES(Locks::classlinker_classes_lock_)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700902 REQUIRES_SHARED(Locks::mutator_lock_);
Mathieu Chartiercc5ebdf2015-07-27 11:19:43 -0700903
904 // Returns the number of non zygote nor image classes.
Mathieu Chartier6b069532015-08-05 15:08:12 -0700905 size_t NumNonZygoteClasses() const
906 REQUIRES(Locks::classlinker_classes_lock_)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700907 REQUIRES_SHARED(Locks::mutator_lock_);
Mathieu Chartiercc5ebdf2015-07-27 11:19:43 -0700908
Mathieu Chartierc77f3ab2015-09-03 19:41:50 -0700909 void FinishInit(Thread* self)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700910 REQUIRES_SHARED(Locks::mutator_lock_)
Andreas Gampecc1b5352016-12-01 16:58:38 -0800911 REQUIRES(!Locks::dex_lock_, !Roles::uninterruptible_);
Brian Carlstroma663ea52011-08-19 23:33:41 -0700912
Roland Levillain0e840272018-08-23 19:55:30 +0100913 // If we do not allow moving classes (`art::kMovingClass` is false) or if
914 // parameter `kMovable` is false (or both), the class object is allocated in
915 // the non-moving space.
Vladimir Marko70e2a762019-07-12 16:49:00 +0100916 template <bool kMovable = true, class PreFenceVisitor>
917 ObjPtr<mirror::Class> AllocClass(Thread* self,
918 ObjPtr<mirror::Class> java_lang_Class,
919 uint32_t class_size,
920 const PreFenceVisitor& pre_fence_visitor)
921 REQUIRES_SHARED(Locks::mutator_lock_)
922 REQUIRES(!Roles::uninterruptible_);
923
924 // Convenience AllocClass() overload that uses mirror::Class::InitializeClassVisitor
925 // for the class initialization.
Roland Levillain0e840272018-08-23 19:55:30 +0100926 template <bool kMovable = true>
Vladimir Markoa8bba7d2018-05-30 15:18:48 +0100927 ObjPtr<mirror::Class> AllocClass(Thread* self,
928 ObjPtr<mirror::Class> java_lang_Class,
929 uint32_t class_size)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700930 REQUIRES_SHARED(Locks::mutator_lock_)
Mathieu Chartierc77f3ab2015-09-03 19:41:50 -0700931 REQUIRES(!Roles::uninterruptible_);
Brian Carlstrom75cb3b42011-07-28 02:13:36 -0700932
Vladimir Marko70e2a762019-07-12 16:49:00 +0100933 // Allocate a primitive array class and store it in appropriate class root.
934 void AllocPrimitiveArrayClass(Thread* self,
935 ClassRoot primitive_root,
936 ClassRoot array_root)
937 REQUIRES_SHARED(Locks::mutator_lock_)
938 REQUIRES(!Roles::uninterruptible_);
939
940 // Finish setup of an array class.
941 void FinishArrayClassSetup(ObjPtr<mirror::Class> array_class)
942 REQUIRES_SHARED(Locks::mutator_lock_)
943 REQUIRES(!Roles::uninterruptible_);
944
945 // Finish setup of a core array class (Object[], Class[], String[] and
946 // primitive arrays) and insert it into the class table.
947 void FinishCoreArrayClassSetup(ClassRoot array_root)
Roland Levillain0e840272018-08-23 19:55:30 +0100948 REQUIRES_SHARED(Locks::mutator_lock_)
949 REQUIRES(!Roles::uninterruptible_);
950
David Srbecky86d6cd52020-12-02 18:13:10 +0000951 ObjPtr<mirror::DexCache> AllocDexCache(Thread* self, const DexFile& dex_file)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700952 REQUIRES_SHARED(Locks::mutator_lock_)
Mathieu Chartierc77f3ab2015-09-03 19:41:50 -0700953 REQUIRES(!Roles::uninterruptible_);
Ian Rogersbdb03912011-09-14 00:55:44 -0700954
Mathieu Chartier6c60d842016-09-15 10:24:43 -0700955 // Used for tests and AppendToBootClassPath.
Vladimir Markobcf17522018-06-01 13:14:32 +0100956 ObjPtr<mirror::DexCache> AllocAndInitializeDexCache(Thread* self,
957 const DexFile& dex_file,
David Srbecky33df0e32021-09-30 14:36:32 +0000958 ObjPtr<mirror::ClassLoader> class_loader)
Mathieu Chartier6c60d842016-09-15 10:24:43 -0700959 REQUIRES_SHARED(Locks::mutator_lock_)
Andreas Gampecc1b5352016-12-01 16:58:38 -0800960 REQUIRES(!Locks::dex_lock_)
Mathieu Chartier6c60d842016-09-15 10:24:43 -0700961 REQUIRES(!Roles::uninterruptible_);
962
Vladimir Marko70e2a762019-07-12 16:49:00 +0100963 // Create a primitive class and store it in the appropriate class root.
964 void CreatePrimitiveClass(Thread* self, Primitive::Type type, ClassRoot primitive_root)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700965 REQUIRES_SHARED(Locks::mutator_lock_)
Mathieu Chartierc77f3ab2015-09-03 19:41:50 -0700966 REQUIRES(!Roles::uninterruptible_);
Brian Carlstroma331b3c2011-07-18 17:47:56 -0700967
Vladimir Markoa8bba7d2018-05-30 15:18:48 +0100968 ObjPtr<mirror::Class> CreateArrayClass(Thread* self,
969 const char* descriptor,
970 size_t hash,
971 Handle<mirror::ClassLoader> class_loader)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700972 REQUIRES_SHARED(Locks::mutator_lock_)
Andreas Gampecc1b5352016-12-01 16:58:38 -0800973 REQUIRES(!Locks::dex_lock_, !Roles::uninterruptible_);
Brian Carlstroma331b3c2011-07-18 17:47:56 -0700974
Mathieu Chartier0a19e212019-11-27 14:35:24 -0800975 void AppendToBootClassPath(const DexFile* dex_file, ObjPtr<mirror::DexCache> dex_cache)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700976 REQUIRES_SHARED(Locks::mutator_lock_)
Andreas Gampecc1b5352016-12-01 16:58:38 -0800977 REQUIRES(!Locks::dex_lock_);
Brian Carlstrom578bbdc2011-07-21 14:07:47 -0700978
Mingyao Yang98d1cc82014-05-15 17:02:16 -0700979 // Precomputes size needed for Class, in the case of a non-temporary class this size must be
980 // sufficient to hold all static fields.
981 uint32_t SizeOfClassWithoutEmbeddedTables(const DexFile& dex_file,
Andreas Gampe3f1dcd32018-12-28 09:39:56 -0800982 const dex::ClassDef& dex_class_def);
Brian Carlstrom4873d462011-08-21 15:23:39 -0700983
Mathieu Chartier1f1cb9f2018-06-04 09:22:46 -0700984 void LoadField(const ClassAccessor::Field& field, Handle<mirror::Class> klass, ArtField* dst)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700985 REQUIRES_SHARED(Locks::mutator_lock_);
Brian Carlstrom578bbdc2011-07-21 14:07:47 -0700986
Mathieu Chartier268764d2016-09-13 12:09:38 -0700987 void LoadMethod(const DexFile& dex_file,
Mathieu Chartier1f1cb9f2018-06-04 09:22:46 -0700988 const ClassAccessor::Method& method,
989 Handle<mirror::Class> klass,
990 ArtMethod* dst)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700991 REQUIRES_SHARED(Locks::mutator_lock_);
Brian Carlstrom934486c2011-07-12 23:42:50 -0700992
Vladimir Marko86c87522020-05-11 16:55:55 +0100993 void FixupStaticTrampolines(Thread* self, ObjPtr<mirror::Class> klass)
994 REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogers19846512012-02-24 11:42:47 -0800995
Nicolas Geoffray7d8d8ff2016-11-02 12:38:05 +0000996 // Finds a class in a Path- or DexClassLoader, loading it if necessary without using JNI. Hash
Andreas Gampe34ee6842014-12-02 15:43:52 -0800997 // function is supposed to be ComputeModifiedUtf8Hash(descriptor). Returns true if the
998 // class-loader chain could be handled, false otherwise, i.e., a non-supported class-loader
999 // was encountered while walking the parent chain (currently only BootClassLoader and
1000 // PathClassLoader are supported).
Nicolas Geoffray7d8d8ff2016-11-02 12:38:05 +00001001 bool FindClassInBaseDexClassLoader(ScopedObjectAccessAlreadyRunnable& soa,
1002 Thread* self,
1003 const char* descriptor,
1004 size_t hash,
1005 Handle<mirror::ClassLoader> class_loader,
Vladimir Markobcf17522018-06-01 13:14:32 +01001006 /*out*/ ObjPtr<mirror::Class>* result)
Andreas Gampe34ee6842014-12-02 15:43:52 -08001007 REQUIRES_SHARED(Locks::mutator_lock_)
Andreas Gampecc1b5352016-12-01 16:58:38 -08001008 REQUIRES(!Locks::dex_lock_);
Andreas Gampe34ee6842014-12-02 15:43:52 -08001009
Nicolas Geoffray80a560c2018-10-26 13:48:51 +01001010 bool FindClassInSharedLibraries(ScopedObjectAccessAlreadyRunnable& soa,
1011 Thread* self,
1012 const char* descriptor,
1013 size_t hash,
1014 Handle<mirror::ClassLoader> class_loader,
1015 /*out*/ ObjPtr<mirror::Class>* result)
1016 REQUIRES_SHARED(Locks::mutator_lock_)
1017 REQUIRES(!Locks::dex_lock_);
1018
Brad Stenning9c924e82021-10-11 19:09:00 -07001019 bool FindClassInSharedLibrariesHelper(ScopedObjectAccessAlreadyRunnable& soa,
1020 Thread* self,
1021 const char* descriptor,
1022 size_t hash,
1023 Handle<mirror::ClassLoader> class_loader,
1024 ArtField* field,
1025 /*out*/ ObjPtr<mirror::Class>* result)
1026 REQUIRES_SHARED(Locks::mutator_lock_)
1027 REQUIRES(!Locks::dex_lock_);
1028
1029 bool FindClassInSharedLibrariesAfter(ScopedObjectAccessAlreadyRunnable& soa,
1030 Thread* self,
1031 const char* descriptor,
1032 size_t hash,
1033 Handle<mirror::ClassLoader> class_loader,
1034 /*out*/ ObjPtr<mirror::Class>* result)
1035 REQUIRES_SHARED(Locks::mutator_lock_)
1036 REQUIRES(!Locks::dex_lock_);
1037
Calin Juravle415dc3d2017-06-28 11:03:12 -07001038 // Finds the class in the classpath of the given class loader. It only searches the class loader
1039 // dex files and does not recurse into its parent.
1040 // The method checks that the provided class loader is either a PathClassLoader or a
1041 // DexClassLoader.
Nicolas Geoffraye8445e52021-09-23 14:10:05 +01001042 // If the class is found the method updates `result`.
1043 // The method always returns true, to notify to the caller a
1044 // BaseDexClassLoader has a known lookup.
1045 bool FindClassInBaseDexClassLoaderClassPath(
Calin Juravle415dc3d2017-06-28 11:03:12 -07001046 ScopedObjectAccessAlreadyRunnable& soa,
1047 const char* descriptor,
1048 size_t hash,
Nicolas Geoffraye8445e52021-09-23 14:10:05 +01001049 Handle<mirror::ClassLoader> class_loader,
1050 /*out*/ ObjPtr<mirror::Class>* result)
Calin Juravle415dc3d2017-06-28 11:03:12 -07001051 REQUIRES_SHARED(Locks::mutator_lock_)
1052 REQUIRES(!Locks::dex_lock_);
1053
1054 // Finds the class in the boot class loader.
Nicolas Geoffraye8445e52021-09-23 14:10:05 +01001055 // If the class is found the method updates `result`.
1056 // The method always returns true, to notify to the caller the
1057 // boot class loader has a known lookup.
1058 bool FindClassInBootClassLoaderClassPath(Thread* self,
1059 const char* descriptor,
1060 size_t hash,
1061 /*out*/ ObjPtr<mirror::Class>* result)
Calin Juravle415dc3d2017-06-28 11:03:12 -07001062 REQUIRES_SHARED(Locks::mutator_lock_)
1063 REQUIRES(!Locks::dex_lock_);
1064
Vladimir Marko666ee3d2017-12-11 18:37:36 +00001065 // Implementation of LookupResolvedType() called when the type was not found in the dex cache.
1066 ObjPtr<mirror::Class> DoLookupResolvedType(dex::TypeIndex type_idx,
Vladimir Marko09c5ca42018-05-31 15:15:31 +01001067 ObjPtr<mirror::Class> referrer)
1068 REQUIRES_SHARED(Locks::mutator_lock_);
1069 ObjPtr<mirror::Class> DoLookupResolvedType(dex::TypeIndex type_idx,
Vladimir Marko666ee3d2017-12-11 18:37:36 +00001070 ObjPtr<mirror::DexCache> dex_cache,
1071 ObjPtr<mirror::ClassLoader> class_loader)
1072 REQUIRES_SHARED(Locks::mutator_lock_);
1073
Vladimir Marko18090d12018-06-01 16:53:12 +01001074 // Implementation of ResolveString() called when the string was not found in the dex cache.
1075 ObjPtr<mirror::String> DoResolveString(dex::StringIndex string_idx,
1076 ObjPtr<mirror::DexCache> dex_cache)
1077 REQUIRES_SHARED(Locks::mutator_lock_);
1078 ObjPtr<mirror::String> DoResolveString(dex::StringIndex string_idx,
1079 Handle<mirror::DexCache> dex_cache)
1080 REQUIRES_SHARED(Locks::mutator_lock_);
1081
1082 // Implementation of LookupString() called when the string was not found in the dex cache.
1083 ObjPtr<mirror::String> DoLookupString(dex::StringIndex string_idx,
1084 ObjPtr<mirror::DexCache> dex_cache)
1085 REQUIRES_SHARED(Locks::mutator_lock_);
1086
Andreas Gampeb0625e02019-05-01 12:43:31 -07001087 // Implementation of ResolveType() called when the type was not found in the dex cache. May be
1088 // used with ArtField*, ArtMethod* or ObjPtr<Class>.
1089 template <typename RefType>
1090 ObjPtr<mirror::Class> DoResolveType(dex::TypeIndex type_idx, RefType referrer)
Vladimir Marko09c5ca42018-05-31 15:15:31 +01001091 REQUIRES_SHARED(Locks::mutator_lock_)
1092 REQUIRES(!Locks::dex_lock_, !Roles::uninterruptible_);
1093 ObjPtr<mirror::Class> DoResolveType(dex::TypeIndex type_idx,
Vladimir Marko666ee3d2017-12-11 18:37:36 +00001094 Handle<mirror::DexCache> dex_cache,
1095 Handle<mirror::ClassLoader> class_loader)
1096 REQUIRES_SHARED(Locks::mutator_lock_)
1097 REQUIRES(!Locks::dex_lock_, !Roles::uninterruptible_);
1098
Andreas Gampe34ee6842014-12-02 15:43:52 -08001099 // Finds a class by its descriptor, returning NULL if it isn't wasn't loaded
1100 // by the given 'class_loader'. Uses the provided hash for the descriptor.
Vladimir Markoa8bba7d2018-05-30 15:18:48 +01001101 ObjPtr<mirror::Class> LookupClass(Thread* self,
1102 const char* descriptor,
1103 size_t hash,
1104 ObjPtr<mirror::ClassLoader> class_loader)
Andreas Gampe34ee6842014-12-02 15:43:52 -08001105 REQUIRES(!Locks::classlinker_classes_lock_)
1106 REQUIRES_SHARED(Locks::mutator_lock_);
1107
Vladimir Markof44d36c2017-03-14 14:18:46 +00001108 // Find a field by its field index.
1109 ArtField* LookupResolvedField(uint32_t field_idx,
1110 ObjPtr<mirror::DexCache> dex_cache,
1111 ObjPtr<mirror::ClassLoader> class_loader,
1112 bool is_static)
1113 REQUIRES_SHARED(Locks::mutator_lock_);
1114
Vladimir Markocd556b02017-02-03 11:47:34 +00001115 void RegisterDexFileLocked(const DexFile& dex_file,
1116 ObjPtr<mirror::DexCache> dex_cache,
1117 ObjPtr<mirror::ClassLoader> class_loader)
Andreas Gampecc1b5352016-12-01 16:58:38 -08001118 REQUIRES(Locks::dex_lock_)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -07001119 REQUIRES_SHARED(Locks::mutator_lock_);
Alex Light725da8f2020-02-19 14:46:33 -08001120 const DexCacheData* FindDexCacheDataLocked(const DexFile& dex_file)
Santiago Aboy Solanes970ba212021-10-21 10:52:47 +01001121 REQUIRES_SHARED(Locks::dex_lock_);
Santiago Aboy Solanes4b8ea5d2021-11-19 10:14:54 +00001122 const DexCacheData* FindDexCacheDataLocked(const OatDexFile& oat_dex_file)
Santiago Aboy Solanes970ba212021-10-21 10:52:47 +01001123 REQUIRES_SHARED(Locks::dex_lock_);
Alex Light725da8f2020-02-19 14:46:33 -08001124 static ObjPtr<mirror::DexCache> DecodeDexCacheLocked(Thread* self, const DexCacheData* data)
1125 REQUIRES_SHARED(Locks::dex_lock_, Locks::mutator_lock_);
1126 bool IsSameClassLoader(ObjPtr<mirror::DexCache> dex_cache,
1127 const DexCacheData* data,
1128 ObjPtr<mirror::ClassLoader> class_loader)
1129 REQUIRES_SHARED(Locks::dex_lock_, Locks::mutator_lock_);
Brian Carlstromaded5f72011-10-07 17:15:04 -07001130
Alex Lighteb7c1442015-08-31 13:17:42 -07001131 bool InitializeDefaultInterfaceRecursive(Thread* self,
1132 Handle<mirror::Class> klass,
1133 bool can_run_clinit,
1134 bool can_init_parents)
Andreas Gampecc1b5352016-12-01 16:58:38 -08001135 REQUIRES(!Locks::dex_lock_)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -07001136 REQUIRES_SHARED(Locks::mutator_lock_);
Mathieu Chartierc77f3ab2015-09-03 19:41:50 -07001137 bool WaitForInitializeClass(Handle<mirror::Class> klass,
1138 Thread* self,
Igor Murashkinb1d8c312015-08-04 11:18:43 -07001139 ObjectLock<mirror::Class>& lock);
Carl Shapiro0e5d75d2011-07-06 18:28:37 -07001140
Mathieu Chartierc77f3ab2015-09-03 19:41:50 -07001141 bool IsSameDescriptorInDifferentClassContexts(Thread* self,
1142 const char* descriptor,
Andreas Gampe5a4b8a22014-09-11 08:30:08 -07001143 Handle<mirror::ClassLoader> class_loader1,
1144 Handle<mirror::ClassLoader> class_loader2)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -07001145 REQUIRES_SHARED(Locks::mutator_lock_);
Carl Shapiro0e5d75d2011-07-06 18:28:37 -07001146
Mathieu Chartierc77f3ab2015-09-03 19:41:50 -07001147 bool IsSameMethodSignatureInDifferentClassContexts(Thread* self,
1148 ArtMethod* method,
Mathieu Chartier28357fa2016-10-18 16:27:40 -07001149 ObjPtr<mirror::Class> klass1,
1150 ObjPtr<mirror::Class> klass2)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -07001151 REQUIRES_SHARED(Locks::mutator_lock_);
Carl Shapiro0e5d75d2011-07-06 18:28:37 -07001152
Andreas Gampe5a4b8a22014-09-11 08:30:08 -07001153 bool LinkSuperClass(Handle<mirror::Class> klass)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -07001154 REQUIRES_SHARED(Locks::mutator_lock_);
Carl Shapiro0e5d75d2011-07-06 18:28:37 -07001155
Andreas Gampe5a4b8a22014-09-11 08:30:08 -07001156 bool LoadSuperAndInterfaces(Handle<mirror::Class> klass, const DexFile& dex_file)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -07001157 REQUIRES_SHARED(Locks::mutator_lock_)
Andreas Gampecc1b5352016-12-01 16:58:38 -08001158 REQUIRES(!Locks::dex_lock_);
Carl Shapiro0e5d75d2011-07-06 18:28:37 -07001159
Mathieu Chartiercc5ebdf2015-07-27 11:19:43 -07001160 bool LinkMethods(Thread* self,
1161 Handle<mirror::Class> klass,
Mathieu Chartier2d2621a2014-10-23 16:48:06 -07001162 Handle<mirror::ObjectArray<mirror::Class>> interfaces,
Artem Udovichenkoa62cb9b2016-06-30 09:18:25 +00001163 bool* out_new_conflict,
Igor Murashkinb1d8c312015-08-04 11:18:43 -07001164 ArtMethod** out_imt)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -07001165 REQUIRES_SHARED(Locks::mutator_lock_);
Carl Shapiro0e5d75d2011-07-06 18:28:37 -07001166
Vladimir Marko5aead702019-03-27 11:00:36 +00001167 ObjPtr<mirror::MethodHandle> ResolveMethodHandleForField(
1168 Thread* self,
1169 const dex::MethodHandleItem& method_handle,
1170 ArtMethod* referrer) REQUIRES_SHARED(Locks::mutator_lock_);
Orion Hodsonf8db2c32017-07-07 20:07:12 +01001171
Vladimir Marko5aead702019-03-27 11:00:36 +00001172 ObjPtr<mirror::MethodHandle> ResolveMethodHandleForMethod(
1173 Thread* self,
1174 const dex::MethodHandleItem& method_handle,
1175 ArtMethod* referrer) REQUIRES_SHARED(Locks::mutator_lock_);
Orion Hodsonf8db2c32017-07-07 20:07:12 +01001176
Alex Lighteb7c1442015-08-31 13:17:42 -07001177 // Sets up the interface lookup table (IFTable) in the correct order to allow searching for
1178 // default methods.
1179 bool SetupInterfaceLookupTable(Thread* self,
1180 Handle<mirror::Class> klass,
1181 Handle<mirror::ObjectArray<mirror::Class>> interfaces)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -07001182 REQUIRES_SHARED(Locks::mutator_lock_);
Alex Lighteb7c1442015-08-31 13:17:42 -07001183
Alex Light9139e002015-10-09 15:59:48 -07001184
1185 enum class DefaultMethodSearchResult {
1186 kDefaultFound,
1187 kAbstractFound,
1188 kDefaultConflict
1189 };
1190
Alex Lighteb7c1442015-08-31 13:17:42 -07001191 // Find the default method implementation for 'interface_method' in 'klass', if one exists.
1192 //
1193 // Arguments:
1194 // * self - The current thread.
1195 // * target_method - The method we are trying to find a default implementation for.
1196 // * klass - The class we are searching for a definition of target_method.
1197 // * out_default_method - The pointer we will store the found default method to on success.
Alex Lighteb7c1442015-08-31 13:17:42 -07001198 //
1199 // Return value:
Alex Light9139e002015-10-09 15:59:48 -07001200 // * kDefaultFound - There were no conflicting method implementations found in the class while
1201 // searching for target_method. The default method implementation is stored into
1202 // out_default_method.
1203 // * kAbstractFound - There were no conflicting method implementations found in the class while
1204 // searching for target_method but no default implementation was found either.
1205 // out_default_method is set to null and the method should be considered not
1206 // implemented.
1207 // * kDefaultConflict - Conflicting method implementations were found when searching for
1208 // target_method. The value of *out_default_method is null.
1209 DefaultMethodSearchResult FindDefaultMethodImplementation(
Artem Udovichenkoa62cb9b2016-06-30 09:18:25 +00001210 Thread* self,
1211 ArtMethod* target_method,
1212 Handle<mirror::Class> klass,
1213 /*out*/ArtMethod** out_default_method) const
Andreas Gampebdf7f1c2016-08-30 16:38:47 -07001214 REQUIRES_SHARED(Locks::mutator_lock_);
Alex Lighteb7c1442015-08-31 13:17:42 -07001215
Igor Murashkinb1d8c312015-08-04 11:18:43 -07001216 bool LinkStaticFields(Thread* self, Handle<mirror::Class> klass, size_t* class_size)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -07001217 REQUIRES_SHARED(Locks::mutator_lock_);
Andreas Gampe5a4b8a22014-09-11 08:30:08 -07001218 bool LinkInstanceFields(Thread* self, Handle<mirror::Class> klass)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -07001219 REQUIRES_SHARED(Locks::mutator_lock_);
Andreas Gampe5a4b8a22014-09-11 08:30:08 -07001220 void CreateReferenceInstanceOffsets(Handle<mirror::Class> klass)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -07001221 REQUIRES_SHARED(Locks::mutator_lock_);
Carl Shapiro0e5d75d2011-07-06 18:28:37 -07001222
Mathieu Chartiere401d142015-04-22 13:56:20 -07001223 void CheckProxyConstructor(ArtMethod* constructor) const
Andreas Gampebdf7f1c2016-08-30 16:38:47 -07001224 REQUIRES_SHARED(Locks::mutator_lock_);
Mathieu Chartiere401d142015-04-22 13:56:20 -07001225 void CheckProxyMethod(ArtMethod* method, ArtMethod* prototype) const
Andreas Gampebdf7f1c2016-08-30 16:38:47 -07001226 REQUIRES_SHARED(Locks::mutator_lock_);
Mathieu Chartiere401d142015-04-22 13:56:20 -07001227
Andreas Gampecc1b5352016-12-01 16:58:38 -08001228 size_t GetDexCacheCount() REQUIRES_SHARED(Locks::mutator_lock_, Locks::dex_lock_) {
Hiroshi Yamauchie9e3e692014-06-24 14:31:37 -07001229 return dex_caches_.size();
1230 }
David Srbecky6fbcc292021-02-23 01:05:32 +00001231 const std::unordered_map<const DexFile*, DexCacheData>& GetDexCachesData()
Andreas Gampecc1b5352016-12-01 16:58:38 -08001232 REQUIRES_SHARED(Locks::mutator_lock_, Locks::dex_lock_) {
Mathieu Chartier673ed3d2015-08-28 14:56:43 -07001233 return dex_caches_;
1234 }
Brian Carlstrom58ae9412011-10-04 00:56:06 -07001235
Mathieu Chartiere401d142015-04-22 13:56:20 -07001236 void CreateProxyConstructor(Handle<mirror::Class> klass, ArtMethod* out)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -07001237 REQUIRES_SHARED(Locks::mutator_lock_);
Mathieu Chartiere401d142015-04-22 13:56:20 -07001238 void CreateProxyMethod(Handle<mirror::Class> klass, ArtMethod* prototype, ArtMethod* out)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -07001239 REQUIRES_SHARED(Locks::mutator_lock_);
Jesse Wilson95caa792011-10-12 18:14:17 -04001240
Mathieu Chartier5b830502016-03-02 10:30:23 -08001241 // Register a class loader and create its class table and allocator. Should not be called if
1242 // these are already created.
Mathieu Chartier28357fa2016-10-18 16:27:40 -07001243 void RegisterClassLoader(ObjPtr<mirror::ClassLoader> class_loader)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -07001244 REQUIRES_SHARED(Locks::mutator_lock_)
Mathieu Chartier5b830502016-03-02 10:30:23 -08001245 REQUIRES(Locks::classlinker_classes_lock_);
1246
Nicolas Geoffray3a090922015-11-24 09:17:30 +00001247 // Insert a new class table if not found.
Mathieu Chartier28357fa2016-10-18 16:27:40 -07001248 ClassTable* InsertClassTableForClassLoader(ObjPtr<mirror::ClassLoader> class_loader)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -07001249 REQUIRES_SHARED(Locks::mutator_lock_)
Mathieu Chartierc77f3ab2015-09-03 19:41:50 -07001250 REQUIRES(Locks::classlinker_classes_lock_);
Mathieu Chartiercc5ebdf2015-07-27 11:19:43 -07001251
Ian Rogersdbf3be02014-08-29 15:40:08 -07001252 // EnsureResolved is called to make sure that a class in the class_table_ has been resolved
1253 // before returning it to the caller. Its the responsibility of the thread that placed the class
1254 // in the table to make it resolved. The thread doing resolution must notify on the class' lock
1255 // when resolution has occurred. This happens in mirror::Class::SetStatus. As resolution may
1256 // retire a class, the version of the class in the table is returned and this may differ from
1257 // the class passed in.
Vladimir Markoa8bba7d2018-05-30 15:18:48 +01001258 ObjPtr<mirror::Class> EnsureResolved(Thread* self,
1259 const char* descriptor,
1260 ObjPtr<mirror::Class> klass)
Mathieu Chartierc77f3ab2015-09-03 19:41:50 -07001261 WARN_UNUSED
Andreas Gampebdf7f1c2016-08-30 16:38:47 -07001262 REQUIRES_SHARED(Locks::mutator_lock_)
Andreas Gampecc1b5352016-12-01 16:58:38 -08001263 REQUIRES(!Locks::dex_lock_);
Ian Rogersdbf3be02014-08-29 15:40:08 -07001264
Mathieu Chartier28357fa2016-10-18 16:27:40 -07001265 void FixupTemporaryDeclaringClass(ObjPtr<mirror::Class> temp_class,
1266 ObjPtr<mirror::Class> new_class)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -07001267 REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogersdbf3be02014-08-29 15:40:08 -07001268
Mathieu Chartier28357fa2016-10-18 16:27:40 -07001269 void SetClassRoot(ClassRoot class_root, ObjPtr<mirror::Class> klass)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -07001270 REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogers6f3dbba2014-10-14 17:41:57 -07001271
1272 // Return the quick generic JNI stub for testing.
1273 const void* GetRuntimeQuickGenericJniStub() const;
1274
Mathieu Chartier28357fa2016-10-18 16:27:40 -07001275 bool CanWeInitializeClass(ObjPtr<mirror::Class> klass,
1276 bool can_init_statics,
1277 bool can_init_parents)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -07001278 REQUIRES_SHARED(Locks::mutator_lock_);
Mathieu Chartiere401d142015-04-22 13:56:20 -07001279
Mathieu Chartier28357fa2016-10-18 16:27:40 -07001280 void UpdateClassMethods(ObjPtr<mirror::Class> klass,
Alex Lighte64300b2015-12-15 15:02:47 -08001281 LengthPrefixedArray<ArtMethod>* new_methods)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -07001282 REQUIRES_SHARED(Locks::mutator_lock_)
Mathieu Chartier54d220e2015-07-30 16:20:06 -07001283 REQUIRES(!Locks::classlinker_classes_lock_);
Mathieu Chartiere401d142015-04-22 13:56:20 -07001284
Andreas Gampe7ba5a672016-02-04 21:45:01 -08001285 // Check that c1 == FindSystemClass(self, descriptor). Abort with class dumps otherwise.
1286 void CheckSystemClass(Thread* self, Handle<mirror::Class> c1, const char* descriptor)
Andreas Gampecc1b5352016-12-01 16:58:38 -08001287 REQUIRES(!Locks::dex_lock_)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -07001288 REQUIRES_SHARED(Locks::mutator_lock_);
Andreas Gampe7ba5a672016-02-04 21:45:01 -08001289
Vladimir Marko921094a2017-01-12 18:37:06 +00001290 // Allocate method arrays for interfaces.
1291 bool AllocateIfTableMethodArrays(Thread* self,
1292 Handle<mirror::Class> klass,
1293 Handle<mirror::IfTable> iftable)
1294 REQUIRES_SHARED(Locks::mutator_lock_);
1295
Mathieu Chartier7f98c9a2016-04-14 10:49:19 -07001296 // Sets imt_ref appropriately for LinkInterfaceMethods.
1297 // If there is no method in the imt location of imt_ref it will store the given method there.
1298 // Otherwise it will set the conflict method which will figure out which method to use during
1299 // runtime.
1300 void SetIMTRef(ArtMethod* unimplemented_method,
1301 ArtMethod* imt_conflict_method,
1302 ArtMethod* current_method,
Artem Udovichenkoa62cb9b2016-06-30 09:18:25 +00001303 /*out*/bool* new_conflict,
Andreas Gampebdf7f1c2016-08-30 16:38:47 -07001304 /*out*/ArtMethod** imt_ref) REQUIRES_SHARED(Locks::mutator_lock_);
Mathieu Chartier7f98c9a2016-04-14 10:49:19 -07001305
Mathieu Chartier28357fa2016-10-18 16:27:40 -07001306 void FillIMTFromIfTable(ObjPtr<mirror::IfTable> if_table,
Mathieu Chartiere42888f2016-04-14 10:49:19 -07001307 ArtMethod* unimplemented_method,
1308 ArtMethod* imt_conflict_method,
Mathieu Chartier28357fa2016-10-18 16:27:40 -07001309 ObjPtr<mirror::Class> klass,
Mathieu Chartiere42888f2016-04-14 10:49:19 -07001310 bool create_conflict_tables,
1311 bool ignore_copied_methods,
Artem Udovichenkoa62cb9b2016-06-30 09:18:25 +00001312 /*out*/bool* new_conflict,
Andreas Gampebdf7f1c2016-08-30 16:38:47 -07001313 /*out*/ArtMethod** imt) REQUIRES_SHARED(Locks::mutator_lock_);
Mathieu Chartier7f98c9a2016-04-14 10:49:19 -07001314
1315 void FillImtFromSuperClass(Handle<mirror::Class> klass,
1316 ArtMethod* unimplemented_method,
1317 ArtMethod* imt_conflict_method,
Artem Udovichenkoa62cb9b2016-06-30 09:18:25 +00001318 bool* new_conflict,
Andreas Gampebdf7f1c2016-08-30 16:38:47 -07001319 ArtMethod** imt) REQUIRES_SHARED(Locks::mutator_lock_);
Mathieu Chartier7f98c9a2016-04-14 10:49:19 -07001320
Vladimir Markoba118822017-06-12 15:41:56 +01001321 // Check invoke type against the referenced class. Throws IncompatibleClassChangeError
1322 // (if `kThrowOnError`) and returns true on mismatch (kInterface on a non-interface class,
1323 // kVirtual on interface, kDefault on interface for dex files not supporting default methods),
1324 // otherwise returns false.
1325 template <bool kThrowOnError, typename ClassGetter>
1326 static bool CheckInvokeClassMismatch(ObjPtr<mirror::DexCache> dex_cache,
1327 InvokeType type,
1328 ClassGetter class_getter)
1329 REQUIRES_SHARED(Locks::mutator_lock_);
1330 // Helper that feeds the above function with `ClassGetter` doing `LookupResolvedType()`.
1331 template <bool kThrow>
1332 bool CheckInvokeClassMismatch(ObjPtr<mirror::DexCache> dex_cache,
1333 InvokeType type,
1334 uint32_t method_idx,
1335 ObjPtr<mirror::ClassLoader> class_loader)
1336 REQUIRES_SHARED(Locks::mutator_lock_);
1337
Vladimir Marko02610552018-06-04 14:38:00 +01001338 ObjPtr<mirror::IfTable> GetArrayIfTable() REQUIRES_SHARED(Locks::mutator_lock_);
1339
Brian Carlstrom4a96b602011-07-26 16:40:23 -07001340 std::vector<const DexFile*> boot_class_path_;
Mathieu Chartierfbc31082016-01-24 11:59:56 -08001341 std::vector<std::unique_ptr<const DexFile>> boot_dex_files_;
Brian Carlstrom578bbdc2011-07-21 14:07:47 -07001342
Hiroshi Yamauchi04302db2015-11-11 23:45:34 -08001343 // JNI weak globals and side data to allow dex caches to get unloaded. We lazily delete weak
1344 // globals when we register new dex files.
David Srbecky6fbcc292021-02-23 01:05:32 +00001345 std::unordered_map<const DexFile*, DexCacheData> dex_caches_ GUARDED_BY(Locks::dex_lock_);
Brian Carlstrom47d237a2011-10-18 15:08:33 -07001346
Mathieu Chartier9b1c71e2015-09-02 18:51:54 -07001347 // This contains the class loaders which have class tables. It is populated by
Mathieu Chartier951ec2c2015-09-22 08:50:05 -07001348 // InsertClassTableForClassLoader.
1349 std::list<ClassLoaderData> class_loaders_
Mathieu Chartier6b069532015-08-05 15:08:12 -07001350 GUARDED_BY(Locks::classlinker_classes_lock_);
1351
1352 // Boot class path table. Since the class loader for this is null.
Andreas Gampe2af99022017-04-25 08:32:59 -07001353 std::unique_ptr<ClassTable> boot_class_table_ GUARDED_BY(Locks::classlinker_classes_lock_);
Carl Shapiro0e5d75d2011-07-06 18:28:37 -07001354
Mathieu Chartiercc5ebdf2015-07-27 11:19:43 -07001355 // New class roots, only used by CMS since the GC needs to mark these in the pause.
1356 std::vector<GcRoot<mirror::Class>> new_class_roots_ GUARDED_BY(Locks::classlinker_classes_lock_);
Elliott Hughesf8349362012-06-18 15:00:06 -07001357
Vladimir Marko1998cd02017-01-13 13:02:58 +00001358 // Boot image oat files with new .bss GC roots to be visited in the pause by CMS.
1359 std::vector<const OatFile*> new_bss_roots_boot_oat_files_
1360 GUARDED_BY(Locks::classlinker_classes_lock_);
1361
Ian Rogers7dfb28c2013-08-22 08:18:36 -07001362 // Number of times we've searched dex caches for a class. After a certain number of misses we move
1363 // the classes into the class_table_ to avoid dex cache based searches.
Ian Rogers68b56852014-08-29 20:19:11 -07001364 Atomic<uint32_t> failed_dex_cache_class_lookups_;
Ian Rogers7dfb28c2013-08-22 08:18:36 -07001365
Ian Rogers6f3dbba2014-10-14 17:41:57 -07001366 // Well known mirror::Class roots.
Hiroshi Yamauchi94f7b492014-07-22 18:08:23 -07001367 GcRoot<mirror::ObjectArray<mirror::Class>> class_roots_;
Brian Carlstrom913af1b2011-07-23 21:41:13 -07001368
Vladimir Marko43354742021-02-03 15:37:01 +00001369 // Method hashes for virtual methods from java.lang.Object used
1370 // to avoid recalculating them for each class we link.
1371 uint32_t object_virtual_method_hashes_[mirror::Object::kVTableLength];
1372
Ian Rogers98379392014-02-24 16:53:16 -08001373 // A cache of the last FindArrayClass results. The cache serves to avoid creating array class
1374 // descriptors for the sake of performing FindClass.
1375 static constexpr size_t kFindArrayCacheSize = 16;
Hiroshi Yamauchi94f7b492014-07-22 18:08:23 -07001376 GcRoot<mirror::Class> find_array_class_cache_[kFindArrayCacheSize];
Ian Rogers98379392014-02-24 16:53:16 -08001377 size_t find_array_class_cache_next_victim_;
1378
Brian Carlstrom75cb3b42011-07-28 02:13:36 -07001379 bool init_done_;
Vladimir Marko1998cd02017-01-13 13:02:58 +00001380 bool log_new_roots_ GUARDED_BY(Locks::classlinker_classes_lock_);
Brian Carlstrom75cb3b42011-07-28 02:13:36 -07001381
Elliott Hughescf4c6c42011-09-01 15:16:42 -07001382 InternTable* intern_table_;
1383
Andreas Gampe87658f32019-04-18 18:39:02 +00001384 const bool fast_class_not_found_exceptions_;
1385
Mingyao Yang98d1cc82014-05-15 17:02:16 -07001386 // Trampolines within the image the bounce to runtime entrypoints. Done so that there is a single
1387 // patch point within the image. TODO: make these proper relocations.
Vladimir Marko7dac8642019-11-06 17:09:30 +00001388 const void* jni_dlsym_lookup_trampoline_;
Vladimir Markofa458ac2020-02-12 14:08:07 +00001389 const void* jni_dlsym_lookup_critical_trampoline_;
Jeff Hao0aba0ba2013-06-03 14:49:28 -07001390 const void* quick_resolution_trampoline_;
Jeff Hao88474b42013-10-23 16:24:40 -07001391 const void* quick_imt_conflict_trampoline_;
Andreas Gampe2da88232014-02-27 12:26:20 -08001392 const void* quick_generic_jni_trampoline_;
Vladimir Marko8a630572014-04-09 18:45:35 +01001393 const void* quick_to_interpreter_bridge_trampoline_;
Nicolas Geoffrayc39af942021-01-25 08:43:57 +00001394 const void* nterp_trampoline_;
Jeff Hao0aba0ba2013-06-03 14:49:28 -07001395
Mathieu Chartier2d721012014-11-10 11:08:06 -08001396 // Image pointer size.
Andreas Gampe542451c2016-07-26 09:02:02 -07001397 PointerSize image_pointer_size_;
Mathieu Chartier2d721012014-11-10 11:08:06 -08001398
Vladimir Markobf121912019-06-04 13:49:05 +01001399 // Classes to transition from ClassStatus::kInitialized to ClassStatus::kVisiblyInitialized.
1400 Mutex visibly_initialized_callback_lock_;
1401 std::unique_ptr<VisiblyInitializedCallback> visibly_initialized_callback_
1402 GUARDED_BY(visibly_initialized_callback_lock_);
1403 IntrusiveForwardList<VisiblyInitializedCallback> running_visibly_initialized_callbacks_
1404 GUARDED_BY(visibly_initialized_callback_lock_);
1405
Vladimir Marko86c87522020-05-11 16:55:55 +01001406 // Registered native code for @CriticalNative methods of classes that are not visibly
1407 // initialized. These code pointers cannot be stored in ArtMethod as that would risk
1408 // skipping the class initialization check for direct calls from compiled code.
1409 Mutex critical_native_code_with_clinit_check_lock_;
1410 std::map<ArtMethod*, void*> critical_native_code_with_clinit_check_
1411 GUARDED_BY(critical_native_code_with_clinit_check_lock_);
1412
Andreas Gampec1ac9ee2017-07-24 22:35:49 -07001413 std::unique_ptr<ClassHierarchyAnalysis> cha_;
1414
Mathieu Chartier65975772016-08-05 10:46:36 -07001415 class FindVirtualMethodHolderVisitor;
Andreas Gampe2af99022017-04-25 08:32:59 -07001416
Mathieu Chartier74ccee62018-10-10 10:30:29 -07001417 friend class AppImageLoadingHelper;
Mathieu Chartierf9c6fc62015-10-07 11:44:05 -07001418 friend class ImageDumper; // for DexLock
Vladimir Marko74527972016-11-29 15:57:32 +00001419 friend struct linker::CompilationHelper; // For Compile in ImageTest.
1420 friend class linker::ImageWriter; // for GetClassRoots
Ian Rogers6f3dbba2014-10-14 17:41:57 -07001421 friend class JniCompilerTest; // for GetRuntimeQuickGenericJniStub
Andreas Gampe5f4a09a2015-09-28 13:16:33 -07001422 friend class JniInternalTest; // for GetRuntimeQuickGenericJniStub
Andreas Gampe2af99022017-04-25 08:32:59 -07001423 friend class VMClassLoader; // for LookupClass and FindClassInBaseDexClassLoader.
Mathieu Chartier76172162016-01-26 14:54:06 -08001424 ART_FRIEND_TEST(ClassLinkerTest, RegisterDexFileName); // for DexLock, and RegisterDexFileLocked
Narayan Kamath25352fc2016-08-03 12:46:58 +01001425 ART_FRIEND_TEST(mirror::DexCacheMethodHandlesTest, Open); // for AllocDexCache
Ian Rogers6f3dbba2014-10-14 17:41:57 -07001426 ART_FRIEND_TEST(mirror::DexCacheTest, Open); // for AllocDexCache
Carl Shapiro0e5d75d2011-07-06 18:28:37 -07001427 DISALLOW_COPY_AND_ASSIGN(ClassLinker);
1428};
1429
Andreas Gampe0f01b582017-01-18 15:22:37 -08001430class ClassLoadCallback {
1431 public:
1432 virtual ~ClassLoadCallback() {}
1433
Alex Light270db1c2019-12-03 12:20:01 +00001434 // Called immediately before beginning class-definition and immediately before returning from it.
1435 virtual void BeginDefineClass() REQUIRES_SHARED(Locks::mutator_lock_) {}
1436 virtual void EndDefineClass() REQUIRES_SHARED(Locks::mutator_lock_) {}
1437
Alex Lightb0f11922017-01-23 14:25:17 -08001438 // If set we will replace initial_class_def & initial_dex_file with the final versions. The
1439 // callback author is responsible for ensuring these are allocated in such a way they can be
1440 // cleaned up if another transformation occurs. Note that both must be set or null/unchanged on
1441 // return.
1442 // Note: the class may be temporary, in which case a following ClassPrepare event will be a
1443 // different object. It is the listener's responsibility to handle this.
1444 // Note: This callback is rarely useful so a default implementation has been given that does
1445 // nothing.
1446 virtual void ClassPreDefine(const char* descriptor ATTRIBUTE_UNUSED,
1447 Handle<mirror::Class> klass ATTRIBUTE_UNUSED,
1448 Handle<mirror::ClassLoader> class_loader ATTRIBUTE_UNUSED,
1449 const DexFile& initial_dex_file ATTRIBUTE_UNUSED,
Andreas Gampe3f1dcd32018-12-28 09:39:56 -08001450 const dex::ClassDef& initial_class_def ATTRIBUTE_UNUSED,
Alex Lightb0f11922017-01-23 14:25:17 -08001451 /*out*/DexFile const** final_dex_file ATTRIBUTE_UNUSED,
Andreas Gampe3f1dcd32018-12-28 09:39:56 -08001452 /*out*/dex::ClassDef const** final_class_def ATTRIBUTE_UNUSED)
Alex Lightb0f11922017-01-23 14:25:17 -08001453 REQUIRES_SHARED(Locks::mutator_lock_) {}
1454
Andreas Gampe0f01b582017-01-18 15:22:37 -08001455 // A class has been loaded.
1456 // Note: the class may be temporary, in which case a following ClassPrepare event will be a
1457 // different object. It is the listener's responsibility to handle this.
1458 virtual void ClassLoad(Handle<mirror::Class> klass) REQUIRES_SHARED(Locks::mutator_lock_) = 0;
1459
1460 // A class has been prepared, i.e., resolved. As the ClassLoad event might have been for a
1461 // temporary class, provide both the former and the current class.
1462 virtual void ClassPrepare(Handle<mirror::Class> temp_klass,
1463 Handle<mirror::Class> klass) REQUIRES_SHARED(Locks::mutator_lock_) = 0;
1464};
1465
Carl Shapiro0e5d75d2011-07-06 18:28:37 -07001466} // namespace art
1467
Brian Carlstromfc0e3212013-07-17 14:40:12 -07001468#endif // ART_RUNTIME_CLASS_LINKER_H_