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" |
| 10 | |
| 11 | namespace art { |
| 12 | |
Ian Rogers | 0cfe1fb | 2011-08-26 03:29:44 -0700 | [diff] [blame] | 13 | // C++ mirror of java.lang.ClassLoader |
Brian Carlstrom | 1f87008 | 2011-08-23 16:02:11 -0700 | [diff] [blame] | 14 | class ClassLoader : public Object { |
| 15 | public: |
| 16 | static const std::vector<const DexFile*>& GetClassPath(const ClassLoader* class_loader); |
| 17 | |
| 18 | void SetClassPath(std::vector<const DexFile*>& class_path) { |
Elliott Hughes | 0f4c41d | 2011-09-04 14:58:03 -0700 | [diff] [blame] | 19 | DCHECK_EQ(class_path_.size(), 0U); |
Ian Rogers | 0cfe1fb | 2011-08-26 03:29:44 -0700 | [diff] [blame] | 20 | // TODO: use setter |
Brian Carlstrom | 1f87008 | 2011-08-23 16:02:11 -0700 | [diff] [blame] | 21 | class_path_ = class_path; |
| 22 | } |
| 23 | |
| 24 | private: |
| 25 | // Field order required by test "ValidateFieldOrderOfJavaCppUnionClasses". |
| 26 | Object* packages_; |
| 27 | ClassLoader* parent_; |
| 28 | |
| 29 | // TODO: remove once we can create a real PathClassLoader |
| 30 | std::vector<const DexFile*> class_path_; |
| 31 | |
| 32 | DISALLOW_IMPLICIT_CONSTRUCTORS(ClassLoader); |
| 33 | }; |
| 34 | |
Ian Rogers | 0cfe1fb | 2011-08-26 03:29:44 -0700 | [diff] [blame] | 35 | // C++ mirror of dalvik.system.BaseDexClassLoader |
Brian Carlstrom | 1f87008 | 2011-08-23 16:02:11 -0700 | [diff] [blame] | 36 | class BaseDexClassLoader : public ClassLoader { |
| 37 | private: |
| 38 | // Field order required by test "ValidateFieldOrderOfJavaCppUnionClasses". |
| 39 | String* original_path_; |
| 40 | Object* path_list_; |
| 41 | DISALLOW_IMPLICIT_CONSTRUCTORS(BaseDexClassLoader); |
| 42 | }; |
| 43 | |
Ian Rogers | 0cfe1fb | 2011-08-26 03:29:44 -0700 | [diff] [blame] | 44 | // C++ mirror of dalvik.system.PathClassLoader |
Brian Carlstrom | 1f87008 | 2011-08-23 16:02:11 -0700 | [diff] [blame] | 45 | class PathClassLoader : public BaseDexClassLoader { |
| 46 | public: |
| 47 | static const PathClassLoader* Alloc(std::vector<const DexFile*> dex_files); |
| 48 | static void SetClass(Class* dalvik_system_PathClassLoader); |
| 49 | static void ResetClass(); |
| 50 | private: |
| 51 | static Class* dalvik_system_PathClassLoader_; |
| 52 | DISALLOW_IMPLICIT_CONSTRUCTORS(PathClassLoader); |
| 53 | }; |
| 54 | |
| 55 | } // namespace art |
| 56 | |
| 57 | #endif // ART_SRC_OBJECT_H_ |