Elliott Hughes | 418d20f | 2011-09-22 14:00:39 -0700 | [diff] [blame] | 1 | /* |
| 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 Shapiro | 0e5d75d | 2011-07-06 18:28:37 -0700 | [diff] [blame] | 16 | |
| 17 | #ifndef ART_SRC_CLASS_LINKER_H_ |
| 18 | #define ART_SRC_CLASS_LINKER_H_ |
| 19 | |
| 20 | #include <map> |
Ian Rogers | 6d4d9fc | 2011-11-30 16:24:48 -0800 | [diff] [blame] | 21 | #include <string> |
Carl Shapiro | 0e5d75d | 2011-07-06 18:28:37 -0700 | [diff] [blame] | 22 | #include <utility> |
| 23 | #include <vector> |
| 24 | |
Ian Rogers | caab8c4 | 2011-10-12 12:11:18 -0700 | [diff] [blame] | 25 | #include "dex_cache.h" |
Brian Carlstrom | 7e49dca | 2011-07-22 18:07:34 -0700 | [diff] [blame] | 26 | #include "dex_file.h" |
Brian Carlstrom | 7e93b50 | 2011-08-04 14:16:22 -0700 | [diff] [blame] | 27 | #include "heap.h" |
Brian Carlstrom | 7e93b50 | 2011-08-04 14:16:22 -0700 | [diff] [blame] | 28 | #include "macros.h" |
Elliott Hughes | 8daa092 | 2011-09-11 13:46:25 -0700 | [diff] [blame] | 29 | #include "mutex.h" |
Brian Carlstrom | 58ae941 | 2011-10-04 00:56:06 -0700 | [diff] [blame] | 30 | #include "oat_file.h" |
Brian Carlstrom | 578bbdc | 2011-07-21 14:07:47 -0700 | [diff] [blame] | 31 | #include "object.h" |
Brian Carlstrom | 40381fb | 2011-10-19 14:13:40 -0700 | [diff] [blame] | 32 | #include "stack_indirect_reference_table.h" |
Brian Carlstrom | 7e93b50 | 2011-08-04 14:16:22 -0700 | [diff] [blame] | 33 | #include "unordered_map.h" |
Brian Carlstrom | a663ea5 | 2011-08-19 23:33:41 -0700 | [diff] [blame] | 34 | #include "unordered_set.h" |
Brian Carlstrom | 7e93b50 | 2011-08-04 14:16:22 -0700 | [diff] [blame] | 35 | |
Brian Carlstrom | 578bbdc | 2011-07-21 14:07:47 -0700 | [diff] [blame] | 36 | #include "gtest/gtest.h" |
Carl Shapiro | 0e5d75d | 2011-07-06 18:28:37 -0700 | [diff] [blame] | 37 | |
| 38 | namespace art { |
| 39 | |
Elliott Hughes | cf4c6c4 | 2011-09-01 15:16:42 -0700 | [diff] [blame] | 40 | class ClassLoader; |
| 41 | class InternTable; |
Brian Carlstrom | d1422f8 | 2011-09-28 11:37:09 -0700 | [diff] [blame] | 42 | class ObjectLock; |
Elliott Hughes | cf4c6c4 | 2011-09-01 15:16:42 -0700 | [diff] [blame] | 43 | |
Elliott Hughes | a215526 | 2011-11-16 16:26:58 -0800 | [diff] [blame] | 44 | typedef bool (ClassVisitor)(Class* c, void* arg); |
| 45 | |
Carl Shapiro | 0e5d75d | 2011-07-06 18:28:37 -0700 | [diff] [blame] | 46 | class ClassLinker { |
| 47 | public: |
Brian Carlstrom | 58ae941 | 2011-10-04 00:56:06 -0700 | [diff] [blame] | 48 | // Creates the class linker by boot strapping from dex files. |
Elliott Hughes | 4dd9b4d | 2011-12-12 18:29:24 -0800 | [diff] [blame] | 49 | static ClassLinker* Create(const std::string& boot_class_path, InternTable* intern_table); |
Brian Carlstrom | 58ae941 | 2011-10-04 00:56:06 -0700 | [diff] [blame] | 50 | |
| 51 | // Creates the class linker from one or more images. |
Elliott Hughes | 4dd9b4d | 2011-12-12 18:29:24 -0800 | [diff] [blame] | 52 | static ClassLinker* Create(InternTable* intern_table); |
Carl Shapiro | 61e019d | 2011-07-14 16:53:09 -0700 | [diff] [blame] | 53 | |
Brian Carlstrom | 9ea1cb1 | 2011-08-24 23:18:18 -0700 | [diff] [blame] | 54 | ~ClassLinker(); |
Carl Shapiro | 565f507 | 2011-07-10 13:39:43 -0700 | [diff] [blame] | 55 | |
Elliott Hughes | 64bf5a3 | 2011-09-20 14:43:12 -0700 | [diff] [blame] | 56 | // Finds a class by its descriptor, loading it if necessary. |
Brian Carlstrom | 74eb46a | 2011-08-02 20:10:14 -0700 | [diff] [blame] | 57 | // If class_loader is null, searches boot_class_path_. |
Elliott Hughes | c3b77c7 | 2011-12-15 20:56:48 -0800 | [diff] [blame] | 58 | Class* FindClass(const char* descriptor, const ClassLoader* class_loader); |
Brian Carlstrom | aded5f7 | 2011-10-07 17:15:04 -0700 | [diff] [blame] | 59 | |
Elliott Hughes | db7d5e9 | 2011-12-16 18:47:37 -0800 | [diff] [blame] | 60 | Class* FindSystemClass(const char* descriptor); |
Brian Carlstrom | aded5f7 | 2011-10-07 17:15:04 -0700 | [diff] [blame] | 61 | |
| 62 | // Define a new a class based on a ClassDef from a DexFile |
Elliott Hughes | c3b77c7 | 2011-12-15 20:56:48 -0800 | [diff] [blame] | 63 | Class* DefineClass(const StringPiece& descriptor, const ClassLoader* class_loader, |
Brian Carlstrom | aded5f7 | 2011-10-07 17:15:04 -0700 | [diff] [blame] | 64 | const DexFile& dex_file, const DexFile::ClassDef& dex_class_def); |
Elliott Hughes | 64bf5a3 | 2011-09-20 14:43:12 -0700 | [diff] [blame] | 65 | |
| 66 | // Finds a class by its descriptor, returning NULL if it isn't wasn't loaded |
| 67 | // by the given 'class_loader'. |
Elliott Hughes | c3b77c7 | 2011-12-15 20:56:48 -0800 | [diff] [blame] | 68 | Class* LookupClass(const char* descriptor, const ClassLoader* class_loader); |
Carl Shapiro | 0e5d75d | 2011-07-06 18:28:37 -0700 | [diff] [blame] | 69 | |
Elliott Hughes | 6fa602d | 2011-12-02 17:54:25 -0800 | [diff] [blame] | 70 | // Finds all the classes with the given descriptor, regardless of ClassLoader. |
Elliott Hughes | c3b77c7 | 2011-12-15 20:56:48 -0800 | [diff] [blame] | 71 | void LookupClasses(const char* descriptor, std::vector<Class*>& classes); |
Elliott Hughes | 6fa602d | 2011-12-02 17:54:25 -0800 | [diff] [blame] | 72 | |
Elliott Hughes | d8ddfd5 | 2011-08-15 14:32:53 -0700 | [diff] [blame] | 73 | Class* FindPrimitiveClass(char type); |
| 74 | |
Brian Carlstrom | ae82698 | 2011-11-09 01:33:42 -0800 | [diff] [blame] | 75 | // General class unloading is not supported, this is used to prune |
| 76 | // unwanted classes during image writing. |
Elliott Hughes | c3b77c7 | 2011-12-15 20:56:48 -0800 | [diff] [blame] | 77 | bool RemoveClass(const char* descriptor, const ClassLoader* class_loader); |
Brian Carlstrom | ae82698 | 2011-11-09 01:33:42 -0800 | [diff] [blame] | 78 | |
Elliott Hughes | 9d5ccec | 2011-09-19 13:19:50 -0700 | [diff] [blame] | 79 | void DumpAllClasses(int flags) const; |
| 80 | |
Elliott Hughes | cac6cc7 | 2011-11-03 20:31:21 -0700 | [diff] [blame] | 81 | void DumpForSigQuit(std::ostream& os) const; |
| 82 | |
Elliott Hughes | e27955c | 2011-08-26 15:21:24 -0700 | [diff] [blame] | 83 | size_t NumLoadedClasses() const; |
| 84 | |
Brian Carlstrom | b63ec39 | 2011-08-27 17:38:27 -0700 | [diff] [blame] | 85 | // Resolve a String with the given index from the DexFile, storing the |
Brian Carlstrom | aded5f7 | 2011-10-07 17:15:04 -0700 | [diff] [blame] | 86 | // result in the DexCache. The referrer is used to identify the |
| 87 | // target DexCache and ClassLoader to use for resolution. |
| 88 | String* ResolveString(uint32_t string_idx, const Method* referrer) { |
Ian Rogers | caab8c4 | 2011-10-12 12:11:18 -0700 | [diff] [blame] | 89 | String* resolved_string = referrer->GetDexCacheStrings()->Get(string_idx); |
| 90 | if (UNLIKELY(resolved_string == NULL)) { |
| 91 | Class* declaring_class = referrer->GetDeclaringClass(); |
| 92 | DexCache* dex_cache = declaring_class->GetDexCache(); |
| 93 | const DexFile& dex_file = FindDexFile(dex_cache); |
| 94 | resolved_string = ResolveString(dex_file, string_idx, dex_cache); |
| 95 | } |
| 96 | return resolved_string; |
Brian Carlstrom | aded5f7 | 2011-10-07 17:15:04 -0700 | [diff] [blame] | 97 | } |
| 98 | |
| 99 | // Resolve a String with the given index from the DexFile, storing the |
Brian Carlstrom | 9ea1cb1 | 2011-08-24 23:18:18 -0700 | [diff] [blame] | 100 | // result in the DexCache. |
Ian Rogers | 0cfe1fb | 2011-08-26 03:29:44 -0700 | [diff] [blame] | 101 | String* ResolveString(const DexFile& dex_file, uint32_t string_idx, DexCache* dex_cache); |
Brian Carlstrom | 9ea1cb1 | 2011-08-24 23:18:18 -0700 | [diff] [blame] | 102 | |
Brian Carlstrom | b63ec39 | 2011-08-27 17:38:27 -0700 | [diff] [blame] | 103 | // Resolve a Type with the given index from the DexFile, storing the |
Brian Carlstrom | 9ea1cb1 | 2011-08-24 23:18:18 -0700 | [diff] [blame] | 104 | // result in the DexCache. The referrer is used to identity the |
| 105 | // target DexCache and ClassLoader to use for resolution. |
| 106 | Class* ResolveType(const DexFile& dex_file, |
Ian Rogers | 6d4d9fc | 2011-11-30 16:24:48 -0800 | [diff] [blame] | 107 | uint16_t type_idx, |
Brian Carlstrom | 9ea1cb1 | 2011-08-24 23:18:18 -0700 | [diff] [blame] | 108 | const Class* referrer) { |
| 109 | return ResolveType(dex_file, |
| 110 | type_idx, |
| 111 | referrer->GetDexCache(), |
| 112 | referrer->GetClassLoader()); |
| 113 | } |
| 114 | |
Brian Carlstrom | b63ec39 | 2011-08-27 17:38:27 -0700 | [diff] [blame] | 115 | // Resolve a Type with the given index from the DexFile, storing the |
Ian Rogers | 0cfe1fb | 2011-08-26 03:29:44 -0700 | [diff] [blame] | 116 | // result in the DexCache. The referrer is used to identify the |
Brian Carlstrom | b63ec39 | 2011-08-27 17:38:27 -0700 | [diff] [blame] | 117 | // target DexCache and ClassLoader to use for resolution. |
Ian Rogers | 6d4d9fc | 2011-11-30 16:24:48 -0800 | [diff] [blame] | 118 | Class* ResolveType(uint16_t type_idx, const Method* referrer) { |
Ian Rogers | caab8c4 | 2011-10-12 12:11:18 -0700 | [diff] [blame] | 119 | Class* resolved_type = referrer->GetDexCacheResolvedTypes()->Get(type_idx); |
| 120 | if (UNLIKELY(resolved_type == NULL)) { |
| 121 | Class* declaring_class = referrer->GetDeclaringClass(); |
| 122 | DexCache* dex_cache = declaring_class->GetDexCache(); |
| 123 | const ClassLoader* class_loader = declaring_class->GetClassLoader(); |
| 124 | const DexFile& dex_file = FindDexFile(dex_cache); |
| 125 | resolved_type = ResolveType(dex_file, type_idx, dex_cache, class_loader); |
| 126 | } |
| 127 | return resolved_type; |
Ian Rogers | 0cfe1fb | 2011-08-26 03:29:44 -0700 | [diff] [blame] | 128 | } |
| 129 | |
Ian Rogers | 6d4d9fc | 2011-11-30 16:24:48 -0800 | [diff] [blame] | 130 | Class* ResolveType(uint16_t type_idx, const Field* referrer) { |
Ian Rogers | 0cfe1fb | 2011-08-26 03:29:44 -0700 | [diff] [blame] | 131 | Class* declaring_class = referrer->GetDeclaringClass(); |
| 132 | DexCache* dex_cache = declaring_class->GetDexCache(); |
Ian Rogers | caab8c4 | 2011-10-12 12:11:18 -0700 | [diff] [blame] | 133 | Class* resolved_type = dex_cache->GetResolvedType(type_idx); |
| 134 | if (UNLIKELY(resolved_type == NULL)) { |
| 135 | const ClassLoader* class_loader = declaring_class->GetClassLoader(); |
| 136 | const DexFile& dex_file = FindDexFile(dex_cache); |
| 137 | resolved_type = ResolveType(dex_file, type_idx, dex_cache, class_loader); |
| 138 | } |
| 139 | return resolved_type; |
Brian Carlstrom | b63ec39 | 2011-08-27 17:38:27 -0700 | [diff] [blame] | 140 | } |
| 141 | |
Brian Carlstrom | 9ea1cb1 | 2011-08-24 23:18:18 -0700 | [diff] [blame] | 142 | // Resolve a type with the given ID from the DexFile, storing the |
| 143 | // result in DexCache. The ClassLoader is used to search for the |
| 144 | // type, since it may be referenced from but not contained within |
| 145 | // the given DexFile. |
| 146 | Class* ResolveType(const DexFile& dex_file, |
Ian Rogers | 6d4d9fc | 2011-11-30 16:24:48 -0800 | [diff] [blame] | 147 | uint16_t type_idx, |
Brian Carlstrom | 9ea1cb1 | 2011-08-24 23:18:18 -0700 | [diff] [blame] | 148 | DexCache* dex_cache, |
| 149 | const ClassLoader* class_loader); |
| 150 | |
| 151 | // Resolve a method with a given ID from the DexFile, storing the |
| 152 | // result in DexCache. The ClassLinker and ClassLoader are used as |
| 153 | // in ResolveType. What is unique is the method type argument which |
| 154 | // is used to determine if this method is a direct, static, or |
| 155 | // virtual method. |
| 156 | Method* ResolveMethod(const DexFile& dex_file, |
| 157 | uint32_t method_idx, |
| 158 | DexCache* dex_cache, |
| 159 | const ClassLoader* class_loader, |
Brian Carlstrom | 20cfffa | 2011-08-26 02:31:27 -0700 | [diff] [blame] | 160 | bool is_direct); |
Brian Carlstrom | 9ea1cb1 | 2011-08-24 23:18:18 -0700 | [diff] [blame] | 161 | |
Brian Carlstrom | 1619286 | 2011-09-12 17:50:06 -0700 | [diff] [blame] | 162 | Method* ResolveMethod(uint32_t method_idx, const Method* referrer, bool is_direct) { |
Ian Rogers | caab8c4 | 2011-10-12 12:11:18 -0700 | [diff] [blame] | 163 | Method* resolved_method = referrer->GetDexCacheResolvedMethods()->Get(method_idx); |
| 164 | if (UNLIKELY(resolved_method == NULL)) { |
| 165 | Class* declaring_class = referrer->GetDeclaringClass(); |
| 166 | DexCache* dex_cache = declaring_class->GetDexCache(); |
| 167 | const ClassLoader* class_loader = declaring_class->GetClassLoader(); |
| 168 | const DexFile& dex_file = FindDexFile(dex_cache); |
| 169 | resolved_method = ResolveMethod(dex_file, method_idx, dex_cache, class_loader, is_direct); |
| 170 | } |
| 171 | return resolved_method; |
Brian Carlstrom | 1619286 | 2011-09-12 17:50:06 -0700 | [diff] [blame] | 172 | } |
| 173 | |
Brian Carlstrom | 845490b | 2011-09-19 15:56:53 -0700 | [diff] [blame] | 174 | Field* ResolveField(uint32_t field_idx, const Method* referrer, bool is_static) { |
Ian Rogers | caab8c4 | 2011-10-12 12:11:18 -0700 | [diff] [blame] | 175 | Field* resolved_field = referrer->GetDexCacheResolvedFields()->Get(field_idx); |
| 176 | if (UNLIKELY(resolved_field == NULL)) { |
| 177 | Class* declaring_class = referrer->GetDeclaringClass(); |
| 178 | DexCache* dex_cache = declaring_class->GetDexCache(); |
| 179 | const ClassLoader* class_loader = declaring_class->GetClassLoader(); |
| 180 | const DexFile& dex_file = FindDexFile(dex_cache); |
| 181 | resolved_field = ResolveField(dex_file, field_idx, dex_cache, class_loader, is_static); |
| 182 | } |
| 183 | return resolved_field; |
Brian Carlstrom | b9edb84 | 2011-08-28 16:31:06 -0700 | [diff] [blame] | 184 | } |
| 185 | |
Brian Carlstrom | 1619286 | 2011-09-12 17:50:06 -0700 | [diff] [blame] | 186 | // Resolve a field with a given ID from the DexFile, storing the |
Brian Carlstrom | 9ea1cb1 | 2011-08-24 23:18:18 -0700 | [diff] [blame] | 187 | // result in DexCache. The ClassLinker and ClassLoader are used as |
| 188 | // in ResolveType. What is unique is the is_static argument which is |
| 189 | // used to determine if we are resolving a static or non-static |
| 190 | // field. |
| 191 | Field* ResolveField(const DexFile& dex_file, |
| 192 | uint32_t field_idx, |
| 193 | DexCache* dex_cache, |
| 194 | const ClassLoader* class_loader, |
| 195 | bool is_static); |
| 196 | |
Ian Rogers | b067ac2 | 2011-12-13 18:05:09 -0800 | [diff] [blame] | 197 | Field* ResolveFieldJLS(uint32_t field_idx, const Method* referrer) { |
| 198 | Field* resolved_field = referrer->GetDexCacheResolvedFields()->Get(field_idx); |
| 199 | if (UNLIKELY(resolved_field == NULL)) { |
| 200 | Class* declaring_class = referrer->GetDeclaringClass(); |
| 201 | DexCache* dex_cache = declaring_class->GetDexCache(); |
| 202 | const ClassLoader* class_loader = declaring_class->GetClassLoader(); |
| 203 | const DexFile& dex_file = FindDexFile(dex_cache); |
| 204 | resolved_field = ResolveFieldJLS(dex_file, field_idx, dex_cache, class_loader); |
| 205 | } |
| 206 | return resolved_field; |
| 207 | } |
| 208 | |
| 209 | // Resolve a field with a given ID from the DexFile, storing the |
| 210 | // result in DexCache. The ClassLinker and ClassLoader are used as |
| 211 | // in ResolveType. No is_static argument is provided so that Java |
| 212 | // field resolution semantics are followed. |
| 213 | Field* ResolveFieldJLS(const DexFile& dex_file, |
| 214 | uint32_t field_idx, |
| 215 | DexCache* dex_cache, |
| 216 | const ClassLoader* class_loader); |
| 217 | |
Ian Rogers | ad25ac5 | 2011-10-04 19:13:33 -0700 | [diff] [blame] | 218 | // Get shorty from method index without resolution. Used to do handlerization. |
| 219 | const char* MethodShorty(uint32_t method_idx, Method* referrer); |
| 220 | |
Elliott Hughes | f4c21c9 | 2011-08-19 17:31:31 -0700 | [diff] [blame] | 221 | // Returns true on success, false if there's an exception pending. |
Brian Carlstrom | 25c3325 | 2011-09-18 15:58:35 -0700 | [diff] [blame] | 222 | // can_run_clinit=false allows the compiler to attempt to init a class, |
| 223 | // given the restriction that no <clinit> execution is possible. |
| 224 | bool EnsureInitialized(Class* c, bool can_run_clinit); |
Carl Shapiro | 0e5d75d | 2011-07-06 18:28:37 -0700 | [diff] [blame] | 225 | |
Elliott Hughes | 2a20cfd | 2011-09-23 19:30:41 -0700 | [diff] [blame] | 226 | // Initializes classes that have instances in the image but that have |
| 227 | // <clinit> methods so they could not be initialized by the compiler. |
| 228 | void RunRootClinits(); |
| 229 | |
Brian Carlstrom | 9ea1cb1 | 2011-08-24 23:18:18 -0700 | [diff] [blame] | 230 | void RegisterDexFile(const DexFile& dex_file); |
Brian Carlstrom | 40381fb | 2011-10-19 14:13:40 -0700 | [diff] [blame] | 231 | void RegisterDexFile(const DexFile& dex_file, SirtRef<DexCache>& dex_cache); |
Carl Shapiro | 0e5d75d | 2011-07-06 18:28:37 -0700 | [diff] [blame] | 232 | |
Brian Carlstrom | 8a48741 | 2011-08-29 20:08:52 -0700 | [diff] [blame] | 233 | const std::vector<const DexFile*>& GetBootClassPath() { |
| 234 | return boot_class_path_; |
| 235 | } |
| 236 | |
Elliott Hughes | a215526 | 2011-11-16 16:26:58 -0800 | [diff] [blame] | 237 | void VisitClasses(ClassVisitor* visitor, void* arg) const; |
| 238 | |
Elliott Hughes | 410c0c8 | 2011-09-01 17:58:25 -0700 | [diff] [blame] | 239 | void VisitRoots(Heap::RootVisitor* visitor, void* arg) const; |
Brian Carlstrom | 75cb3b4 | 2011-07-28 02:13:36 -0700 | [diff] [blame] | 240 | |
buzbee | c143c55 | 2011-08-20 17:38:58 -0700 | [diff] [blame] | 241 | const DexFile& FindDexFile(const DexCache* dex_cache) const; |
Brian Carlstrom | 9ea1cb1 | 2011-08-24 23:18:18 -0700 | [diff] [blame] | 242 | DexCache* FindDexCache(const DexFile& dex_file) const; |
Brian Carlstrom | aded5f7 | 2011-10-07 17:15:04 -0700 | [diff] [blame] | 243 | bool IsDexFileRegistered(const DexFile& dex_file) const; |
Brian Carlstrom | 1d9f52b | 2011-10-13 10:50:45 -0700 | [diff] [blame] | 244 | |
jeffhao | 262bf46 | 2011-10-20 18:36:32 -0700 | [diff] [blame] | 245 | // Generate an oat file from a dex file |
Brian Carlstrom | d601af8 | 2012-01-06 10:15:19 -0800 | [diff] [blame^] | 246 | bool GenerateOatFile(const std::string& dex_filename, |
| 247 | int oat_fd, |
| 248 | const std::string& oat_cache_filename); |
jeffhao | 262bf46 | 2011-10-20 18:36:32 -0700 | [diff] [blame] | 249 | |
Brian Carlstrom | 1d9f52b | 2011-10-13 10:50:45 -0700 | [diff] [blame] | 250 | // Find, possibily opening, an OatFile corresponding to a DexFile |
Brian Carlstrom | ae82698 | 2011-11-09 01:33:42 -0800 | [diff] [blame] | 251 | const OatFile* FindOatFileForDexFile(const DexFile& dex_file); |
| 252 | const OatFile* FindOatFileFromOatLocation(const std::string& location); |
buzbee | c143c55 | 2011-08-20 17:38:58 -0700 | [diff] [blame] | 253 | |
Elliott Hughes | 418d20f | 2011-09-22 14:00:39 -0700 | [diff] [blame] | 254 | // TODO: replace this with multiple methods that allocate the correct managed type. |
Shih-wei Liao | 4417536 | 2011-08-28 16:59:17 -0700 | [diff] [blame] | 255 | template <class T> |
| 256 | ObjectArray<T>* AllocObjectArray(size_t length) { |
| 257 | return ObjectArray<T>::Alloc(GetClassRoot(kObjectArrayClass), length); |
| 258 | } |
| 259 | |
Elliott Hughes | 418d20f | 2011-09-22 14:00:39 -0700 | [diff] [blame] | 260 | ObjectArray<Class>* AllocClassArray(size_t length) { |
| 261 | return ObjectArray<Class>::Alloc(GetClassRoot(kClassArrayClass), length); |
| 262 | } |
| 263 | |
Shih-wei Liao | 55df06b | 2011-08-26 14:39:27 -0700 | [diff] [blame] | 264 | ObjectArray<StackTraceElement>* AllocStackTraceElementArray(size_t length); |
| 265 | |
jeffhao | 98eacac | 2011-09-14 16:11:53 -0700 | [diff] [blame] | 266 | void VerifyClass(Class* klass); |
| 267 | |
Jesse Wilson | 95caa79 | 2011-10-12 18:14:17 -0400 | [diff] [blame] | 268 | Class* CreateProxyClass(String* name, ObjectArray<Class>* interfaces, ClassLoader* loader, |
Ian Rogers | 6d4d9fc | 2011-11-30 16:24:48 -0800 | [diff] [blame] | 269 | ObjectArray<Method>* methods, ObjectArray<ObjectArray<Class> >* throws); |
| 270 | std::string GetDescriptorForProxy(const Class* proxy_class); |
Jesse Wilson | 95caa79 | 2011-10-12 18:14:17 -0400 | [diff] [blame] | 271 | |
Brian Carlstrom | 47d237a | 2011-10-18 15:08:33 -0700 | [diff] [blame] | 272 | pid_t GetClassesLockOwner(); // For SignalCatcher. |
| 273 | pid_t GetDexLockOwner(); // For SignalCatcher. |
Brian Carlstrom | 24a3c2e | 2011-10-17 18:07:52 -0700 | [diff] [blame] | 274 | |
Carl Shapiro | 0e5d75d | 2011-07-06 18:28:37 -0700 | [diff] [blame] | 275 | private: |
Elliott Hughes | 4dd9b4d | 2011-12-12 18:29:24 -0800 | [diff] [blame] | 276 | explicit ClassLinker(InternTable*); |
Carl Shapiro | 61e019d | 2011-07-14 16:53:09 -0700 | [diff] [blame] | 277 | |
Brian Carlstrom | 58ae941 | 2011-10-04 00:56:06 -0700 | [diff] [blame] | 278 | // Initialize class linker by bootstraping from dex files |
| 279 | void Init(const std::string& boot_class_path); |
Carl Shapiro | 61e019d | 2011-07-14 16:53:09 -0700 | [diff] [blame] | 280 | |
Brian Carlstrom | 58ae941 | 2011-10-04 00:56:06 -0700 | [diff] [blame] | 281 | // Initialize class linker from one or more images. |
| 282 | void InitFromImage(); |
| 283 | OatFile* OpenOat(const Space* space); |
Brian Carlstrom | 78128a6 | 2011-09-15 17:21:19 -0700 | [diff] [blame] | 284 | static void InitFromImageCallback(Object* obj, void* arg); |
Brian Carlstrom | c74255f | 2011-09-11 22:47:39 -0700 | [diff] [blame] | 285 | struct InitFromImageCallbackState; |
Brian Carlstrom | a663ea5 | 2011-08-19 23:33:41 -0700 | [diff] [blame] | 286 | |
| 287 | void FinishInit(); |
| 288 | |
Brian Carlstrom | 75cb3b4 | 2011-07-28 02:13:36 -0700 | [diff] [blame] | 289 | // For early bootstrapping by Init |
Brian Carlstrom | 4873d46 | 2011-08-21 15:23:39 -0700 | [diff] [blame] | 290 | Class* AllocClass(Class* java_lang_Class, size_t class_size); |
Brian Carlstrom | 75cb3b4 | 2011-07-28 02:13:36 -0700 | [diff] [blame] | 291 | |
| 292 | // Alloc* convenience functions to avoid needing to pass in Class* |
| 293 | // values that are known to the ClassLinker such as |
| 294 | // kObjectArrayClass and kJavaLangString etc. |
Brian Carlstrom | 4873d46 | 2011-08-21 15:23:39 -0700 | [diff] [blame] | 295 | Class* AllocClass(size_t class_size); |
Brian Carlstrom | 9ea1cb1 | 2011-08-24 23:18:18 -0700 | [diff] [blame] | 296 | DexCache* AllocDexCache(const DexFile& dex_file); |
Jesse Wilson | 35baaab | 2011-08-10 16:18:03 -0400 | [diff] [blame] | 297 | Field* AllocField(); |
Ian Rogers | bdb0391 | 2011-09-14 00:55:44 -0700 | [diff] [blame] | 298 | |
Brian Carlstrom | 75cb3b4 | 2011-07-28 02:13:36 -0700 | [diff] [blame] | 299 | Method* AllocMethod(); |
Ian Rogers | bdb0391 | 2011-09-14 00:55:44 -0700 | [diff] [blame] | 300 | |
Brian Carlstrom | 9cc262e | 2011-08-28 12:45:30 -0700 | [diff] [blame] | 301 | CodeAndDirectMethods* AllocCodeAndDirectMethods(size_t length); |
Brian Carlstrom | 4b620ff | 2011-09-11 01:11:01 -0700 | [diff] [blame] | 302 | InterfaceEntry* AllocInterfaceEntry(Class* interface); |
Brian Carlstrom | 75cb3b4 | 2011-07-28 02:13:36 -0700 | [diff] [blame] | 303 | |
Brian Carlstrom | 6b4ef02 | 2011-10-23 14:59:04 -0700 | [diff] [blame] | 304 | Class* CreatePrimitiveClass(const char* descriptor, Primitive::Type type) { |
Brian Carlstrom | 5b8e4c8 | 2011-09-18 01:38:59 -0700 | [diff] [blame] | 305 | return InitializePrimitiveClass(AllocClass(sizeof(Class)), descriptor, type); |
| 306 | } |
| 307 | Class* InitializePrimitiveClass(Class* primitive_class, |
| 308 | const char* descriptor, |
Brian Carlstrom | 6b4ef02 | 2011-10-23 14:59:04 -0700 | [diff] [blame] | 309 | Primitive::Type type); |
Brian Carlstrom | 5b8e4c8 | 2011-09-18 01:38:59 -0700 | [diff] [blame] | 310 | |
Brian Carlstrom | a331b3c | 2011-07-18 17:47:56 -0700 | [diff] [blame] | 311 | |
Elliott Hughes | c3b77c7 | 2011-12-15 20:56:48 -0800 | [diff] [blame] | 312 | Class* CreateArrayClass(const std::string& descriptor, const ClassLoader* class_loader); |
Brian Carlstrom | a331b3c | 2011-07-18 17:47:56 -0700 | [diff] [blame] | 313 | |
Brian Carlstrom | 9ea1cb1 | 2011-08-24 23:18:18 -0700 | [diff] [blame] | 314 | void AppendToBootClassPath(const DexFile& dex_file); |
Brian Carlstrom | 40381fb | 2011-10-19 14:13:40 -0700 | [diff] [blame] | 315 | void AppendToBootClassPath(const DexFile& dex_file, SirtRef<DexCache>& dex_cache); |
Brian Carlstrom | 578bbdc | 2011-07-21 14:07:47 -0700 | [diff] [blame] | 316 | |
Elliott Hughes | 5fe594f | 2011-09-08 12:33:17 -0700 | [diff] [blame] | 317 | void ConstructFieldMap(const DexFile& dex_file, const DexFile::ClassDef& dex_class_def, |
Ian Rogers | 0571d35 | 2011-11-03 19:51:38 -0700 | [diff] [blame] | 318 | Class* c, std::map<uint32_t, Field*>& field_map); |
Elliott Hughes | 5fe594f | 2011-09-08 12:33:17 -0700 | [diff] [blame] | 319 | |
Brian Carlstrom | 4873d46 | 2011-08-21 15:23:39 -0700 | [diff] [blame] | 320 | size_t SizeOfClass(const DexFile& dex_file, |
| 321 | const DexFile::ClassDef& dex_class_def); |
| 322 | |
Brian Carlstrom | f615a61 | 2011-07-23 12:50:34 -0700 | [diff] [blame] | 323 | void LoadClass(const DexFile& dex_file, |
| 324 | const DexFile::ClassDef& dex_class_def, |
Brian Carlstrom | 40381fb | 2011-10-19 14:13:40 -0700 | [diff] [blame] | 325 | SirtRef<Class>& klass, |
Brian Carlstrom | 9ea1cb1 | 2011-08-24 23:18:18 -0700 | [diff] [blame] | 326 | const ClassLoader* class_loader); |
Brian Carlstrom | 578bbdc | 2011-07-21 14:07:47 -0700 | [diff] [blame] | 327 | |
Ian Rogers | 0571d35 | 2011-11-03 19:51:38 -0700 | [diff] [blame] | 328 | void LoadField(const DexFile& dex_file, const ClassDataItemIterator& it, SirtRef<Class>& klass, |
Brian Carlstrom | 40381fb | 2011-10-19 14:13:40 -0700 | [diff] [blame] | 329 | SirtRef<Field>& dst); |
Brian Carlstrom | 578bbdc | 2011-07-21 14:07:47 -0700 | [diff] [blame] | 330 | |
Ian Rogers | 0571d35 | 2011-11-03 19:51:38 -0700 | [diff] [blame] | 331 | void LoadMethod(const DexFile& dex_file, const ClassDataItemIterator& dex_method, |
| 332 | SirtRef<Class>& klass, SirtRef<Method>& dst); |
Brian Carlstrom | 934486c | 2011-07-12 23:42:50 -0700 | [diff] [blame] | 333 | |
Carl Shapiro | 0e5d75d | 2011-07-06 18:28:37 -0700 | [diff] [blame] | 334 | // Inserts a class into the class table. Returns true if the class |
| 335 | // was inserted. |
Elliott Hughes | c3b77c7 | 2011-12-15 20:56:48 -0800 | [diff] [blame] | 336 | bool InsertClass(const StringPiece& descriptor, Class* klass, bool image_class); |
Brian Carlstrom | aded5f7 | 2011-10-07 17:15:04 -0700 | [diff] [blame] | 337 | |
Brian Carlstrom | 40381fb | 2011-10-19 14:13:40 -0700 | [diff] [blame] | 338 | void RegisterDexFileLocked(const DexFile& dex_file, SirtRef<DexCache>& dex_cache); |
Brian Carlstrom | aded5f7 | 2011-10-07 17:15:04 -0700 | [diff] [blame] | 339 | bool IsDexFileRegisteredLocked(const DexFile& dex_file) const; |
| 340 | |
Brian Carlstrom | d1422f8 | 2011-09-28 11:37:09 -0700 | [diff] [blame] | 341 | bool InitializeClass(Class* klass, bool can_run_clinit); |
| 342 | bool WaitForInitializeClass(Class* klass, Thread* self, ObjectLock& lock); |
Carl Shapiro | 0e5d75d | 2011-07-06 18:28:37 -0700 | [diff] [blame] | 343 | bool ValidateSuperClassDescriptors(const Class* klass); |
Brian Carlstrom | d1422f8 | 2011-09-28 11:37:09 -0700 | [diff] [blame] | 344 | bool InitializeSuperClass(Class* klass, bool can_run_clinit); |
| 345 | void InitializeStaticFields(Class* klass); |
Carl Shapiro | 0e5d75d | 2011-07-06 18:28:37 -0700 | [diff] [blame] | 346 | |
| 347 | bool HasSameDescriptorClasses(const char* descriptor, |
| 348 | const Class* klass1, |
| 349 | const Class* klass2); |
| 350 | |
| 351 | bool HasSameMethodDescriptorClasses(const Method* descriptor, |
| 352 | const Class* klass1, |
| 353 | const Class* klass2); |
| 354 | |
Ian Rogers | c2b4447 | 2011-12-14 21:17:17 -0800 | [diff] [blame] | 355 | bool LinkClass(SirtRef<Class>& klass, ObjectArray<Class>* interfaces); |
Carl Shapiro | 0e5d75d | 2011-07-06 18:28:37 -0700 | [diff] [blame] | 356 | |
Brian Carlstrom | 40381fb | 2011-10-19 14:13:40 -0700 | [diff] [blame] | 357 | bool LinkSuperClass(SirtRef<Class>& klass); |
Carl Shapiro | 0e5d75d | 2011-07-06 18:28:37 -0700 | [diff] [blame] | 358 | |
Brian Carlstrom | 40381fb | 2011-10-19 14:13:40 -0700 | [diff] [blame] | 359 | bool LoadSuperAndInterfaces(SirtRef<Class>& klass, const DexFile& dex_file); |
Carl Shapiro | 0e5d75d | 2011-07-06 18:28:37 -0700 | [diff] [blame] | 360 | |
Ian Rogers | 6d4d9fc | 2011-11-30 16:24:48 -0800 | [diff] [blame] | 361 | bool LinkMethods(SirtRef<Class>& klass, ObjectArray<Class>* interfaces); |
Carl Shapiro | 0e5d75d | 2011-07-06 18:28:37 -0700 | [diff] [blame] | 362 | |
Brian Carlstrom | 40381fb | 2011-10-19 14:13:40 -0700 | [diff] [blame] | 363 | bool LinkVirtualMethods(SirtRef<Class>& klass); |
Carl Shapiro | 0e5d75d | 2011-07-06 18:28:37 -0700 | [diff] [blame] | 364 | |
Ian Rogers | 6d4d9fc | 2011-11-30 16:24:48 -0800 | [diff] [blame] | 365 | bool LinkInterfaceMethods(SirtRef<Class>& klass, ObjectArray<Class>* interfaces); |
Carl Shapiro | 0e5d75d | 2011-07-06 18:28:37 -0700 | [diff] [blame] | 366 | |
Brian Carlstrom | 40381fb | 2011-10-19 14:13:40 -0700 | [diff] [blame] | 367 | bool LinkStaticFields(SirtRef<Class>& klass); |
| 368 | bool LinkInstanceFields(SirtRef<Class>& klass); |
| 369 | bool LinkFields(SirtRef<Class>& klass, bool is_static); |
Ian Rogers | 0cfe1fb | 2011-08-26 03:29:44 -0700 | [diff] [blame] | 370 | |
Carl Shapiro | 0e5d75d | 2011-07-06 18:28:37 -0700 | [diff] [blame] | 371 | |
Brian Carlstrom | 40381fb | 2011-10-19 14:13:40 -0700 | [diff] [blame] | 372 | void CreateReferenceInstanceOffsets(SirtRef<Class>& klass); |
| 373 | void CreateReferenceStaticOffsets(SirtRef<Class>& klass); |
| 374 | void CreateReferenceOffsets(SirtRef<Class>& klass, bool is_static, |
Ian Rogers | 0cfe1fb | 2011-08-26 03:29:44 -0700 | [diff] [blame] | 375 | uint32_t reference_offsets); |
Carl Shapiro | 0e5d75d | 2011-07-06 18:28:37 -0700 | [diff] [blame] | 376 | |
Brian Carlstrom | 58ae941 | 2011-10-04 00:56:06 -0700 | [diff] [blame] | 377 | // For use by ImageWriter to find DexCaches for its roots |
| 378 | const std::vector<DexCache*>& GetDexCaches() { |
| 379 | return dex_caches_; |
| 380 | } |
| 381 | |
Brian Carlstrom | ae82698 | 2011-11-09 01:33:42 -0800 | [diff] [blame] | 382 | const OatFile* FindOpenedOatFileForDexFile(const DexFile& dex_file); |
| 383 | const OatFile* FindOpenedOatFileFromOatLocation(const std::string& oat_location); |
Brian Carlstrom | fad7143 | 2011-10-16 20:25:10 -0700 | [diff] [blame] | 384 | |
Ian Rogers | 6d4d9fc | 2011-11-30 16:24:48 -0800 | [diff] [blame] | 385 | Method* CreateProxyConstructor(SirtRef<Class>& klass, Class* proxy_class); |
| 386 | Method* CreateProxyMethod(SirtRef<Class>& klass, SirtRef<Method>& prototype); |
Jesse Wilson | 95caa79 | 2011-10-12 18:14:17 -0400 | [diff] [blame] | 387 | |
Brian Carlstrom | 4a96b60 | 2011-07-26 16:40:23 -0700 | [diff] [blame] | 388 | std::vector<const DexFile*> boot_class_path_; |
Brian Carlstrom | 578bbdc | 2011-07-21 14:07:47 -0700 | [diff] [blame] | 389 | |
Brian Carlstrom | 4a96b60 | 2011-07-26 16:40:23 -0700 | [diff] [blame] | 390 | std::vector<const DexFile*> dex_files_; |
Brian Carlstrom | 7e49dca | 2011-07-22 18:07:34 -0700 | [diff] [blame] | 391 | std::vector<DexCache*> dex_caches_; |
Brian Carlstrom | 47d237a | 2011-10-18 15:08:33 -0700 | [diff] [blame] | 392 | std::vector<const OatFile*> oat_files_; |
| 393 | // lock to protect concurrent access to dex_files_, dex_caches_, and oat_files_ |
| 394 | mutable Mutex dex_lock_; |
| 395 | |
Carl Shapiro | 0e5d75d | 2011-07-06 18:28:37 -0700 | [diff] [blame] | 396 | |
Brian Carlstrom | aded5f7 | 2011-10-07 17:15:04 -0700 | [diff] [blame] | 397 | // multimap from a string hash code of a class descriptor to |
Brian Carlstrom | 9cff8e1 | 2011-08-18 16:47:29 -0700 | [diff] [blame] | 398 | // Class* instances. Results should be compared for a matching |
| 399 | // Class::descriptor_ and Class::class_loader_. |
Brian Carlstrom | 47d237a | 2011-10-18 15:08:33 -0700 | [diff] [blame] | 400 | // Protected by classes_lock_ |
Brian Carlstrom | 9cff8e1 | 2011-08-18 16:47:29 -0700 | [diff] [blame] | 401 | typedef std::tr1::unordered_multimap<size_t, Class*> Table; |
Ian Rogers | 5d76c43 | 2011-10-31 21:42:49 -0700 | [diff] [blame] | 402 | Table image_classes_; |
Carl Shapiro | 0e5d75d | 2011-07-06 18:28:37 -0700 | [diff] [blame] | 403 | Table classes_; |
Brian Carlstrom | 47d237a | 2011-10-18 15:08:33 -0700 | [diff] [blame] | 404 | mutable Mutex classes_lock_; |
Carl Shapiro | 0e5d75d | 2011-07-06 18:28:37 -0700 | [diff] [blame] | 405 | |
Brian Carlstrom | a663ea5 | 2011-08-19 23:33:41 -0700 | [diff] [blame] | 406 | // indexes into class_roots_. |
| 407 | // needs to be kept in sync with class_roots_descriptors_. |
Brian Carlstrom | 74eb46a | 2011-08-02 20:10:14 -0700 | [diff] [blame] | 408 | enum ClassRoot { |
Brian Carlstrom | 75cb3b4 | 2011-07-28 02:13:36 -0700 | [diff] [blame] | 409 | kJavaLangClass, |
| 410 | kJavaLangObject, |
Elliott Hughes | 418d20f | 2011-09-22 14:00:39 -0700 | [diff] [blame] | 411 | kClassArrayClass, |
Brian Carlstrom | 74eb46a | 2011-08-02 20:10:14 -0700 | [diff] [blame] | 412 | kObjectArrayClass, |
| 413 | kJavaLangString, |
Elliott Hughes | bf61ba3 | 2011-10-11 10:53:09 -0700 | [diff] [blame] | 414 | kJavaLangRefReference, |
Elliott Hughes | 8060925 | 2011-09-23 17:24:51 -0700 | [diff] [blame] | 415 | kJavaLangReflectConstructor, |
Brian Carlstrom | 75cb3b4 | 2011-07-28 02:13:36 -0700 | [diff] [blame] | 416 | kJavaLangReflectField, |
| 417 | kJavaLangReflectMethod, |
Ian Rogers | 466bb25 | 2011-10-14 03:29:56 -0700 | [diff] [blame] | 418 | kJavaLangReflectProxy, |
Brian Carlstrom | 74eb46a | 2011-08-02 20:10:14 -0700 | [diff] [blame] | 419 | kJavaLangClassLoader, |
| 420 | kDalvikSystemBaseDexClassLoader, |
| 421 | kDalvikSystemPathClassLoader, |
Shih-wei Liao | 55df06b | 2011-08-26 14:39:27 -0700 | [diff] [blame] | 422 | kJavaLangStackTraceElement, |
Brian Carlstrom | 75cb3b4 | 2011-07-28 02:13:36 -0700 | [diff] [blame] | 423 | kPrimitiveBoolean, |
Brian Carlstrom | 75cb3b4 | 2011-07-28 02:13:36 -0700 | [diff] [blame] | 424 | kPrimitiveByte, |
Elliott Hughes | d8ddfd5 | 2011-08-15 14:32:53 -0700 | [diff] [blame] | 425 | kPrimitiveChar, |
| 426 | kPrimitiveDouble, |
| 427 | kPrimitiveFloat, |
Brian Carlstrom | 75cb3b4 | 2011-07-28 02:13:36 -0700 | [diff] [blame] | 428 | kPrimitiveInt, |
| 429 | kPrimitiveLong, |
Elliott Hughes | d8ddfd5 | 2011-08-15 14:32:53 -0700 | [diff] [blame] | 430 | kPrimitiveShort, |
Brian Carlstrom | 75cb3b4 | 2011-07-28 02:13:36 -0700 | [diff] [blame] | 431 | kPrimitiveVoid, |
Elliott Hughes | d8ddfd5 | 2011-08-15 14:32:53 -0700 | [diff] [blame] | 432 | kBooleanArrayClass, |
| 433 | kByteArrayClass, |
| 434 | kCharArrayClass, |
| 435 | kDoubleArrayClass, |
| 436 | kFloatArrayClass, |
| 437 | kIntArrayClass, |
| 438 | kLongArrayClass, |
| 439 | kShortArrayClass, |
Shih-wei Liao | 55df06b | 2011-08-26 14:39:27 -0700 | [diff] [blame] | 440 | kJavaLangStackTraceElementArrayClass, |
Brian Carlstrom | 75cb3b4 | 2011-07-28 02:13:36 -0700 | [diff] [blame] | 441 | kClassRootsMax, |
| 442 | }; |
| 443 | ObjectArray<Class>* class_roots_; |
Brian Carlstrom | 913af1b | 2011-07-23 21:41:13 -0700 | [diff] [blame] | 444 | |
Brian Carlstrom | 74eb46a | 2011-08-02 20:10:14 -0700 | [diff] [blame] | 445 | Class* GetClassRoot(ClassRoot class_root) { |
Brian Carlstrom | a663ea5 | 2011-08-19 23:33:41 -0700 | [diff] [blame] | 446 | DCHECK(class_roots_ != NULL); |
Brian Carlstrom | 74eb46a | 2011-08-02 20:10:14 -0700 | [diff] [blame] | 447 | Class* klass = class_roots_->Get(class_root); |
| 448 | DCHECK(klass != NULL); |
| 449 | return klass; |
| 450 | } |
| 451 | |
Ian Rogers | 6d4d9fc | 2011-11-30 16:24:48 -0800 | [diff] [blame] | 452 | void SetClassRoot(ClassRoot class_root, Class* klass); |
Brian Carlstrom | a663ea5 | 2011-08-19 23:33:41 -0700 | [diff] [blame] | 453 | |
Brian Carlstrom | 34f426c | 2011-10-04 12:58:02 -0700 | [diff] [blame] | 454 | ObjectArray<Class>* GetClassRoots() { |
| 455 | DCHECK(class_roots_ != NULL); |
| 456 | return class_roots_; |
| 457 | } |
| 458 | |
Elliott Hughes | 418d20f | 2011-09-22 14:00:39 -0700 | [diff] [blame] | 459 | static const char* class_roots_descriptors_[]; |
Brian Carlstrom | a663ea5 | 2011-08-19 23:33:41 -0700 | [diff] [blame] | 460 | |
| 461 | const char* GetClassRootDescriptor(ClassRoot class_root) { |
| 462 | const char* descriptor = class_roots_descriptors_[class_root]; |
| 463 | CHECK(descriptor != NULL); |
| 464 | return descriptor; |
| 465 | } |
| 466 | |
Brian Carlstrom | 4b620ff | 2011-09-11 01:11:01 -0700 | [diff] [blame] | 467 | ObjectArray<InterfaceEntry>* array_iftable_; |
Carl Shapiro | 565f507 | 2011-07-10 13:39:43 -0700 | [diff] [blame] | 468 | |
Brian Carlstrom | 75cb3b4 | 2011-07-28 02:13:36 -0700 | [diff] [blame] | 469 | bool init_done_; |
| 470 | |
Elliott Hughes | cf4c6c4 | 2011-09-01 15:16:42 -0700 | [diff] [blame] | 471 | InternTable* intern_table_; |
| 472 | |
Brian Carlstrom | f734cf5 | 2011-08-17 16:28:14 -0700 | [diff] [blame] | 473 | friend class CommonTest; |
Brian Carlstrom | 34f426c | 2011-10-04 12:58:02 -0700 | [diff] [blame] | 474 | friend class ImageWriter; // for GetClassRoots |
Brian Carlstrom | ae82698 | 2011-11-09 01:33:42 -0800 | [diff] [blame] | 475 | friend class ObjectTest; |
Ian Rogers | 6d4d9fc | 2011-11-30 16:24:48 -0800 | [diff] [blame] | 476 | FRIEND_TEST(ClassLinkerTest, ClassRootDescriptors); |
Brian Carlstrom | ae82698 | 2011-11-09 01:33:42 -0800 | [diff] [blame] | 477 | FRIEND_TEST(DexCacheTest, Open); |
| 478 | FRIEND_TEST(ExceptionTest, FindExceptionHandler); |
| 479 | FRIEND_TEST(ObjectTest, AllocObjectArray); |
Carl Shapiro | 0e5d75d | 2011-07-06 18:28:37 -0700 | [diff] [blame] | 480 | DISALLOW_COPY_AND_ASSIGN(ClassLinker); |
| 481 | }; |
| 482 | |
| 483 | } // namespace art |
| 484 | |
| 485 | #endif // ART_SRC_CLASS_LINKER_H_ |