src/hotspot/share/prims/methodHandles.cpp
changeset 51997 9ce37fa2e179
parent 51467 12997ebbc0d8
child 52411 35ebea32a23c
equal deleted inserted replaced
51996:84743156e780 51997:9ce37fa2e179
   535 bool MethodHandles::is_basic_type_signature(Symbol* sig) {
   535 bool MethodHandles::is_basic_type_signature(Symbol* sig) {
   536   assert(vmSymbols::object_signature()->utf8_length() == (int)OBJ_SIG_LEN, "");
   536   assert(vmSymbols::object_signature()->utf8_length() == (int)OBJ_SIG_LEN, "");
   537   assert(vmSymbols::object_signature()->equals(OBJ_SIG), "");
   537   assert(vmSymbols::object_signature()->equals(OBJ_SIG), "");
   538   const int len = sig->utf8_length();
   538   const int len = sig->utf8_length();
   539   for (int i = 0; i < len; i++) {
   539   for (int i = 0; i < len; i++) {
   540     switch (sig->byte_at(i)) {
   540     switch (sig->char_at(i)) {
   541     case 'L':
   541     case 'L':
   542       // only java/lang/Object is valid here
   542       // only java/lang/Object is valid here
   543       if (sig->index_of_at(i, OBJ_SIG, OBJ_SIG_LEN) != i)
   543       if (sig->index_of_at(i, OBJ_SIG, OBJ_SIG_LEN) != i)
   544         return false;
   544         return false;
   545       i += OBJ_SIG_LEN-1;  //-1 because of i++ in loop
   545       i += OBJ_SIG_LEN-1;  //-1 because of i++ in loop
   561   if (sig == NULL) {
   561   if (sig == NULL) {
   562     return sig;
   562     return sig;
   563   } else if (is_basic_type_signature(sig)) {
   563   } else if (is_basic_type_signature(sig)) {
   564     sig->increment_refcount();
   564     sig->increment_refcount();
   565     return sig;  // that was easy
   565     return sig;  // that was easy
   566   } else if (sig->byte_at(0) != '(') {
   566   } else if (sig->char_at(0) != '(') {
   567     BasicType bt = char2type(sig->byte_at(0));
   567     BasicType bt = char2type(sig->char_at(0));
   568     if (is_subword_type(bt)) {
   568     if (is_subword_type(bt)) {
   569       bsig = vmSymbols::int_signature();
   569       bsig = vmSymbols::int_signature();
   570     } else {
   570     } else {
   571       assert(bt == T_OBJECT || bt == T_ARRAY, "is_basic_type_signature was false");
   571       assert(bt == T_OBJECT || bt == T_ARRAY, "is_basic_type_signature was false");
   572       bsig = vmSymbols::object_signature();
   572       bsig = vmSymbols::object_signature();
   613   st = st ? st : tty;
   613   st = st ? st : tty;
   614   int len  = sig->utf8_length();
   614   int len  = sig->utf8_length();
   615   int array = 0;
   615   int array = 0;
   616   bool prev_type = false;
   616   bool prev_type = false;
   617   for (int i = 0; i < len; i++) {
   617   for (int i = 0; i < len; i++) {
   618     char ch = sig->byte_at(i);
   618     char ch = sig->char_at(i);
   619     switch (ch) {
   619     switch (ch) {
   620     case '(': case ')':
   620     case '(': case ')':
   621       prev_type = false;
   621       prev_type = false;
   622       st->put(ch);
   622       st->put(ch);
   623       continue;
   623       continue;
   628       continue;
   628       continue;
   629     case 'L':
   629     case 'L':
   630       {
   630       {
   631         if (prev_type)  st->put(',');
   631         if (prev_type)  st->put(',');
   632         int start = i+1, slash = start;
   632         int start = i+1, slash = start;
   633         while (++i < len && (ch = sig->byte_at(i)) != ';') {
   633         while (++i < len && (ch = sig->char_at(i)) != ';') {
   634           if (ch == '/' || ch == '.' || ch == '$')  slash = i+1;
   634           if (ch == '/' || ch == '.' || ch == '$')  slash = i+1;
   635         }
   635         }
   636         if (slash < i)  start = slash;
   636         if (slash < i)  start = slash;
   637         if (!keep_basic_names) {
   637         if (!keep_basic_names) {
   638           st->put('L');
   638           st->put('L');
   639         } else {
   639         } else {
   640           for (int j = start; j < i; j++)
   640           for (int j = start; j < i; j++)
   641             st->put(sig->byte_at(j));
   641             st->put(sig->char_at(j));
   642           prev_type = true;
   642           prev_type = true;
   643         }
   643         }
   644         break;
   644         break;
   645       }
   645       }
   646     default:
   646     default:
   973   if (name != NULL) {
   973   if (name != NULL) {
   974     if (name->utf8_length() == 0)  return 0; // a match is not possible
   974     if (name->utf8_length() == 0)  return 0; // a match is not possible
   975   }
   975   }
   976   if (sig != NULL) {
   976   if (sig != NULL) {
   977     if (sig->utf8_length() == 0)  return 0; // a match is not possible
   977     if (sig->utf8_length() == 0)  return 0; // a match is not possible
   978     if (sig->byte_at(0) == '(')
   978     if (sig->char_at(0) == '(')
   979       match_flags &= ~(IS_FIELD | IS_TYPE);
   979       match_flags &= ~(IS_FIELD | IS_TYPE);
   980     else
   980     else
   981       match_flags &= ~(IS_CONSTRUCTOR | IS_METHOD);
   981       match_flags &= ~(IS_CONSTRUCTOR | IS_METHOD);
   982   }
   982   }
   983 
   983 
  1454           }
  1454           }
  1455         case -2:  // type
  1455         case -2:  // type
  1456           {
  1456           {
  1457             Symbol* type = caller->constants()->signature_ref_at(bss_index_in_pool);
  1457             Symbol* type = caller->constants()->signature_ref_at(bss_index_in_pool);
  1458             Handle th;
  1458             Handle th;
  1459             if (type->byte_at(0) == '(') {
  1459             if (type->char_at(0) == '(') {
  1460               th = SystemDictionary::find_method_handle_type(type, caller, CHECK);
  1460               th = SystemDictionary::find_method_handle_type(type, caller, CHECK);
  1461             } else {
  1461             } else {
  1462               th = SystemDictionary::find_java_mirror_for_type(type, caller, SignatureStream::NCDFError, CHECK);
  1462               th = SystemDictionary::find_java_mirror_for_type(type, caller, SignatureStream::NCDFError, CHECK);
  1463             }
  1463             }
  1464             pseudo_arg = th();
  1464             pseudo_arg = th();