blob: 018cea9d58fb2773836fa0d35c8ab45976057e9c [file] [log] [blame]
Elliott Hughes2faa5f12012-01-30 14:42:07 -08001/*
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 Carlstrom1f870082011-08-23 16:02:11 -070016
17#ifndef ART_SRC_CLASS_LOADER_H_
18#define ART_SRC_CLASS_LOADER_H_
19
Elliott Hughese5448b52012-01-18 16:44:06 -080020#include <map>
Brian Carlstrom1f870082011-08-23 16:02:11 -070021#include <vector>
22
23#include "dex_file.h"
24#include "object.h"
25
26namespace art {
27
Ian Rogers0cfe1fb2011-08-26 03:29:44 -070028// C++ mirror of java.lang.ClassLoader
Brian Carlstromaded5f72011-10-07 17:15:04 -070029class MANAGED ClassLoader : public Object {
Brian Carlstrom1f870082011-08-23 16:02:11 -070030 public:
Brian Carlstromaded5f72011-10-07 17:15:04 -070031 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 Carlstrom1f870082011-08-23 16:02:11 -070035 }
36
37 private:
38 // Field order required by test "ValidateFieldOrderOfJavaCppUnionClasses".
39 Object* packages_;
40 ClassLoader* parent_;
Jesse Wilson1b5f4972011-10-11 21:41:08 -040041 Object* proxyCache_;
Brian Carlstrom1f870082011-08-23 16:02:11 -070042
Elliott Hughese5448b52012-01-18 16:44:06 -080043 typedef std::map<const ClassLoader*, std::vector<const DexFile*> > Table;
Brian Carlstromaded5f72011-10-07 17:15:04 -070044 static Table compile_time_class_paths_;
45
46 static bool use_compile_time_class_path;
Brian Carlstrom1f870082011-08-23 16:02:11 -070047
Brian Carlstrom693267a2011-09-06 09:25:34 -070048 friend struct ClassLoaderOffsets; // for verifying offset information
Brian Carlstrom1f870082011-08-23 16:02:11 -070049 DISALLOW_IMPLICIT_CONSTRUCTORS(ClassLoader);
50};
51
Ian Rogers0cfe1fb2011-08-26 03:29:44 -070052// C++ mirror of dalvik.system.BaseDexClassLoader
Brian Carlstrome4f7e1d2011-09-11 13:21:12 -070053// TODO: add MANAGED when class_path_ removed
Brian Carlstrom1f870082011-08-23 16:02:11 -070054class BaseDexClassLoader : public ClassLoader {
55 private:
56 // Field order required by test "ValidateFieldOrderOfJavaCppUnionClasses".
57 String* original_path_;
58 Object* path_list_;
Brian Carlstrom693267a2011-09-06 09:25:34 -070059
60 friend struct BaseDexClassLoaderOffsets; // for verifying offset information
Brian Carlstrom1f870082011-08-23 16:02:11 -070061 DISALLOW_IMPLICIT_CONSTRUCTORS(BaseDexClassLoader);
62};
63
Ian Rogers0cfe1fb2011-08-26 03:29:44 -070064// C++ mirror of dalvik.system.PathClassLoader
Brian Carlstrome4f7e1d2011-09-11 13:21:12 -070065// TODO: add MANAGED when class_path_ removed
Brian Carlstrom1f870082011-08-23 16:02:11 -070066class PathClassLoader : public BaseDexClassLoader {
67 public:
Brian Carlstrom40381fb2011-10-19 14:13:40 -070068 static PathClassLoader* AllocCompileTime(std::vector<const DexFile*>& dex_files);
Brian Carlstrom1f870082011-08-23 16:02:11 -070069 static void SetClass(Class* dalvik_system_PathClassLoader);
70 static void ResetClass();
71 private:
72 static Class* dalvik_system_PathClassLoader_;
Brian Carlstrom693267a2011-09-06 09:25:34 -070073 friend struct PathClassLoaderOffsets; // for verifying offset information
Brian Carlstrom1f870082011-08-23 16:02:11 -070074 DISALLOW_IMPLICIT_CONSTRUCTORS(PathClassLoader);
75};
76
77} // namespace art
78
79#endif // ART_SRC_OBJECT_H_