Elliott Hughes | 2faa5f1 | 2012-01-30 14:42:07 -0800 | [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 | */ |
Brian Carlstrom | 1f87008 | 2011-08-23 16:02:11 -0700 | [diff] [blame] | 16 | |
| 17 | #ifndef ART_SRC_CLASS_LOADER_H_ |
| 18 | #define ART_SRC_CLASS_LOADER_H_ |
| 19 | |
Elliott Hughes | e5448b5 | 2012-01-18 16:44:06 -0800 | [diff] [blame] | 20 | #include <map> |
Brian Carlstrom | 1f87008 | 2011-08-23 16:02:11 -0700 | [diff] [blame] | 21 | #include <vector> |
| 22 | |
| 23 | #include "dex_file.h" |
| 24 | #include "object.h" |
| 25 | |
| 26 | namespace art { |
| 27 | |
Ian Rogers | 0cfe1fb | 2011-08-26 03:29:44 -0700 | [diff] [blame] | 28 | // C++ mirror of java.lang.ClassLoader |
Brian Carlstrom | aded5f7 | 2011-10-07 17:15:04 -0700 | [diff] [blame] | 29 | class MANAGED ClassLoader : public Object { |
Brian Carlstrom | 1f87008 | 2011-08-23 16:02:11 -0700 | [diff] [blame] | 30 | public: |
Brian Carlstrom | aded5f7 | 2011-10-07 17:15:04 -0700 | [diff] [blame] | 31 | static const std::vector<const DexFile*>& GetCompileTimeClassPath(const ClassLoader* class_loader); |
| 32 | static void SetCompileTimeClassPath(const ClassLoader* class_loader, std::vector<const DexFile*>& class_path); |
| 33 | static bool UseCompileTimeClassPath() { |
| 34 | return use_compile_time_class_path; |
Brian Carlstrom | 1f87008 | 2011-08-23 16:02:11 -0700 | [diff] [blame] | 35 | } |
| 36 | |
| 37 | private: |
| 38 | // Field order required by test "ValidateFieldOrderOfJavaCppUnionClasses". |
| 39 | Object* packages_; |
| 40 | ClassLoader* parent_; |
Jesse Wilson | 1b5f497 | 2011-10-11 21:41:08 -0400 | [diff] [blame] | 41 | Object* proxyCache_; |
Brian Carlstrom | 1f87008 | 2011-08-23 16:02:11 -0700 | [diff] [blame] | 42 | |
Elliott Hughes | e5448b5 | 2012-01-18 16:44:06 -0800 | [diff] [blame] | 43 | typedef std::map<const ClassLoader*, std::vector<const DexFile*> > Table; |
Brian Carlstrom | aded5f7 | 2011-10-07 17:15:04 -0700 | [diff] [blame] | 44 | static Table compile_time_class_paths_; |
| 45 | |
| 46 | static bool use_compile_time_class_path; |
Brian Carlstrom | 1f87008 | 2011-08-23 16:02:11 -0700 | [diff] [blame] | 47 | |
Brian Carlstrom | 693267a | 2011-09-06 09:25:34 -0700 | [diff] [blame] | 48 | friend struct ClassLoaderOffsets; // for verifying offset information |
Brian Carlstrom | 1f87008 | 2011-08-23 16:02:11 -0700 | [diff] [blame] | 49 | DISALLOW_IMPLICIT_CONSTRUCTORS(ClassLoader); |
| 50 | }; |
| 51 | |
Ian Rogers | 0cfe1fb | 2011-08-26 03:29:44 -0700 | [diff] [blame] | 52 | // C++ mirror of dalvik.system.BaseDexClassLoader |
Brian Carlstrom | e4f7e1d | 2011-09-11 13:21:12 -0700 | [diff] [blame] | 53 | // TODO: add MANAGED when class_path_ removed |
Brian Carlstrom | 1f87008 | 2011-08-23 16:02:11 -0700 | [diff] [blame] | 54 | class BaseDexClassLoader : public ClassLoader { |
| 55 | private: |
| 56 | // Field order required by test "ValidateFieldOrderOfJavaCppUnionClasses". |
| 57 | String* original_path_; |
| 58 | Object* path_list_; |
Brian Carlstrom | 693267a | 2011-09-06 09:25:34 -0700 | [diff] [blame] | 59 | |
| 60 | friend struct BaseDexClassLoaderOffsets; // for verifying offset information |
Brian Carlstrom | 1f87008 | 2011-08-23 16:02:11 -0700 | [diff] [blame] | 61 | DISALLOW_IMPLICIT_CONSTRUCTORS(BaseDexClassLoader); |
| 62 | }; |
| 63 | |
Ian Rogers | 0cfe1fb | 2011-08-26 03:29:44 -0700 | [diff] [blame] | 64 | // C++ mirror of dalvik.system.PathClassLoader |
Brian Carlstrom | e4f7e1d | 2011-09-11 13:21:12 -0700 | [diff] [blame] | 65 | // TODO: add MANAGED when class_path_ removed |
Brian Carlstrom | 1f87008 | 2011-08-23 16:02:11 -0700 | [diff] [blame] | 66 | class PathClassLoader : public BaseDexClassLoader { |
| 67 | public: |
Brian Carlstrom | 40381fb | 2011-10-19 14:13:40 -0700 | [diff] [blame] | 68 | static PathClassLoader* AllocCompileTime(std::vector<const DexFile*>& dex_files); |
Brian Carlstrom | 1f87008 | 2011-08-23 16:02:11 -0700 | [diff] [blame] | 69 | static void SetClass(Class* dalvik_system_PathClassLoader); |
| 70 | static void ResetClass(); |
| 71 | private: |
| 72 | static Class* dalvik_system_PathClassLoader_; |
Brian Carlstrom | 693267a | 2011-09-06 09:25:34 -0700 | [diff] [blame] | 73 | friend struct PathClassLoaderOffsets; // for verifying offset information |
Brian Carlstrom | 1f87008 | 2011-08-23 16:02:11 -0700 | [diff] [blame] | 74 | DISALLOW_IMPLICIT_CONSTRUCTORS(PathClassLoader); |
| 75 | }; |
| 76 | |
| 77 | } // namespace art |
| 78 | |
| 79 | #endif // ART_SRC_OBJECT_H_ |