< prev index next >

src/hotspot/share/classfile/classLoader.cpp

Print this page




1283 
1284     e = _first_append_entry;
1285     while (e != NULL) {
1286       stream = e->open_stream(file_name, CHECK_NULL);
1287       if (NULL != stream) {
1288         break;
1289       }
1290       e = e->next();
1291       ++classpath_index;
1292     }
1293   }
1294 
1295   if (NULL == stream) {
1296     return NULL;
1297   }
1298 
1299   stream->set_verify(ClassLoaderExt::should_verify(classpath_index));
1300 
1301   ClassLoaderData* loader_data = ClassLoaderData::the_null_class_loader_data();
1302   Handle protection_domain;

1303 
1304   InstanceKlass* result = KlassFactory::create_from_stream(stream,
1305                                                            name,
1306                                                            loader_data,
1307                                                            protection_domain,
1308                                                            NULL, // unsafe_anonymous_host
1309                                                            NULL, // cp_patches
1310                                                            THREAD);
1311   if (HAS_PENDING_EXCEPTION) {
1312     if (DumpSharedSpaces) {
1313       log_error(cds)("Preload Error: Failed to load %s", class_name);
1314     }
1315     return NULL;
1316   }
1317 
1318   if (!add_package(file_name, classpath_index, THREAD)) {
1319     return NULL;
1320   }
1321 
1322   return result;
1323 }
1324 
1325 #if INCLUDE_CDS
1326 char* ClassLoader::skip_uri_protocol(char* source) {
1327   if (strncmp(source, "file:", 5) == 0) {
1328     // file: protocol path could start with file:/ or file:///
1329     // locate the char after all the forward slashes


1331     while (*(source + offset) == '/') {
1332         offset++;
1333     }
1334     source += offset;
1335   // for non-windows platforms, move back one char as the path begins with a '/'
1336 #ifndef _WINDOWS
1337     source -= 1;
1338 #endif
1339   } else if (strncmp(source, "jrt:/", 5) == 0) {
1340     source += 5;
1341   }
1342   return source;
1343 }
1344 
1345 // Record the shared classpath index and loader type for classes loaded
1346 // by the builtin loaders at dump time.
1347 void ClassLoader::record_result(InstanceKlass* ik, const ClassFileStream* stream, TRAPS) {
1348   Arguments::assert_is_dumping_archive();
1349   assert(stream != NULL, "sanity");
1350 
1351   if (ik->is_unsafe_anonymous()) {
1352     // We do not archive unsafe anonymous classes.
1353     return;
1354   }
1355 
1356   oop loader = ik->class_loader();
1357   char* src = (char*)stream->source();
1358   if (src == NULL) {
1359     if (loader == NULL) {
1360       // JFR classes
1361       ik->set_shared_classpath_index(0);
1362       ik->set_class_loader_type(ClassLoader::BOOT_LOADER);
1363     }
1364     return;
1365   }
1366 
1367   assert(has_jrt_entry(), "CDS dumping does not support exploded JDK build");
1368 
1369   ResourceMark rm(THREAD);
1370   int classpath_index = -1;
1371   PackageEntry* pkg_entry = ik->package();
1372 




1283 
1284     e = _first_append_entry;
1285     while (e != NULL) {
1286       stream = e->open_stream(file_name, CHECK_NULL);
1287       if (NULL != stream) {
1288         break;
1289       }
1290       e = e->next();
1291       ++classpath_index;
1292     }
1293   }
1294 
1295   if (NULL == stream) {
1296     return NULL;
1297   }
1298 
1299   stream->set_verify(ClassLoaderExt::should_verify(classpath_index));
1300 
1301   ClassLoaderData* loader_data = ClassLoaderData::the_null_class_loader_data();
1302   Handle protection_domain;
1303   ClassLoadInfo cl_info(protection_domain);
1304 
1305   InstanceKlass* result = KlassFactory::create_from_stream(stream,
1306                                                            name,
1307                                                            loader_data,
1308                                                            cl_info,


1309                                                            THREAD);
1310   if (HAS_PENDING_EXCEPTION) {
1311     if (DumpSharedSpaces) {
1312       log_error(cds)("Preload Error: Failed to load %s", class_name);
1313     }
1314     return NULL;
1315   }
1316 
1317   if (!add_package(file_name, classpath_index, THREAD)) {
1318     return NULL;
1319   }
1320 
1321   return result;
1322 }
1323 
1324 #if INCLUDE_CDS
1325 char* ClassLoader::skip_uri_protocol(char* source) {
1326   if (strncmp(source, "file:", 5) == 0) {
1327     // file: protocol path could start with file:/ or file:///
1328     // locate the char after all the forward slashes


1330     while (*(source + offset) == '/') {
1331         offset++;
1332     }
1333     source += offset;
1334   // for non-windows platforms, move back one char as the path begins with a '/'
1335 #ifndef _WINDOWS
1336     source -= 1;
1337 #endif
1338   } else if (strncmp(source, "jrt:/", 5) == 0) {
1339     source += 5;
1340   }
1341   return source;
1342 }
1343 
1344 // Record the shared classpath index and loader type for classes loaded
1345 // by the builtin loaders at dump time.
1346 void ClassLoader::record_result(InstanceKlass* ik, const ClassFileStream* stream, TRAPS) {
1347   Arguments::assert_is_dumping_archive();
1348   assert(stream != NULL, "sanity");
1349 
1350   if (ik->is_hidden() || ik->is_unsafe_anonymous()) {
1351     // We do not archive hidden or unsafe anonymous classes.
1352     return;
1353   }
1354 
1355   oop loader = ik->class_loader();
1356   char* src = (char*)stream->source();
1357   if (src == NULL) {
1358     if (loader == NULL) {
1359       // JFR classes
1360       ik->set_shared_classpath_index(0);
1361       ik->set_class_loader_type(ClassLoader::BOOT_LOADER);
1362     }
1363     return;
1364   }
1365 
1366   assert(has_jrt_entry(), "CDS dumping does not support exploded JDK build");
1367 
1368   ResourceMark rm(THREAD);
1369   int classpath_index = -1;
1370   PackageEntry* pkg_entry = ik->package();
1371 


< prev index next >