< prev index next >

src/hotspot/share/runtime/signature.cpp

Print this page


 449 
 450   char* buffer = NEW_RESOURCE_ARRAY(char, end - begin);
 451   for (int index = begin; index < end; index++) {
 452     buffer[index - begin] = _signature->char_at(index);
 453   }
 454   Symbol* result = SymbolTable::probe(buffer, end - begin);
 455   return result;
 456 }
 457 
 458 int SignatureStream::reference_parameter_count() {
 459   int args_count = 0;
 460   for ( ; !at_return_type(); next()) {
 461     if (is_object()) {
 462       args_count++;
 463     }
 464   }
 465   return args_count;
 466 }
 467 
 468 #ifdef ASSERT
 469 bool SignatureVerifier::is_valid_method_signature(Symbol* sig) {
 470   const char* method_sig = (const char*)sig->bytes();
 471   ssize_t len = sig->utf8_length();
 472   ssize_t index = 0;
 473   if (method_sig != NULL && len > 1 && method_sig[index] == '(') {
 474     ++index;
 475     while (index < len && method_sig[index] != ')') {
 476       ssize_t res = is_valid_type(&method_sig[index], len - index);
 477       if (res == -1) {
 478         return false;
 479       } else {
 480         index += res;
 481       }
 482     }
 483     if (index < len && method_sig[index] == ')') {
 484       // check the return type
 485       ++index;
 486       return (is_valid_type(&method_sig[index], len - index) == (len - index));
 487     }
 488   }
 489   return false;
 490 }
 491 
 492 bool SignatureVerifier::is_valid_type_signature(Symbol* sig) {
 493   const char* type_sig = (const char*)sig->bytes();
 494   ssize_t len = sig->utf8_length();
 495   return (type_sig != NULL && len >= 1 &&
 496           (is_valid_type(type_sig, len) == len));
 497 }
 498 
 499 // Checks to see if the type (not to go beyond 'limit') refers to a valid type.
 500 // Returns -1 if it is not, or the index of the next character that is not part
 501 // of the type.  The type encoding may end before 'limit' and that's ok.
 502 ssize_t SignatureVerifier::is_valid_type(const char* type, ssize_t limit) {
 503   ssize_t index = 0;
 504 
 505   // Iterate over any number of array dimensions
 506   while (index < limit && type[index] == '[') ++index;
 507   if (index >= limit) {
 508     return -1;
 509   }
 510   switch (type[index]) {
 511     case 'B': case 'C': case 'D': case 'F': case 'I':
 512     case 'J': case 'S': case 'Z': case 'V':




 449 
 450   char* buffer = NEW_RESOURCE_ARRAY(char, end - begin);
 451   for (int index = begin; index < end; index++) {
 452     buffer[index - begin] = _signature->char_at(index);
 453   }
 454   Symbol* result = SymbolTable::probe(buffer, end - begin);
 455   return result;
 456 }
 457 
 458 int SignatureStream::reference_parameter_count() {
 459   int args_count = 0;
 460   for ( ; !at_return_type(); next()) {
 461     if (is_object()) {
 462       args_count++;
 463     }
 464   }
 465   return args_count;
 466 }
 467 
 468 #ifdef ASSERT
 469 bool SignatureVerifier::is_valid_method_signature(const Symbol* sig) {
 470   const char* method_sig = (const char*)sig->bytes();
 471   ssize_t len = sig->utf8_length();
 472   ssize_t index = 0;
 473   if (method_sig != NULL && len > 1 && method_sig[index] == '(') {
 474     ++index;
 475     while (index < len && method_sig[index] != ')') {
 476       ssize_t res = is_valid_type(&method_sig[index], len - index);
 477       if (res == -1) {
 478         return false;
 479       } else {
 480         index += res;
 481       }
 482     }
 483     if (index < len && method_sig[index] == ')') {
 484       // check the return type
 485       ++index;
 486       return (is_valid_type(&method_sig[index], len - index) == (len - index));
 487     }
 488   }
 489   return false;
 490 }
 491 
 492 bool SignatureVerifier::is_valid_type_signature(const Symbol* sig) {
 493   const char* type_sig = (const char*)sig->bytes();
 494   ssize_t len = sig->utf8_length();
 495   return (type_sig != NULL && len >= 1 &&
 496           (is_valid_type(type_sig, len) == len));
 497 }
 498 
 499 // Checks to see if the type (not to go beyond 'limit') refers to a valid type.
 500 // Returns -1 if it is not, or the index of the next character that is not part
 501 // of the type.  The type encoding may end before 'limit' and that's ok.
 502 ssize_t SignatureVerifier::is_valid_type(const char* type, ssize_t limit) {
 503   ssize_t index = 0;
 504 
 505   // Iterate over any number of array dimensions
 506   while (index < limit && type[index] == '[') ++index;
 507   if (index >= limit) {
 508     return -1;
 509   }
 510   switch (type[index]) {
 511     case 'B': case 'C': case 'D': case 'F': case 'I':
 512     case 'J': case 'S': case 'Z': case 'V':


< prev index next >