src/hotspot/share/classfile/verifier.cpp
changeset 58722 cba8afa5cfed
parent 58481 48a73ec3a817
child 59290 97d13893ec3c
equal deleted inserted replaced
58720:ae0af9fb3dbb 58722:cba8afa5cfed
  2850           "Third and fourth operand bytes of invokedynamic must be zero");
  2850           "Third and fourth operand bytes of invokedynamic must be zero");
  2851       return;
  2851       return;
  2852     }
  2852     }
  2853   }
  2853   }
  2854 
  2854 
  2855   if (method_name->char_at(0) == '<') {
  2855   if (method_name->char_at(0) == JVM_SIGNATURE_SPECIAL) {
  2856     // Make sure <init> can only be invoked by invokespecial
  2856     // Make sure <init> can only be invoked by invokespecial
  2857     if (opcode != Bytecodes::_invokespecial ||
  2857     if (opcode != Bytecodes::_invokespecial ||
  2858         method_name != vmSymbols::object_initializer_name()) {
  2858         method_name != vmSymbols::object_initializer_name()) {
  2859       verify_error(ErrorContext::bad_code(bci),
  2859       verify_error(ErrorContext::bad_code(bci),
  2860           "Illegal call to internal method");
  2860           "Illegal call to internal method");
  3026   if (component_type.is_array()) {     // it's an array
  3026   if (component_type.is_array()) {     // it's an array
  3027     const char* component_name = component_type.name()->as_utf8();
  3027     const char* component_name = component_type.name()->as_utf8();
  3028     // Check for more than MAX_ARRAY_DIMENSIONS
  3028     // Check for more than MAX_ARRAY_DIMENSIONS
  3029     length = (int)strlen(component_name);
  3029     length = (int)strlen(component_name);
  3030     if (length > MAX_ARRAY_DIMENSIONS &&
  3030     if (length > MAX_ARRAY_DIMENSIONS &&
  3031         component_name[MAX_ARRAY_DIMENSIONS - 1] == '[') {
  3031         component_name[MAX_ARRAY_DIMENSIONS - 1] == JVM_SIGNATURE_ARRAY) {
  3032       verify_error(ErrorContext::bad_code(bci),
  3032       verify_error(ErrorContext::bad_code(bci),
  3033         "Illegal anewarray instruction, array has more than 255 dimensions");
  3033         "Illegal anewarray instruction, array has more than 255 dimensions");
  3034     }
  3034     }
  3035     // add one dimension to component
  3035     // add one dimension to component
  3036     length++;
  3036     length++;
  3037     arr_sig_str = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, char, length + 1);
  3037     arr_sig_str = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, char, length + 1);
  3038     int n = os::snprintf(arr_sig_str, length + 1, "[%s", component_name);
  3038     int n = os::snprintf(arr_sig_str, length + 1, "%c%s",
       
  3039                          JVM_SIGNATURE_ARRAY, component_name);
  3039     assert(n == length, "Unexpected number of characters in string");
  3040     assert(n == length, "Unexpected number of characters in string");
  3040   } else {         // it's an object or interface
  3041   } else {         // it's an object or interface
  3041     const char* component_name = component_type.name()->as_utf8();
  3042     const char* component_name = component_type.name()->as_utf8();
  3042     // add one dimension to component with 'L' prepended and ';' postpended.
  3043     // add one dimension to component with 'L' prepended and ';' postpended.
  3043     length = (int)strlen(component_name) + 3;
  3044     length = (int)strlen(component_name) + 3;
  3044     arr_sig_str = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, char, length + 1);
  3045     arr_sig_str = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, char, length + 1);
  3045     int n = os::snprintf(arr_sig_str, length + 1, "[L%s;", component_name);
  3046     int n = os::snprintf(arr_sig_str, length + 1, "%c%c%s;",
       
  3047                          JVM_SIGNATURE_ARRAY, JVM_SIGNATURE_CLASS, component_name);
  3046     assert(n == length, "Unexpected number of characters in string");
  3048     assert(n == length, "Unexpected number of characters in string");
  3047   }
  3049   }
  3048   Symbol* arr_sig = create_temporary_symbol(arr_sig_str, length);
  3050   Symbol* arr_sig = create_temporary_symbol(arr_sig_str, length);
  3049   VerificationType new_array_type = VerificationType::reference_type(arr_sig);
  3051   VerificationType new_array_type = VerificationType::reference_type(arr_sig);
  3050   current_frame->push_stack(new_array_type, CHECK_VERIFY(this));
  3052   current_frame->push_stack(new_array_type, CHECK_VERIFY(this));