156 } else {
157 // Copy the manifest into the shared archive
158 manifest = ClassLoaderExt::read_raw_manifest(cpe, &manifest_size, CHECK);
159 Array<u1>* buf = MetadataFactory::new_array<u1>(loader_data,
160 manifest_size,
161 THREAD);
162 char* p = (char*)(buf->data());
163 memcpy(p, manifest, manifest_size);
164 ent->set_manifest(buf);
165 ent->_is_signed = false;
166 }
167 }
168 }
169 }
170
171 void SharedClassUtil::initialize(TRAPS) {
172 if (UseSharedSpaces) {
173 int size = FileMapInfo::get_number_of_shared_paths();
174 if (size > 0) {
175 SystemDictionaryShared::allocate_shared_data_arrays(size, THREAD);
176 if (!DumpSharedSpaces) {
177 FileMapHeaderExt* header = (FileMapHeaderExt*)FileMapInfo::current_info()->header();
178 ClassLoaderExt::init_paths_start_index(header->_app_class_paths_start_index);
179 ClassLoaderExt::init_app_module_paths_start_index(header->_app_module_paths_start_index);
180 }
181 }
182 }
183
184 if (DumpSharedSpaces) {
185 if (SharedArchiveConfigFile) {
186 read_extra_data(SharedArchiveConfigFile, THREAD);
187 }
188 }
189 }
190
191 void SharedClassUtil::read_extra_data(const char* filename, TRAPS) {
192 HashtableTextDump reader(filename);
193 reader.check_version("VERSION: 1.0");
194
195 while (reader.remain() > 0) {
196 int utf8_length;
197 int prefix_type = reader.scan_prefix(&utf8_length);
198 ResourceMark rm(THREAD);
199 char* utf8_buffer = NEW_RESOURCE_ARRAY(char, utf8_length);
200 reader.get_utf8(utf8_buffer, utf8_length);
201
202 if (prefix_type == HashtableTextDump::SymbolPrefix) {
212 bool SharedClassUtil::is_classpath_entry_signed(int classpath_index) {
213 assert(classpath_index >= 0, "Sanity");
214 SharedClassPathEntryExt* ent = (SharedClassPathEntryExt*)
215 FileMapInfo::shared_path(classpath_index);
216 return ent->_is_signed;
217 }
218
219 void FileMapHeaderExt::populate(FileMapInfo* mapinfo, size_t alignment) {
220 FileMapInfo::FileMapHeader::populate(mapinfo, alignment);
221
222 ClassLoaderExt::finalize_shared_paths_misc_info();
223 _app_class_paths_start_index = ClassLoaderExt::app_class_paths_start_index();
224 _app_module_paths_start_index = ClassLoaderExt::app_module_paths_start_index();
225
226 _verify_local = BytecodeVerificationLocal;
227 _verify_remote = BytecodeVerificationRemote;
228 _has_platform_or_app_classes = ClassLoaderExt::has_platform_or_app_classes();
229 }
230
231 bool FileMapHeaderExt::validate() {
232 if (UseAppCDS) {
233 const char* prop = Arguments::get_property("java.system.class.loader");
234 if (prop != NULL) {
235 warning("UseAppCDS is disabled because the java.system.class.loader property is specified (value = \"%s\"). "
236 "To enable UseAppCDS, this property must be not be set", prop);
237 UseAppCDS = false;
238 }
239 }
240
241 if (!FileMapInfo::FileMapHeader::validate()) {
242 return false;
243 }
244
245 // For backwards compatibility, we don't check the verification setting
246 // if the archive only contains system classes.
247 if (_has_platform_or_app_classes &&
248 ((!_verify_local && BytecodeVerificationLocal) ||
249 (!_verify_remote && BytecodeVerificationRemote))) {
250 FileMapInfo::fail_continue("The shared archive file was created with less restrictive "
251 "verification setting than the current setting.");
252 return false;
253 }
254
255 return true;
256 }
|
156 } else {
157 // Copy the manifest into the shared archive
158 manifest = ClassLoaderExt::read_raw_manifest(cpe, &manifest_size, CHECK);
159 Array<u1>* buf = MetadataFactory::new_array<u1>(loader_data,
160 manifest_size,
161 THREAD);
162 char* p = (char*)(buf->data());
163 memcpy(p, manifest, manifest_size);
164 ent->set_manifest(buf);
165 ent->_is_signed = false;
166 }
167 }
168 }
169 }
170
171 void SharedClassUtil::initialize(TRAPS) {
172 if (UseSharedSpaces) {
173 int size = FileMapInfo::get_number_of_shared_paths();
174 if (size > 0) {
175 SystemDictionaryShared::allocate_shared_data_arrays(size, THREAD);
176 FileMapHeaderExt* header = (FileMapHeaderExt*)FileMapInfo::current_info()->header();
177 ClassLoaderExt::init_paths_start_index(header->_app_class_paths_start_index);
178 ClassLoaderExt::init_app_module_paths_start_index(header->_app_module_paths_start_index);
179 }
180 }
181
182 if (DumpSharedSpaces) {
183 if (SharedArchiveConfigFile) {
184 read_extra_data(SharedArchiveConfigFile, THREAD);
185 }
186 }
187 }
188
189 void SharedClassUtil::read_extra_data(const char* filename, TRAPS) {
190 HashtableTextDump reader(filename);
191 reader.check_version("VERSION: 1.0");
192
193 while (reader.remain() > 0) {
194 int utf8_length;
195 int prefix_type = reader.scan_prefix(&utf8_length);
196 ResourceMark rm(THREAD);
197 char* utf8_buffer = NEW_RESOURCE_ARRAY(char, utf8_length);
198 reader.get_utf8(utf8_buffer, utf8_length);
199
200 if (prefix_type == HashtableTextDump::SymbolPrefix) {
210 bool SharedClassUtil::is_classpath_entry_signed(int classpath_index) {
211 assert(classpath_index >= 0, "Sanity");
212 SharedClassPathEntryExt* ent = (SharedClassPathEntryExt*)
213 FileMapInfo::shared_path(classpath_index);
214 return ent->_is_signed;
215 }
216
217 void FileMapHeaderExt::populate(FileMapInfo* mapinfo, size_t alignment) {
218 FileMapInfo::FileMapHeader::populate(mapinfo, alignment);
219
220 ClassLoaderExt::finalize_shared_paths_misc_info();
221 _app_class_paths_start_index = ClassLoaderExt::app_class_paths_start_index();
222 _app_module_paths_start_index = ClassLoaderExt::app_module_paths_start_index();
223
224 _verify_local = BytecodeVerificationLocal;
225 _verify_remote = BytecodeVerificationRemote;
226 _has_platform_or_app_classes = ClassLoaderExt::has_platform_or_app_classes();
227 }
228
229 bool FileMapHeaderExt::validate() {
230 if (!FileMapInfo::FileMapHeader::validate()) {
231 return false;
232 }
233
234 // This must be done after header validation because it might change the
235 // header data
236 const char* prop = Arguments::get_property("java.system.class.loader");
237 if (prop != NULL) {
238 warning("Archived non-system classes are disabled because the "
239 "java.system.class.loader property is specified (value = \"%s\"). "
240 "To use archived non-system classes, this property must be not be set", prop);
241 _has_platform_or_app_classes = false;
242 }
243
244 // For backwards compatibility, we don't check the verification setting
245 // if the archive only contains system classes.
246 if (_has_platform_or_app_classes &&
247 ((!_verify_local && BytecodeVerificationLocal) ||
248 (!_verify_remote && BytecodeVerificationRemote))) {
249 FileMapInfo::fail_continue("The shared archive file was created with less restrictive "
250 "verification setting than the current setting.");
251 return false;
252 }
253
254 return true;
255 }
|