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 | |
| 13 | // ClassLoader objects. |
| 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) { |
| 19 | DCHECK_EQ(0U, class_path_.size()); |
| 20 | class_path_ = class_path; |
| 21 | } |
| 22 | |
| 23 | private: |
| 24 | // Field order required by test "ValidateFieldOrderOfJavaCppUnionClasses". |
| 25 | Object* packages_; |
| 26 | ClassLoader* parent_; |
| 27 | |
| 28 | // TODO: remove once we can create a real PathClassLoader |
| 29 | std::vector<const DexFile*> class_path_; |
| 30 | |
| 31 | DISALLOW_IMPLICIT_CONSTRUCTORS(ClassLoader); |
| 32 | }; |
| 33 | |
| 34 | class BaseDexClassLoader : public ClassLoader { |
| 35 | private: |
| 36 | // Field order required by test "ValidateFieldOrderOfJavaCppUnionClasses". |
| 37 | String* original_path_; |
| 38 | Object* path_list_; |
| 39 | DISALLOW_IMPLICIT_CONSTRUCTORS(BaseDexClassLoader); |
| 40 | }; |
| 41 | |
| 42 | class PathClassLoader : public BaseDexClassLoader { |
| 43 | public: |
| 44 | static const PathClassLoader* Alloc(std::vector<const DexFile*> dex_files); |
| 45 | static void SetClass(Class* dalvik_system_PathClassLoader); |
| 46 | static void ResetClass(); |
| 47 | private: |
| 48 | static Class* dalvik_system_PathClassLoader_; |
| 49 | DISALLOW_IMPLICIT_CONSTRUCTORS(PathClassLoader); |
| 50 | }; |
| 51 | |
| 52 | } // namespace art |
| 53 | |
| 54 | #endif // ART_SRC_OBJECT_H_ |