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