1266
1267 e = _first_append_entry;
1268 while (e != NULL) {
1269 stream = e->open_stream(file_name, CHECK_NULL);
1270 if (NULL != stream) {
1271 break;
1272 }
1273 e = e->next();
1274 ++classpath_index;
1275 }
1276 }
1277
1278 if (NULL == stream) {
1279 return NULL;
1280 }
1281
1282 stream->set_verify(ClassLoaderExt::should_verify(classpath_index));
1283
1284 ClassLoaderData* loader_data = ClassLoaderData::the_null_class_loader_data();
1285 Handle protection_domain;
1286
1287 InstanceKlass* result = KlassFactory::create_from_stream(stream,
1288 name,
1289 loader_data,
1290 protection_domain,
1291 NULL, // unsafe_anonymous_host
1292 NULL, // cp_patches
1293 THREAD);
1294 if (HAS_PENDING_EXCEPTION) {
1295 if (DumpSharedSpaces) {
1296 log_error(cds)("Preload Error: Failed to load %s", class_name);
1297 }
1298 return NULL;
1299 }
1300
1301 if (!add_package(result, classpath_index, THREAD)) {
1302 return NULL;
1303 }
1304
1305 return result;
1306 }
1307
1308 #if INCLUDE_CDS
1309 char* ClassLoader::skip_uri_protocol(char* source) {
1310 if (strncmp(source, "file:", 5) == 0) {
1311 // file: protocol path could start with file:/ or file:///
1312 // locate the char after all the forward slashes
1314 while (*(source + offset) == '/') {
1315 offset++;
1316 }
1317 source += offset;
1318 // for non-windows platforms, move back one char as the path begins with a '/'
1319 #ifndef _WINDOWS
1320 source -= 1;
1321 #endif
1322 } else if (strncmp(source, "jrt:/", 5) == 0) {
1323 source += 5;
1324 }
1325 return source;
1326 }
1327
1328 // Record the shared classpath index and loader type for classes loaded
1329 // by the builtin loaders at dump time.
1330 void ClassLoader::record_result(InstanceKlass* ik, const ClassFileStream* stream, TRAPS) {
1331 Arguments::assert_is_dumping_archive();
1332 assert(stream != NULL, "sanity");
1333
1334 if (ik->is_unsafe_anonymous()) {
1335 // We do not archive unsafe anonymous classes.
1336 return;
1337 }
1338
1339 oop loader = ik->class_loader();
1340 char* src = (char*)stream->source();
1341 if (src == NULL) {
1342 if (loader == NULL) {
1343 // JFR classes
1344 ik->set_shared_classpath_index(0);
1345 ik->set_shared_class_loader_type(ClassLoader::BOOT_LOADER);
1346 }
1347 return;
1348 }
1349
1350 assert(has_jrt_entry(), "CDS dumping does not support exploded JDK build");
1351
1352 ResourceMark rm(THREAD);
1353 int classpath_index = -1;
1354 PackageEntry* pkg_entry = ik->package();
1355
|
1266
1267 e = _first_append_entry;
1268 while (e != NULL) {
1269 stream = e->open_stream(file_name, CHECK_NULL);
1270 if (NULL != stream) {
1271 break;
1272 }
1273 e = e->next();
1274 ++classpath_index;
1275 }
1276 }
1277
1278 if (NULL == stream) {
1279 return NULL;
1280 }
1281
1282 stream->set_verify(ClassLoaderExt::should_verify(classpath_index));
1283
1284 ClassLoaderData* loader_data = ClassLoaderData::the_null_class_loader_data();
1285 Handle protection_domain;
1286 ClassLoadInfo cl_info(protection_domain);
1287
1288 InstanceKlass* result = KlassFactory::create_from_stream(stream,
1289 name,
1290 loader_data,
1291 cl_info,
1292 THREAD);
1293 if (HAS_PENDING_EXCEPTION) {
1294 if (DumpSharedSpaces) {
1295 log_error(cds)("Preload Error: Failed to load %s", class_name);
1296 }
1297 return NULL;
1298 }
1299
1300 if (!add_package(result, classpath_index, THREAD)) {
1301 return NULL;
1302 }
1303
1304 return result;
1305 }
1306
1307 #if INCLUDE_CDS
1308 char* ClassLoader::skip_uri_protocol(char* source) {
1309 if (strncmp(source, "file:", 5) == 0) {
1310 // file: protocol path could start with file:/ or file:///
1311 // locate the char after all the forward slashes
1313 while (*(source + offset) == '/') {
1314 offset++;
1315 }
1316 source += offset;
1317 // for non-windows platforms, move back one char as the path begins with a '/'
1318 #ifndef _WINDOWS
1319 source -= 1;
1320 #endif
1321 } else if (strncmp(source, "jrt:/", 5) == 0) {
1322 source += 5;
1323 }
1324 return source;
1325 }
1326
1327 // Record the shared classpath index and loader type for classes loaded
1328 // by the builtin loaders at dump time.
1329 void ClassLoader::record_result(InstanceKlass* ik, const ClassFileStream* stream, TRAPS) {
1330 Arguments::assert_is_dumping_archive();
1331 assert(stream != NULL, "sanity");
1332
1333 if (ik->is_hidden() || ik->is_unsafe_anonymous()) {
1334 // We do not archive hidden or unsafe anonymous classes.
1335 return;
1336 }
1337
1338 oop loader = ik->class_loader();
1339 char* src = (char*)stream->source();
1340 if (src == NULL) {
1341 if (loader == NULL) {
1342 // JFR classes
1343 ik->set_shared_classpath_index(0);
1344 ik->set_shared_class_loader_type(ClassLoader::BOOT_LOADER);
1345 }
1346 return;
1347 }
1348
1349 assert(has_jrt_entry(), "CDS dumping does not support exploded JDK build");
1350
1351 ResourceMark rm(THREAD);
1352 int classpath_index = -1;
1353 PackageEntry* pkg_entry = ik->package();
1354
|