< prev index next >

src/hotspot/share/classfile/classLoader.cpp

Print this page




1365         break;
1366       }
1367       e = e->next();
1368       ++classpath_index;
1369     }
1370   }
1371 
1372   if (NULL == stream) {
1373     return NULL;
1374   }
1375 
1376   stream->set_verify(ClassLoaderExt::should_verify(classpath_index));
1377 
1378   ClassLoaderData* loader_data = ClassLoaderData::the_null_class_loader_data();
1379   Handle protection_domain;
1380 
1381   InstanceKlass* result = KlassFactory::create_from_stream(stream,
1382                                                            name,
1383                                                            loader_data,
1384                                                            protection_domain,
1385                                                            NULL, // unsafe_anonymous_host
1386                                                            NULL, // cp_patches




1387                                                            THREAD);
1388   if (HAS_PENDING_EXCEPTION) {
1389     if (DumpSharedSpaces) {
1390       tty->print_cr("Preload Error: Failed to load %s", class_name);
1391     }
1392     return NULL;
1393   }
1394 
1395   if (!add_package(file_name, classpath_index, THREAD)) {
1396     return NULL;
1397   }
1398 
1399   return result;
1400 }
1401 
1402 #if INCLUDE_CDS
1403 char* ClassLoader::skip_uri_protocol(char* source) {
1404   if (strncmp(source, "file:", 5) == 0) {
1405     // file: protocol path could start with file:/ or file:///
1406     // locate the char after all the forward slashes


1408     while (*(source + offset) == '/') {
1409         offset++;
1410     }
1411     source += offset;
1412   // for non-windows platforms, move back one char as the path begins with a '/'
1413 #ifndef _WINDOWS
1414     source -= 1;
1415 #endif
1416   } else if (strncmp(source, "jrt:/", 5) == 0) {
1417     source += 5;
1418   }
1419   return source;
1420 }
1421 
1422 // Record the shared classpath index and loader type for classes loaded
1423 // by the builtin loaders at dump time.
1424 void ClassLoader::record_result(InstanceKlass* ik, const ClassFileStream* stream, TRAPS) {
1425   assert(DumpSharedSpaces, "sanity");
1426   assert(stream != NULL, "sanity");
1427 
1428   if (ik->is_unsafe_anonymous()) {
1429     // We do not archive unsafe anonymous classes.
1430     return;
1431   }
1432 
1433   oop loader = ik->class_loader();
1434   char* src = (char*)stream->source();
1435   if (src == NULL) {
1436     if (loader == NULL) {
1437       // JFR classes
1438       ik->set_shared_classpath_index(0);
1439       ik->set_class_loader_type(ClassLoader::BOOT_LOADER);
1440     }
1441     return;
1442   }
1443 
1444   assert(has_jrt_entry(), "CDS dumping does not support exploded JDK build");
1445 
1446   ResourceMark rm(THREAD);
1447   int classpath_index = -1;
1448   PackageEntry* pkg_entry = ik->package();
1449 




1365         break;
1366       }
1367       e = e->next();
1368       ++classpath_index;
1369     }
1370   }
1371 
1372   if (NULL == stream) {
1373     return NULL;
1374   }
1375 
1376   stream->set_verify(ClassLoaderExt::should_verify(classpath_index));
1377 
1378   ClassLoaderData* loader_data = ClassLoaderData::the_null_class_loader_data();
1379   Handle protection_domain;
1380 
1381   InstanceKlass* result = KlassFactory::create_from_stream(stream,
1382                                                            name,
1383                                                            loader_data,
1384                                                            protection_domain,
1385                                                            NULL,  // unsafe_anonymous_host
1386                                                            NULL,  // cp_patches
1387                                                            false, // is_nonfindable
1388                                                            false, // can_access_vm_annotations
1389                                                            NULL,  // dynamic_nest_host
1390                                                            Handle(), // classData
1391                                                            THREAD);
1392   if (HAS_PENDING_EXCEPTION) {
1393     if (DumpSharedSpaces) {
1394       tty->print_cr("Preload Error: Failed to load %s", class_name);
1395     }
1396     return NULL;
1397   }
1398 
1399   if (!add_package(file_name, classpath_index, THREAD)) {
1400     return NULL;
1401   }
1402 
1403   return result;
1404 }
1405 
1406 #if INCLUDE_CDS
1407 char* ClassLoader::skip_uri_protocol(char* source) {
1408   if (strncmp(source, "file:", 5) == 0) {
1409     // file: protocol path could start with file:/ or file:///
1410     // locate the char after all the forward slashes


1412     while (*(source + offset) == '/') {
1413         offset++;
1414     }
1415     source += offset;
1416   // for non-windows platforms, move back one char as the path begins with a '/'
1417 #ifndef _WINDOWS
1418     source -= 1;
1419 #endif
1420   } else if (strncmp(source, "jrt:/", 5) == 0) {
1421     source += 5;
1422   }
1423   return source;
1424 }
1425 
1426 // Record the shared classpath index and loader type for classes loaded
1427 // by the builtin loaders at dump time.
1428 void ClassLoader::record_result(InstanceKlass* ik, const ClassFileStream* stream, TRAPS) {
1429   assert(DumpSharedSpaces, "sanity");
1430   assert(stream != NULL, "sanity");
1431 
1432   if (ik->is_nonfindable() || ik->is_unsafe_anonymous()) {
1433     // We do not archive nonfindable or unsafe anonymous classes.
1434     return;
1435   }
1436 
1437   oop loader = ik->class_loader();
1438   char* src = (char*)stream->source();
1439   if (src == NULL) {
1440     if (loader == NULL) {
1441       // JFR classes
1442       ik->set_shared_classpath_index(0);
1443       ik->set_class_loader_type(ClassLoader::BOOT_LOADER);
1444     }
1445     return;
1446   }
1447 
1448   assert(has_jrt_entry(), "CDS dumping does not support exploded JDK build");
1449 
1450   ResourceMark rm(THREAD);
1451   int classpath_index = -1;
1452   PackageEntry* pkg_entry = ik->package();
1453 


< prev index next >