< prev index next >

src/hotspot/share/cds/classListParser.cpp

Print this page
@@ -465,15 +465,53 @@
            _class_name, _source);
      THROW_NULL(vmSymbols::java_lang_ClassNotFoundException());
    }
  
    InstanceKlass* k = UnregisteredClasses::load_class(class_name, _source, CHECK_NULL);
-   if (k->local_interfaces()->length() != _interfaces->length()) {
+   const int actual_num_interfaces = k->local_interfaces()->length();
+   const int specified_num_interfaces = _interfaces->length(); // specified in classlist
+   int expected_num_interfaces = actual_num_interfaces, i;
+ 
+   {
+     bool identity_object_implemented = false;
+     bool identity_object_specified = false;
+     bool primitive_object_implemented = false;
+     bool primitive_object_specified = false;
+     for (i = 0; i < actual_num_interfaces; i++) {
+       if (k->local_interfaces()->at(i) == vmClasses::IdentityObject_klass()) {
+         identity_object_implemented = true;
+         break;
+       }
+       if (k->local_interfaces()->at(i) == vmClasses::PrimitiveObject_klass()) {
+         primitive_object_implemented = true;
+         break;
+       }
+     }
+     for (i = 0; i < specified_num_interfaces; i++) {
+       if (lookup_class_by_id(_interfaces->at(i)) == vmClasses::IdentityObject_klass()) {
+         identity_object_specified = true;
+         break;
+       }
+       if (lookup_class_by_id(_interfaces->at(i)) == vmClasses::PrimitiveObject_klass()) {
+         primitive_object_specified = true;
+         break;
+       }
+     }
+ 
+     if ( (identity_object_implemented  && !identity_object_specified) ||
+          (primitive_object_implemented && !primitive_object_specified) ){
+       // Backwards compatibility -- older classlists do not know about
+       // java.lang.IdentityObject or java.lang.PrimitiveObject
+       expected_num_interfaces--;
+     }
+   }
+ 
+   if (specified_num_interfaces != expected_num_interfaces) {
      print_specified_interfaces();
      print_actual_interfaces(k);
      error("The number of interfaces (%d) specified in class list does not match the class file (%d)",
-           _interfaces->length(), k->local_interfaces()->length());
+           specified_num_interfaces, expected_num_interfaces);
    }
  
    assert(k->is_shared_unregistered_class(), "must be");
  
    bool added = SystemDictionaryShared::add_unregistered_class(THREAD, k);

@@ -693,10 +731,21 @@
  InstanceKlass* ClassListParser::lookup_interface_for_current_class(Symbol* interface_name) {
    if (!is_loading_from_source()) {
      return NULL;
    }
  
+   if (interface_name == vmSymbols::java_lang_IdentityObject()) {
+     // Backwards compatibility -- older classlists do not know about
+     // java.lang.IdentityObject.
+     return vmClasses::IdentityObject_klass();
+   }
+   if (interface_name == vmSymbols::java_lang_PrimitiveObject()) {
+     // Backwards compatibility -- older classlists do not know about
+     // java.lang.PrimitiveObject.
+     return vmClasses::PrimitiveObject_klass();
+   }
+ 
    const int n = _interfaces->length();
    if (n == 0) {
      error("Class %s implements the interface %s, but no interface has been specified in the input line",
            _class_name, interface_name->as_klass_external_name());
      ShouldNotReachHere();
< prev index next >