< prev index next >

src/share/vm/classfile/classFileParser.cpp

Print this page




 404   int num_klasses = 0;
 405 
 406   // first verification pass - validate cross references
 407   // and fixup class and string constants
 408   for (index = 1; index < length; index++) {          // Index 0 is unused
 409     const jbyte tag = cp->tag_at(index).value();
 410     switch (tag) {
 411       case JVM_CONSTANT_Class:
 412       case JVM_CONSTANT_Value: {
 413         ShouldNotReachHere();     // Only JVM_CONSTANT_[Class|Value]Index should be present
 414         break;
 415       }
 416       case JVM_CONSTANT_Fieldref:
 417         // fall through
 418       case JVM_CONSTANT_Methodref:
 419         // fall through
 420       case JVM_CONSTANT_InterfaceMethodref: {
 421         if (!_need_verify) break;
 422         const int klass_ref_index = cp->klass_ref_index_at(index);
 423         const int name_and_type_ref_index = cp->name_and_type_ref_index_at(index);
 424         check_property(valid_klass_reference_at(klass_ref_index),



 425                        "Invalid constant pool index %u in class file %s",
 426                        klass_ref_index, CHECK);
 427         check_property(valid_cp_range(name_and_type_ref_index, length) &&
 428           cp->tag_at(name_and_type_ref_index).is_name_and_type(),
 429           "Invalid constant pool index %u in class file %s",
 430           name_and_type_ref_index, CHECK);
 431         break;
 432       }
 433       case JVM_CONSTANT_String: {
 434         ShouldNotReachHere();     // Only JVM_CONSTANT_StringIndex should be present
 435         break;
 436       }
 437       case JVM_CONSTANT_Integer:
 438         break;
 439       case JVM_CONSTANT_Float:
 440         break;
 441       case JVM_CONSTANT_Long:
 442       case JVM_CONSTANT_Double: {
 443         index++;
 444         check_property(


 464       case JVM_CONSTANT_UnresolvedClass:         // fall-through
 465       case JVM_CONSTANT_UnresolvedClassInError: {
 466         ShouldNotReachHere();     // Only JVM_CONSTANT_ClassIndex should be present
 467         break;
 468       }
 469       case JVM_CONSTANT_ClassIndex: {
 470         const int class_index = cp->klass_index_at(index);
 471         check_property(valid_symbol_at(class_index),
 472           "Invalid constant pool index %u in class file %s",
 473           class_index, CHECK);
 474 
 475         Symbol* const name = cp->symbol_at(class_index);
 476         const unsigned int name_len = name->utf8_length();
 477 
 478         // check explicitly for ;Qjava/lang/__Value;
 479         if (name_len == 20 &&
 480             name->equals(";Qjava/lang/__Value;")) {
 481             cp->symbol_at_put(class_index, vmSymbols::java_lang____Value());
 482             cp->unresolved_value_type_at_put(index, class_index, num_klasses++);
 483         } else if (EnableValhalla || EnableMVT) {

 484           // check for a value type
 485           // check for name > 3 to rule out ";Q;" where no name is present
 486           if (name_len != 0 &&
 487               name_len > 3 &&
 488               name->byte_at(0) == ';' &&
 489               name->byte_at(1) == 'Q' &&
 490               name->byte_at(name_len-1) == ';') {
 491             Symbol* const strippedsym = SymbolTable::new_symbol(name, 2, name_len-1, CHECK);
 492             assert(strippedsym != NULL, "failure to create value type stripped name");
 493             cp->symbol_at_put(class_index, strippedsym);
 494             cp->unresolved_value_type_at_put(index, class_index, num_klasses++);
 495           } else {
 496             cp->unresolved_klass_at_put(index, class_index, num_klasses++);
 497           }
 498         } else {
 499           cp->unresolved_klass_at_put(index, class_index, num_klasses++);
 500         }
 501         break;
 502       }
 503       case JVM_CONSTANT_ValueIndex: {
 504         const int class_index = cp->value_type_index_at(index);
 505         check_property(valid_symbol_at(class_index),
 506           "Invalid constant pool index %u in class file %s",
 507           class_index, CHECK);
 508         cp->unresolved_value_type_at_put(index, class_index, num_klasses++);
 509         break;
 510       }




 404   int num_klasses = 0;
 405 
 406   // first verification pass - validate cross references
 407   // and fixup class and string constants
 408   for (index = 1; index < length; index++) {          // Index 0 is unused
 409     const jbyte tag = cp->tag_at(index).value();
 410     switch (tag) {
 411       case JVM_CONSTANT_Class:
 412       case JVM_CONSTANT_Value: {
 413         ShouldNotReachHere();     // Only JVM_CONSTANT_[Class|Value]Index should be present
 414         break;
 415       }
 416       case JVM_CONSTANT_Fieldref:
 417         // fall through
 418       case JVM_CONSTANT_Methodref:
 419         // fall through
 420       case JVM_CONSTANT_InterfaceMethodref: {
 421         if (!_need_verify) break;
 422         const int klass_ref_index = cp->klass_ref_index_at(index);
 423         const int name_and_type_ref_index = cp->name_and_type_ref_index_at(index);
 424         check_property(valid_klass_reference_at(klass_ref_index) ||
 425                        (valid_value_type_reference_at(klass_ref_index) &&
 426                         ((EnableMVT && (tag == JVM_CONSTANT_Fieldref)) ||
 427                          EnableValhalla)),
 428                        "Invalid constant pool index %u in class file %s",
 429                        klass_ref_index, CHECK);
 430         check_property(valid_cp_range(name_and_type_ref_index, length) &&
 431           cp->tag_at(name_and_type_ref_index).is_name_and_type(),
 432           "Invalid constant pool index %u in class file %s",
 433           name_and_type_ref_index, CHECK);
 434         break;
 435       }
 436       case JVM_CONSTANT_String: {
 437         ShouldNotReachHere();     // Only JVM_CONSTANT_StringIndex should be present
 438         break;
 439       }
 440       case JVM_CONSTANT_Integer:
 441         break;
 442       case JVM_CONSTANT_Float:
 443         break;
 444       case JVM_CONSTANT_Long:
 445       case JVM_CONSTANT_Double: {
 446         index++;
 447         check_property(


 467       case JVM_CONSTANT_UnresolvedClass:         // fall-through
 468       case JVM_CONSTANT_UnresolvedClassInError: {
 469         ShouldNotReachHere();     // Only JVM_CONSTANT_ClassIndex should be present
 470         break;
 471       }
 472       case JVM_CONSTANT_ClassIndex: {
 473         const int class_index = cp->klass_index_at(index);
 474         check_property(valid_symbol_at(class_index),
 475           "Invalid constant pool index %u in class file %s",
 476           class_index, CHECK);
 477 
 478         Symbol* const name = cp->symbol_at(class_index);
 479         const unsigned int name_len = name->utf8_length();
 480 
 481         // check explicitly for ;Qjava/lang/__Value;
 482         if (name_len == 20 &&
 483             name->equals(";Qjava/lang/__Value;")) {
 484             cp->symbol_at_put(class_index, vmSymbols::java_lang____Value());
 485             cp->unresolved_value_type_at_put(index, class_index, num_klasses++);
 486         } else if (EnableValhalla || EnableMVT) {
 487           const char* derive_vt_classname_postfix = "$Value;";
 488           // check for a value type
 489           // check for name > 3 to rule out ";Q;" where no name is present
 490           if (name_len != 0 &&
 491               name_len > 3 &&
 492               name->starts_with(";Q") &&
 493               ((EnableValhalla && (name->byte_at(name_len-1) == ';')) ||
 494                (EnableMVT && ClassLoader::string_ends_with(name->as_utf8(), derive_vt_classname_postfix)))) {
 495             Symbol* const strippedsym = SymbolTable::new_symbol(name, 2, name_len-1, CHECK);
 496             assert(strippedsym != NULL, "failure to create value type stripped name");
 497             cp->symbol_at_put(class_index, strippedsym);
 498             cp->unresolved_value_type_at_put(index, class_index, num_klasses++);
 499           } else {
 500             cp->unresolved_klass_at_put(index, class_index, num_klasses++);
 501           }
 502         } else {
 503           cp->unresolved_klass_at_put(index, class_index, num_klasses++);
 504         }
 505         break;
 506       }
 507       case JVM_CONSTANT_ValueIndex: {
 508         const int class_index = cp->value_type_index_at(index);
 509         check_property(valid_symbol_at(class_index),
 510           "Invalid constant pool index %u in class file %s",
 511           class_index, CHECK);
 512         cp->unresolved_value_type_at_put(index, class_index, num_klasses++);
 513         break;
 514       }


< prev index next >