< prev index next >

src/hotspot/share/cds/classListParser.cpp

Print this page

450   // The only supported platforms are: (1) Linux/64-bit and (2) Solaris/64-bit and
451   // (3) MacOSX/64-bit
452   // This #if condition should be in sync with the areCustomLoadersSupportedForCDS
453   // method in test/lib/jdk/test/lib/Platform.java.
454   error("AppCDS custom class loaders not supported on this platform");
455 #endif
456 
457   if (!is_super_specified()) {
458     error("If source location is specified, super class must be also specified");
459   }
460   if (!is_id_specified()) {
461     error("If source location is specified, id must be also specified");
462   }
463   if (strncmp(_class_name, "java/", 5) == 0) {
464     log_info(cds)("Prohibited package for non-bootstrap classes: %s.class from %s",
465           _class_name, _source);
466     THROW_NULL(vmSymbols::java_lang_ClassNotFoundException());
467   }
468 
469   InstanceKlass* k = UnregisteredClasses::load_class(class_name, _source, CHECK_NULL);
470   if (k->local_interfaces()->length() != _interfaces->length()) {






































471     print_specified_interfaces();
472     print_actual_interfaces(k);
473     error("The number of interfaces (%d) specified in class list does not match the class file (%d)",
474           _interfaces->length(), k->local_interfaces()->length());
475   }
476 
477   assert(k->is_shared_unregistered_class(), "must be");
478 
479   bool added = SystemDictionaryShared::add_unregistered_class(THREAD, k);
480   if (!added) {
481     // We allow only a single unregistered class for each unique name.
482     error("Duplicated class %s", _class_name);
483   }
484 
485   return k;
486 }
487 
488 void ClassListParser::populate_cds_indy_info(const constantPoolHandle &pool, int cp_index, CDSIndyInfo* cii, TRAPS) {
489   // Caller needs to allocate ResourceMark.
490   int type_index = pool->bootstrap_name_and_type_ref_index_at(cp_index);
491   int name_index = pool->name_ref_index_at(type_index);
492   cii->add_item(pool->symbol_at(name_index)->as_C_string());
493   int sig_index = pool->signature_ref_index_at(type_index);
494   cii->add_item(pool->symbol_at(sig_index)->as_C_string());

678 
679 InstanceKlass* ClassListParser::lookup_super_for_current_class(Symbol* super_name) {
680   if (!is_loading_from_source()) {
681     return NULL;
682   }
683 
684   InstanceKlass* k = lookup_class_by_id(super());
685   if (super_name != k->name()) {
686     error("The specified super class %s (id %d) does not match actual super class %s",
687           k->name()->as_klass_external_name(), super(),
688           super_name->as_klass_external_name());
689   }
690   return k;
691 }
692 
693 InstanceKlass* ClassListParser::lookup_interface_for_current_class(Symbol* interface_name) {
694   if (!is_loading_from_source()) {
695     return NULL;
696   }
697 











698   const int n = _interfaces->length();
699   if (n == 0) {
700     error("Class %s implements the interface %s, but no interface has been specified in the input line",
701           _class_name, interface_name->as_klass_external_name());
702     ShouldNotReachHere();
703   }
704 
705   int i;
706   for (i=0; i<n; i++) {
707     InstanceKlass* k = lookup_class_by_id(_interfaces->at(i));
708     if (interface_name == k->name()) {
709       return k;
710     }
711   }
712 
713   // interface_name is not specified by the "interfaces:" keyword.
714   print_specified_interfaces();
715   error("The interface %s implemented by class %s does not match any of the specified interface IDs",
716         interface_name->as_klass_external_name(), _class_name);
717   ShouldNotReachHere();

450   // The only supported platforms are: (1) Linux/64-bit and (2) Solaris/64-bit and
451   // (3) MacOSX/64-bit
452   // This #if condition should be in sync with the areCustomLoadersSupportedForCDS
453   // method in test/lib/jdk/test/lib/Platform.java.
454   error("AppCDS custom class loaders not supported on this platform");
455 #endif
456 
457   if (!is_super_specified()) {
458     error("If source location is specified, super class must be also specified");
459   }
460   if (!is_id_specified()) {
461     error("If source location is specified, id must be also specified");
462   }
463   if (strncmp(_class_name, "java/", 5) == 0) {
464     log_info(cds)("Prohibited package for non-bootstrap classes: %s.class from %s",
465           _class_name, _source);
466     THROW_NULL(vmSymbols::java_lang_ClassNotFoundException());
467   }
468 
469   InstanceKlass* k = UnregisteredClasses::load_class(class_name, _source, CHECK_NULL);
470   const int actual_num_interfaces = k->local_interfaces()->length();
471   const int specified_num_interfaces = _interfaces->length(); // specified in classlist
472   int expected_num_interfaces = actual_num_interfaces, i;
473 
474   {
475     bool identity_object_implemented = false;
476     bool identity_object_specified = false;
477     bool primitive_object_implemented = false;
478     bool primitive_object_specified = false;
479     for (i = 0; i < actual_num_interfaces; i++) {
480       if (k->local_interfaces()->at(i) == vmClasses::IdentityObject_klass()) {
481         identity_object_implemented = true;
482         break;
483       }
484       if (k->local_interfaces()->at(i) == vmClasses::PrimitiveObject_klass()) {
485         primitive_object_implemented = true;
486         break;
487       }
488     }
489     for (i = 0; i < specified_num_interfaces; i++) {
490       if (lookup_class_by_id(_interfaces->at(i)) == vmClasses::IdentityObject_klass()) {
491         identity_object_specified = true;
492         break;
493       }
494       if (lookup_class_by_id(_interfaces->at(i)) == vmClasses::PrimitiveObject_klass()) {
495         primitive_object_specified = true;
496         break;
497       }
498     }
499 
500     if ( (identity_object_implemented  && !identity_object_specified) ||
501          (primitive_object_implemented && !primitive_object_specified) ){
502       // Backwards compatibility -- older classlists do not know about
503       // java.lang.IdentityObject or java.lang.PrimitiveObject
504       expected_num_interfaces--;
505     }
506   }
507 
508   if (specified_num_interfaces != expected_num_interfaces) {
509     print_specified_interfaces();
510     print_actual_interfaces(k);
511     error("The number of interfaces (%d) specified in class list does not match the class file (%d)",
512           specified_num_interfaces, expected_num_interfaces);
513   }
514 
515   assert(k->is_shared_unregistered_class(), "must be");
516 
517   bool added = SystemDictionaryShared::add_unregistered_class(THREAD, k);
518   if (!added) {
519     // We allow only a single unregistered class for each unique name.
520     error("Duplicated class %s", _class_name);
521   }
522 
523   return k;
524 }
525 
526 void ClassListParser::populate_cds_indy_info(const constantPoolHandle &pool, int cp_index, CDSIndyInfo* cii, TRAPS) {
527   // Caller needs to allocate ResourceMark.
528   int type_index = pool->bootstrap_name_and_type_ref_index_at(cp_index);
529   int name_index = pool->name_ref_index_at(type_index);
530   cii->add_item(pool->symbol_at(name_index)->as_C_string());
531   int sig_index = pool->signature_ref_index_at(type_index);
532   cii->add_item(pool->symbol_at(sig_index)->as_C_string());

716 
717 InstanceKlass* ClassListParser::lookup_super_for_current_class(Symbol* super_name) {
718   if (!is_loading_from_source()) {
719     return NULL;
720   }
721 
722   InstanceKlass* k = lookup_class_by_id(super());
723   if (super_name != k->name()) {
724     error("The specified super class %s (id %d) does not match actual super class %s",
725           k->name()->as_klass_external_name(), super(),
726           super_name->as_klass_external_name());
727   }
728   return k;
729 }
730 
731 InstanceKlass* ClassListParser::lookup_interface_for_current_class(Symbol* interface_name) {
732   if (!is_loading_from_source()) {
733     return NULL;
734   }
735 
736   if (interface_name == vmSymbols::java_lang_IdentityObject()) {
737     // Backwards compatibility -- older classlists do not know about
738     // java.lang.IdentityObject.
739     return vmClasses::IdentityObject_klass();
740   }
741   if (interface_name == vmSymbols::java_lang_PrimitiveObject()) {
742     // Backwards compatibility -- older classlists do not know about
743     // java.lang.PrimitiveObject.
744     return vmClasses::PrimitiveObject_klass();
745   }
746 
747   const int n = _interfaces->length();
748   if (n == 0) {
749     error("Class %s implements the interface %s, but no interface has been specified in the input line",
750           _class_name, interface_name->as_klass_external_name());
751     ShouldNotReachHere();
752   }
753 
754   int i;
755   for (i=0; i<n; i++) {
756     InstanceKlass* k = lookup_class_by_id(_interfaces->at(i));
757     if (interface_name == k->name()) {
758       return k;
759     }
760   }
761 
762   // interface_name is not specified by the "interfaces:" keyword.
763   print_specified_interfaces();
764   error("The interface %s implemented by class %s does not match any of the specified interface IDs",
765         interface_name->as_klass_external_name(), _class_name);
766   ShouldNotReachHere();
< prev index next >