< prev index next >

src/hotspot/share/classfile/classListParser.cpp

Print this page




 266       jio_fprintf(defaultStream::error_stream(), "%s", " ");
 267     }
 268     jio_fprintf(defaultStream::error_stream(), "^\n");
 269   }
 270 
 271   vm_exit_during_initialization("class list format error.", NULL);
 272   va_end(ap);
 273 }
 274 
 275 // This function is used for loading classes for customized class loaders
 276 // during archive dumping.
 277 InstanceKlass* ClassListParser::load_class_from_source(Symbol* class_name, TRAPS) {
 278 #if !(defined(_LP64) && (defined(LINUX)|| defined(SOLARIS) || defined(AIX)))
 279   // The only supported platforms are: (1) Linux/64-bit; (2) Solaris/64-bit; (3) AIX/64-bit
 280   //
 281   // This #if condition should be in sync with the areCustomLoadersSupportedForCDS
 282   // method in test/lib/jdk/test/lib/Platform.java.
 283   error("AppCDS custom class loaders not supported on this platform");
 284 #endif
 285 
 286   assert(UseAppCDS, "must be");
 287   if (!is_super_specified()) {
 288     error("If source location is specified, super class must be also specified");
 289   }
 290   if (!is_id_specified()) {
 291     error("If source location is specified, id must be also specified");
 292   }
 293   InstanceKlass* k = ClassLoaderExt::load_class(class_name, _source, THREAD);
 294 
 295   if (strncmp(_class_name, "java/", 5) == 0) {
 296     log_info(cds)("Prohibited package for non-bootstrap classes: %s.class from %s",
 297           _class_name, _source);
 298     return NULL;
 299   }
 300 
 301   if (k != NULL) {
 302     if (k->local_interfaces()->length() != _interfaces->length()) {
 303       print_specified_interfaces();
 304       print_actual_interfaces(k);
 305       error("The number of interfaces (%d) specified in class list does not match the class file (%d)",
 306             _interfaces->length(), k->local_interfaces()->length());


 366       klass = java_lang_Class::as_Klass(obj);
 367     } else { // load classes in bootclasspath/a
 368       if (HAS_PENDING_EXCEPTION) {
 369         CLEAR_PENDING_EXCEPTION;
 370       }
 371 
 372       if (non_array) {
 373         Klass* k = SystemDictionary::resolve_or_null(class_name_symbol, CHECK_NULL);
 374         if (k != NULL) {
 375           klass = k;
 376         } else {
 377           if (!HAS_PENDING_EXCEPTION) {
 378             THROW_NULL(vmSymbols::java_lang_ClassNotFoundException());
 379           }
 380         }
 381       }
 382     }
 383   } else {
 384     // If "source:" tag is specified, all super class and super interfaces must be specified in the
 385     // class list file.
 386     if (UseAppCDS) {
 387       klass = load_class_from_source(class_name_symbol, CHECK_NULL);
 388     }
 389   }
 390 
 391   if (klass != NULL && klass->is_instance_klass() && is_id_specified()) {
 392     InstanceKlass* ik = InstanceKlass::cast(klass);
 393     int id = this->id();
 394     SystemDictionaryShared::update_shared_entry(ik, id);
 395     InstanceKlass* old = table()->lookup(id);
 396     if (old != NULL && old != ik) {
 397       error("Duplicated ID %d for class %s", id, _class_name);
 398     }
 399     table()->add(id, ik);
 400   }
 401 
 402   return klass;
 403 }
 404 
 405 bool ClassListParser::is_loading_from_source() {
 406   return (_source != NULL);
 407 }
 408 




 266       jio_fprintf(defaultStream::error_stream(), "%s", " ");
 267     }
 268     jio_fprintf(defaultStream::error_stream(), "^\n");
 269   }
 270 
 271   vm_exit_during_initialization("class list format error.", NULL);
 272   va_end(ap);
 273 }
 274 
 275 // This function is used for loading classes for customized class loaders
 276 // during archive dumping.
 277 InstanceKlass* ClassListParser::load_class_from_source(Symbol* class_name, TRAPS) {
 278 #if !(defined(_LP64) && (defined(LINUX)|| defined(SOLARIS) || defined(AIX)))
 279   // The only supported platforms are: (1) Linux/64-bit; (2) Solaris/64-bit; (3) AIX/64-bit
 280   //
 281   // This #if condition should be in sync with the areCustomLoadersSupportedForCDS
 282   // method in test/lib/jdk/test/lib/Platform.java.
 283   error("AppCDS custom class loaders not supported on this platform");
 284 #endif
 285 

 286   if (!is_super_specified()) {
 287     error("If source location is specified, super class must be also specified");
 288   }
 289   if (!is_id_specified()) {
 290     error("If source location is specified, id must be also specified");
 291   }
 292   InstanceKlass* k = ClassLoaderExt::load_class(class_name, _source, THREAD);
 293 
 294   if (strncmp(_class_name, "java/", 5) == 0) {
 295     log_info(cds)("Prohibited package for non-bootstrap classes: %s.class from %s",
 296           _class_name, _source);
 297     return NULL;
 298   }
 299 
 300   if (k != NULL) {
 301     if (k->local_interfaces()->length() != _interfaces->length()) {
 302       print_specified_interfaces();
 303       print_actual_interfaces(k);
 304       error("The number of interfaces (%d) specified in class list does not match the class file (%d)",
 305             _interfaces->length(), k->local_interfaces()->length());


 365       klass = java_lang_Class::as_Klass(obj);
 366     } else { // load classes in bootclasspath/a
 367       if (HAS_PENDING_EXCEPTION) {
 368         CLEAR_PENDING_EXCEPTION;
 369       }
 370 
 371       if (non_array) {
 372         Klass* k = SystemDictionary::resolve_or_null(class_name_symbol, CHECK_NULL);
 373         if (k != NULL) {
 374           klass = k;
 375         } else {
 376           if (!HAS_PENDING_EXCEPTION) {
 377             THROW_NULL(vmSymbols::java_lang_ClassNotFoundException());
 378           }
 379         }
 380       }
 381     }
 382   } else {
 383     // If "source:" tag is specified, all super class and super interfaces must be specified in the
 384     // class list file.

 385     klass = load_class_from_source(class_name_symbol, CHECK_NULL);

 386   }
 387 
 388   if (klass != NULL && klass->is_instance_klass() && is_id_specified()) {
 389     InstanceKlass* ik = InstanceKlass::cast(klass);
 390     int id = this->id();
 391     SystemDictionaryShared::update_shared_entry(ik, id);
 392     InstanceKlass* old = table()->lookup(id);
 393     if (old != NULL && old != ik) {
 394       error("Duplicated ID %d for class %s", id, _class_name);
 395     }
 396     table()->add(id, ik);
 397   }
 398 
 399   return klass;
 400 }
 401 
 402 bool ClassListParser::is_loading_from_source() {
 403   return (_source != NULL);
 404 }
 405 


< prev index next >