494 // This #if condition should be in sync with the areCustomLoadersSupportedForCDS
495 // method in test/lib/jdk/test/lib/Platform.java.
496 error("AppCDS custom class loaders not supported on this platform");
497 #endif
498
499 if (!is_super_specified()) {
500 error("If source location is specified, super class must be also specified");
501 }
502 if (!is_id_specified()) {
503 error("If source location is specified, id must be also specified");
504 }
505 if (strncmp(_class_name, "java/", 5) == 0) {
506 log_info(cds)("Prohibited package for non-bootstrap classes: %s.class from %s",
507 _class_name, _source);
508 THROW_NULL(vmSymbols::java_lang_ClassNotFoundException());
509 }
510
511 ResourceMark rm;
512 char * source_path = os::strdup_check_oom(ClassLoader::uri_to_path(_source));
513 InstanceKlass* k = UnregisteredClasses::load_class(class_name, source_path, CHECK_NULL);
514 if (k->local_interfaces()->length() != _interfaces->length()) {
515 print_specified_interfaces();
516 print_actual_interfaces(k);
517 error("The number of interfaces (%d) specified in class list does not match the class file (%d)",
518 _interfaces->length(), k->local_interfaces()->length());
519 }
520
521 assert(k->is_shared_unregistered_class(), "must be");
522
523 bool added = SystemDictionaryShared::add_unregistered_class(THREAD, k);
524 if (!added) {
525 // We allow only a single unregistered class for each unique name.
526 error("Duplicated class %s", _class_name);
527 }
528
529 return k;
530 }
531
532 void ClassListParser::populate_cds_indy_info(const constantPoolHandle &pool, int cp_index, CDSIndyInfo* cii, TRAPS) {
533 // Caller needs to allocate ResourceMark.
534 int type_index = pool->bootstrap_name_and_type_ref_index_at(cp_index);
535 int name_index = pool->name_ref_index_at(type_index);
536 cii->add_item(pool->symbol_at(name_index)->as_C_string());
537 int sig_index = pool->signature_ref_index_at(type_index);
538 cii->add_item(pool->symbol_at(sig_index)->as_C_string());
|
494 // This #if condition should be in sync with the areCustomLoadersSupportedForCDS
495 // method in test/lib/jdk/test/lib/Platform.java.
496 error("AppCDS custom class loaders not supported on this platform");
497 #endif
498
499 if (!is_super_specified()) {
500 error("If source location is specified, super class must be also specified");
501 }
502 if (!is_id_specified()) {
503 error("If source location is specified, id must be also specified");
504 }
505 if (strncmp(_class_name, "java/", 5) == 0) {
506 log_info(cds)("Prohibited package for non-bootstrap classes: %s.class from %s",
507 _class_name, _source);
508 THROW_NULL(vmSymbols::java_lang_ClassNotFoundException());
509 }
510
511 ResourceMark rm;
512 char * source_path = os::strdup_check_oom(ClassLoader::uri_to_path(_source));
513 InstanceKlass* k = UnregisteredClasses::load_class(class_name, source_path, CHECK_NULL);
514 const int actual_num_interfaces = k->local_interfaces()->length();
515 const int specified_num_interfaces = _interfaces->length(); // specified in classlist
516 int expected_num_interfaces = actual_num_interfaces;
517
518 if (specified_num_interfaces != expected_num_interfaces) {
519 print_specified_interfaces();
520 print_actual_interfaces(k);
521 error("The number of interfaces (%d) specified in class list does not match the class file (%d)",
522 specified_num_interfaces, expected_num_interfaces);
523 }
524
525 assert(k->is_shared_unregistered_class(), "must be");
526
527 bool added = SystemDictionaryShared::add_unregistered_class(THREAD, k);
528 if (!added) {
529 // We allow only a single unregistered class for each unique name.
530 error("Duplicated class %s", _class_name);
531 }
532
533 return k;
534 }
535
536 void ClassListParser::populate_cds_indy_info(const constantPoolHandle &pool, int cp_index, CDSIndyInfo* cii, TRAPS) {
537 // Caller needs to allocate ResourceMark.
538 int type_index = pool->bootstrap_name_and_type_ref_index_at(cp_index);
539 int name_index = pool->name_ref_index_at(type_index);
540 cii->add_item(pool->symbol_at(name_index)->as_C_string());
541 int sig_index = pool->signature_ref_index_at(type_index);
542 cii->add_item(pool->symbol_at(sig_index)->as_C_string());
|