src/hotspot/share/prims/methodHandles.cpp
changeset 58722 cba8afa5cfed
parent 58545 725244418646
child 59056 15936b142f86
--- a/src/hotspot/share/prims/methodHandles.cpp	Mon Oct 21 09:26:14 2019 -0700
+++ b/src/hotspot/share/prims/methodHandles.cpp	Mon Oct 21 13:13:16 2019 -0400
@@ -542,18 +542,22 @@
   const int len = sig->utf8_length();
   for (int i = 0; i < len; i++) {
     switch (sig->char_at(i)) {
-    case 'L':
+    case JVM_SIGNATURE_CLASS:
       // only java/lang/Object is valid here
       if (sig->index_of_at(i, OBJ_SIG, OBJ_SIG_LEN) != i)
         return false;
       i += OBJ_SIG_LEN-1;  //-1 because of i++ in loop
       continue;
-    case '(': case ')': case 'V':
-    case 'I': case 'J': case 'F': case 'D':
+    case JVM_SIGNATURE_FUNC:
+    case JVM_SIGNATURE_ENDFUNC:
+    case JVM_SIGNATURE_VOID:
+    case JVM_SIGNATURE_INT:
+    case JVM_SIGNATURE_LONG:
+    case JVM_SIGNATURE_FLOAT:
+    case JVM_SIGNATURE_DOUBLE:
       continue;
-    //case '[':
-    //case 'Z': case 'B': case 'C': case 'S':
     default:
+      // subword types (T_BYTE etc.), arrays
       return false;
     }
   }
@@ -567,7 +571,7 @@
   } else if (is_basic_type_signature(sig)) {
     sig->increment_refcount();
     return sig;  // that was easy
-  } else if (sig->char_at(0) != '(') {
+  } else if (sig->char_at(0) != JVM_SIGNATURE_FUNC) {
     BasicType bt = char2type(sig->char_at(0));
     if (is_subword_type(bt)) {
       bsig = vmSymbols::int_signature();
@@ -578,7 +582,7 @@
   } else {
     ResourceMark rm;
     stringStream buffer(128);
-    buffer.put('(');
+    buffer.put(JVM_SIGNATURE_FUNC);
     int arg_pos = 0, keep_arg_pos = -1;
     if (keep_last_arg)
       keep_arg_pos = ArgumentCount(sig).size() - 1;
@@ -586,7 +590,7 @@
       BasicType bt = ss.type();
       size_t this_arg_pos = buffer.size();
       if (ss.at_return_type()) {
-        buffer.put(')');
+        buffer.put(JVM_SIGNATURE_ENDFUNC);
       }
       if (arg_pos == keep_arg_pos) {
         buffer.write((char*) ss.raw_bytes(),
@@ -621,25 +625,26 @@
   for (int i = 0; i < len; i++) {
     char ch = sig->char_at(i);
     switch (ch) {
-    case '(': case ')':
+    case JVM_SIGNATURE_FUNC:
+    case JVM_SIGNATURE_ENDFUNC:
       prev_type = false;
       st->put(ch);
       continue;
-    case '[':
+    case JVM_SIGNATURE_ARRAY:
       if (!keep_basic_names && keep_arrays)
         st->put(ch);
       array++;
       continue;
-    case 'L':
+    case JVM_SIGNATURE_CLASS:
       {
         if (prev_type)  st->put(',');
         int start = i+1, slash = start;
-        while (++i < len && (ch = sig->char_at(i)) != ';') {
-          if (ch == '/' || ch == '.' || ch == '$')  slash = i+1;
+        while (++i < len && (ch = sig->char_at(i)) != JVM_SIGNATURE_ENDCLASS) {
+          if (ch == JVM_SIGNATURE_SLASH || ch == JVM_SIGNATURE_DOT || ch == '$')  slash = i+1;
         }
         if (slash < i)  start = slash;
         if (!keep_basic_names) {
-          st->put('L');
+          st->put(JVM_SIGNATURE_CLASS);
         } else {
           for (int j = start; j < i; j++)
             st->put(sig->char_at(j));
@@ -650,7 +655,7 @@
     default:
       {
         if (array && char2type(ch) != T_ILLEGAL && !keep_arrays) {
-          ch = '[';
+          ch = JVM_SIGNATURE_ARRAY;
           array = 0;
         }
         if (prev_type)  st->put(',');
@@ -978,7 +983,7 @@
   }
   if (sig != NULL) {
     if (sig->utf8_length() == 0)  return 0; // a match is not possible
-    if (sig->char_at(0) == '(')
+    if (sig->char_at(0) == JVM_SIGNATURE_FUNC)
       match_flags &= ~(IS_FIELD | IS_TYPE);
     else
       match_flags &= ~(IS_CONSTRUCTOR | IS_METHOD);
@@ -1456,7 +1461,7 @@
           {
             Symbol* type = caller->constants()->signature_ref_at(bss_index_in_pool);
             Handle th;
-            if (type->char_at(0) == '(') {
+            if (type->char_at(0) == JVM_SIGNATURE_FUNC) {
               th = SystemDictionary::find_method_handle_type(type, caller, CHECK);
             } else {
               th = SystemDictionary::find_java_mirror_for_type(type, caller, SignatureStream::NCDFError, CHECK);