17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #ifndef SHARE_CDS_AOTCLASSLOCATION_HPP
26 #define SHARE_CDS_AOTCLASSLOCATION_HPP
27
28 #include "memory/allocation.hpp"
29 #include "oops/array.hpp"
30 #include "utilities/exceptions.hpp"
31 #include "utilities/growableArray.hpp"
32 #include "utilities/globalDefinitions.hpp"
33 #include "utilities/macros.hpp"
34
35 class AllClassLocationStreams;
36 class ClassLocationStream;
37 class LogStream;
38
39 // An AOTClassLocation is a location where the application is configured to load Java classes
40 // from. It can be:
41 // - the location of $JAVA_HOME/lib/modules
42 // - an entry in -Xbootclasspath/a
43 // - an entry in -classpath
44 // - a JAR file specified using --module-path.
45 //
46 // AOTClassLocation is similar to java.security.CodeSource, except:
47 // - Only local files/dirs are allowed. Directories must be empty. Network locations are not allowed.
48 // - No code signing information is recorded.
49 //
50 // We avoid using pointers in AOTClassLocation to avoid runtime pointer relocation. Each AOTClassLocation
51 // is a variable-size structure:
52 // [ all fields specified below (sizeof(AOTClassLocation) bytes) ]
53 // [ path (_path_length bytes, including the terminating zero) ]
54 // [ manifest (_manifest_length bytes, including the terminating zero) ]
55 class AOTClassLocation {
56 public:
122 // In general, validation is performed on the AOTClassLocations to ensure the code locations used
123 // during AOTCache creation are the same as when the AOTCache is used during runtime.
124 // Non-existent entries are recorded during AOTCache creation. Those non-existent entries,
125 // if they are specified at runtime, must not exist.
126 //
127 // Some details on validation:
128 // - the boot classpath can be appended to at runtime if there's no app classpath and no
129 // module path specified when an AOTCache is created;
130 // - the app classpath can be appended to at runtime;
131 // - the module path at runtime can be a superset of the one specified during AOTCache creation.
132
133 class AOTClassLocationConfig : public CHeapObj<mtClassShared> {
134 using Group = AOTClassLocation::Group;
135 using GrowableClassLocationArray = GrowableArrayCHeap<AOTClassLocation*, mtClassShared>;
136
137 // Note: both of the following are non-null if we are dumping a dynamic archive.
138 static AOTClassLocationConfig* _dumptime_instance;
139 static const AOTClassLocationConfig* _runtime_instance;
140
141 Array<AOTClassLocation*>* _class_locations; // jrt -> -Xbootclasspath/a -> -classpath -> --module_path
142 int _boot_classpath_end;
143 int _app_classpath_end;
144 int _module_end;
145 bool _has_non_jar_modules;
146 bool _has_platform_classes;
147 bool _has_app_classes;
148 int _max_used_index;
149 size_t _dumptime_lcp_len;
150
151 // accessors
152 Array<AOTClassLocation*>* class_locations() const { return _class_locations; }
153
154 void parse(JavaThread* current, GrowableClassLocationArray& tmp_array, ClassLocationStream& css,
155 Group group, bool parse_manifest);
156 void add_class_location(JavaThread* current, GrowableClassLocationArray& tmp_array, const char* path,
157 Group group, bool parse_manifest, bool from_cpattr);
158 void dumptime_init_helper(TRAPS);
159
160 bool check_classpaths(bool is_boot_classpath, bool has_aot_linked_classes,
161 int index_start, int index_end, ClassLocationStream& runtime_css,
246 } else if (_dumptime_instance->_max_used_index < index) {
247 _dumptime_instance->_max_used_index = index;
248 }
249 }
250
251 static void dumptime_check_nonempty_dirs() {
252 _dumptime_instance->check_nonempty_dirs();
253 }
254
255 static bool dumptime_is_ready() {
256 return _dumptime_instance != nullptr;
257 }
258 template <typename FUNC> static void dumptime_iterate(FUNC func) {
259 _dumptime_instance->dumptime_iterate_helper(func);
260 }
261
262 AOTClassLocationConfig* write_to_archive() const;
263
264 // Functions used only during runtime
265 bool validate(bool has_aot_linked_classes, bool* has_extra_module_paths) const;
266 };
267
268
269 #endif // SHARE_CDS_AOTCLASSLOCATION_HPP
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #ifndef SHARE_CDS_AOTCLASSLOCATION_HPP
26 #define SHARE_CDS_AOTCLASSLOCATION_HPP
27
28 #include "memory/allocation.hpp"
29 #include "oops/array.hpp"
30 #include "utilities/exceptions.hpp"
31 #include "utilities/growableArray.hpp"
32 #include "utilities/globalDefinitions.hpp"
33 #include "utilities/macros.hpp"
34
35 class AllClassLocationStreams;
36 class ClassLocationStream;
37 class ClassPathZipEntry;
38 class LogStream;
39
40 // An AOTClassLocation is a location where the application is configured to load Java classes
41 // from. It can be:
42 // - the location of $JAVA_HOME/lib/modules
43 // - an entry in -Xbootclasspath/a
44 // - an entry in -classpath
45 // - a JAR file specified using --module-path.
46 //
47 // AOTClassLocation is similar to java.security.CodeSource, except:
48 // - Only local files/dirs are allowed. Directories must be empty. Network locations are not allowed.
49 // - No code signing information is recorded.
50 //
51 // We avoid using pointers in AOTClassLocation to avoid runtime pointer relocation. Each AOTClassLocation
52 // is a variable-size structure:
53 // [ all fields specified below (sizeof(AOTClassLocation) bytes) ]
54 // [ path (_path_length bytes, including the terminating zero) ]
55 // [ manifest (_manifest_length bytes, including the terminating zero) ]
56 class AOTClassLocation {
57 public:
123 // In general, validation is performed on the AOTClassLocations to ensure the code locations used
124 // during AOTCache creation are the same as when the AOTCache is used during runtime.
125 // Non-existent entries are recorded during AOTCache creation. Those non-existent entries,
126 // if they are specified at runtime, must not exist.
127 //
128 // Some details on validation:
129 // - the boot classpath can be appended to at runtime if there's no app classpath and no
130 // module path specified when an AOTCache is created;
131 // - the app classpath can be appended to at runtime;
132 // - the module path at runtime can be a superset of the one specified during AOTCache creation.
133
134 class AOTClassLocationConfig : public CHeapObj<mtClassShared> {
135 using Group = AOTClassLocation::Group;
136 using GrowableClassLocationArray = GrowableArrayCHeap<AOTClassLocation*, mtClassShared>;
137
138 // Note: both of the following are non-null if we are dumping a dynamic archive.
139 static AOTClassLocationConfig* _dumptime_instance;
140 static const AOTClassLocationConfig* _runtime_instance;
141
142 Array<AOTClassLocation*>* _class_locations; // jrt -> -Xbootclasspath/a -> -classpath -> --module_path
143 static Array<ClassPathZipEntry*>* _dumptime_jar_files;
144
145 int _boot_classpath_end;
146 int _app_classpath_end;
147 int _module_end;
148 bool _has_non_jar_modules;
149 bool _has_platform_classes;
150 bool _has_app_classes;
151 int _max_used_index;
152 size_t _dumptime_lcp_len;
153
154 // accessors
155 Array<AOTClassLocation*>* class_locations() const { return _class_locations; }
156
157 void parse(JavaThread* current, GrowableClassLocationArray& tmp_array, ClassLocationStream& css,
158 Group group, bool parse_manifest);
159 void add_class_location(JavaThread* current, GrowableClassLocationArray& tmp_array, const char* path,
160 Group group, bool parse_manifest, bool from_cpattr);
161 void dumptime_init_helper(TRAPS);
162
163 bool check_classpaths(bool is_boot_classpath, bool has_aot_linked_classes,
164 int index_start, int index_end, ClassLocationStream& runtime_css,
249 } else if (_dumptime_instance->_max_used_index < index) {
250 _dumptime_instance->_max_used_index = index;
251 }
252 }
253
254 static void dumptime_check_nonempty_dirs() {
255 _dumptime_instance->check_nonempty_dirs();
256 }
257
258 static bool dumptime_is_ready() {
259 return _dumptime_instance != nullptr;
260 }
261 template <typename FUNC> static void dumptime_iterate(FUNC func) {
262 _dumptime_instance->dumptime_iterate_helper(func);
263 }
264
265 AOTClassLocationConfig* write_to_archive() const;
266
267 // Functions used only during runtime
268 bool validate(bool has_aot_linked_classes, bool* has_extra_module_paths) const;
269
270 void check_invalid_classpath_index(int classpath_index, InstanceKlass* ik);
271 };
272
273
274 #endif // SHARE_CDS_AOTCLASSLOCATION_HPP
|