src/hotspot/share/runtime/signature.cpp
changeset 58722 cba8afa5cfed
parent 54847 59ea39bb2809
--- a/src/hotspot/share/runtime/signature.cpp	Mon Oct 21 09:26:14 2019 -0700
+++ b/src/hotspot/share/runtime/signature.cpp	Mon Oct 21 13:13:16 2019 -0400
@@ -63,41 +63,41 @@
   //       compiler bug (was problem - gri 4/27/2000).
   int size = -1;
   switch(_signature->char_at(_index)) {
-    case 'B': do_byte  (); if (_parameter_index < 0 ) _return_type = T_BYTE;
-              _index++; size = T_BYTE_size   ; break;
-    case 'C': do_char  (); if (_parameter_index < 0 ) _return_type = T_CHAR;
-              _index++; size = T_CHAR_size   ; break;
-    case 'D': do_double(); if (_parameter_index < 0 ) _return_type = T_DOUBLE;
-              _index++; size = T_DOUBLE_size ; break;
-    case 'F': do_float (); if (_parameter_index < 0 ) _return_type = T_FLOAT;
-              _index++; size = T_FLOAT_size  ; break;
-    case 'I': do_int   (); if (_parameter_index < 0 ) _return_type = T_INT;
-              _index++; size = T_INT_size    ; break;
-    case 'J': do_long  (); if (_parameter_index < 0 ) _return_type = T_LONG;
-              _index++; size = T_LONG_size   ; break;
-    case 'S': do_short (); if (_parameter_index < 0 ) _return_type = T_SHORT;
-              _index++; size = T_SHORT_size  ; break;
-    case 'Z': do_bool  (); if (_parameter_index < 0 ) _return_type = T_BOOLEAN;
-              _index++; size = T_BOOLEAN_size; break;
-    case 'V': do_void  (); if (_parameter_index < 0 ) _return_type = T_VOID;
-              _index++; size = T_VOID_size;  ; break;
-    case 'L':
+    case JVM_SIGNATURE_BYTE:    do_byte(); if (_parameter_index < 0 ) _return_type = T_BYTE;
+                                  _index++; size = T_BYTE_size; break;
+    case JVM_SIGNATURE_CHAR:    do_char(); if (_parameter_index < 0 ) _return_type = T_CHAR;
+                                  _index++; size = T_CHAR_size; break;
+    case JVM_SIGNATURE_DOUBLE:  do_double(); if (_parameter_index < 0 ) _return_type = T_DOUBLE;
+                                  _index++; size = T_DOUBLE_size; break;
+    case JVM_SIGNATURE_FLOAT:   do_float(); if (_parameter_index < 0 ) _return_type = T_FLOAT;
+                                  _index++; size = T_FLOAT_size; break;
+    case JVM_SIGNATURE_INT:     do_int(); if (_parameter_index < 0 ) _return_type = T_INT;
+                                  _index++; size = T_INT_size; break;
+    case JVM_SIGNATURE_LONG:    do_long(); if (_parameter_index < 0 ) _return_type = T_LONG;
+                                  _index++; size = T_LONG_size; break;
+    case JVM_SIGNATURE_SHORT:   do_short(); if (_parameter_index < 0 ) _return_type = T_SHORT;
+                                  _index++; size = T_SHORT_size; break;
+    case JVM_SIGNATURE_BOOLEAN: do_bool(); if (_parameter_index < 0 ) _return_type = T_BOOLEAN;
+                                  _index++; size = T_BOOLEAN_size; break;
+    case JVM_SIGNATURE_VOID:    do_void(); if (_parameter_index < 0 ) _return_type = T_VOID;
+                                  _index++; size = T_VOID_size; break;
+    case JVM_SIGNATURE_CLASS:
       { int begin = ++_index;
         Symbol* sig = _signature;
-        while (sig->char_at(_index++) != ';') ;
+        while (sig->char_at(_index++) != JVM_SIGNATURE_ENDCLASS) ;
         do_object(begin, _index);
       }
       if (_parameter_index < 0 ) _return_type = T_OBJECT;
       size = T_OBJECT_size;
       break;
-    case '[':
+    case JVM_SIGNATURE_ARRAY:
       { int begin = ++_index;
         Symbol* sig = _signature;
-        while (sig->char_at(_index) == '[') {
+        while (sig->char_at(_index) == JVM_SIGNATURE_ARRAY) {
           _index++;
         }
-        if (sig->char_at(_index) == 'L') {
-          while (sig->char_at(_index++) != ';') ;
+        if (sig->char_at(_index) == JVM_SIGNATURE_CLASS) {
+          while (sig->char_at(_index++) != JVM_SIGNATURE_ENDCLASS) ;
         } else {
           _index++;
         }
@@ -128,9 +128,9 @@
   // Parse parameters
   _index = 0;
   _parameter_index = 0;
-  expect('(');
-  while (_signature->char_at(_index) != ')') _parameter_index += parse_type();
-  expect(')');
+  expect(JVM_SIGNATURE_FUNC);
+  while (_signature->char_at(_index) != JVM_SIGNATURE_ENDFUNC) _parameter_index += parse_type();
+  expect(JVM_SIGNATURE_ENDFUNC);
   _parameter_index = 0;
 }
 
@@ -202,36 +202,36 @@
 void SignatureIterator::iterate_returntype() {
   // Ignore parameters
   _index = 0;
-  expect('(');
+  expect(JVM_SIGNATURE_FUNC);
   Symbol* sig = _signature;
   // Need to skip over each type in the signature's argument list until a
   // closing ')' is found., then get the return type.  We cannot just scan
   // for the first ')' because ')' is a legal character in a type name.
-  while (sig->char_at(_index) != ')') {
+  while (sig->char_at(_index) != JVM_SIGNATURE_ENDFUNC) {
     switch(sig->char_at(_index)) {
-      case 'B':
-      case 'C':
-      case 'D':
-      case 'F':
-      case 'I':
-      case 'J':
-      case 'S':
-      case 'Z':
-      case 'V':
+      case JVM_SIGNATURE_BYTE:
+      case JVM_SIGNATURE_CHAR:
+      case JVM_SIGNATURE_DOUBLE:
+      case JVM_SIGNATURE_FLOAT:
+      case JVM_SIGNATURE_INT:
+      case JVM_SIGNATURE_LONG:
+      case JVM_SIGNATURE_SHORT:
+      case JVM_SIGNATURE_BOOLEAN:
+      case JVM_SIGNATURE_VOID:
         {
           _index++;
         }
         break;
-      case 'L':
+      case JVM_SIGNATURE_CLASS:
         {
-          while (sig->char_at(_index++) != ';') ;
+          while (sig->char_at(_index++) != JVM_SIGNATURE_ENDCLASS) ;
         }
         break;
-      case '[':
+      case JVM_SIGNATURE_ARRAY:
         {
-          while (sig->char_at(++_index) == '[') ;
-          if (sig->char_at(_index) == 'L') {
-            while (sig->char_at(_index++) != ';') ;
+          while (sig->char_at(++_index) == JVM_SIGNATURE_ARRAY) ;
+          if (sig->char_at(_index) == JVM_SIGNATURE_CLASS) {
+            while (sig->char_at(_index++) != JVM_SIGNATURE_ENDCLASS) ;
           } else {
             _index++;
           }
@@ -242,7 +242,7 @@
         break;
     }
   }
-  expect(')');
+  expect(JVM_SIGNATURE_ENDFUNC);
   // Parse return type
   _parameter_index = -1;
   parse_type();
@@ -255,9 +255,9 @@
   // Parse parameters
   _parameter_index = 0;
   _index = 0;
-  expect('(');
-  while (_signature->char_at(_index) != ')') _parameter_index += parse_type();
-  expect(')');
+  expect(JVM_SIGNATURE_FUNC);
+  while (_signature->char_at(_index) != JVM_SIGNATURE_ENDFUNC) _parameter_index += parse_type();
+  expect(JVM_SIGNATURE_ENDFUNC);
   // Parse return type
   _parameter_index = -1;
   parse_type();
@@ -289,39 +289,39 @@
 
 void SignatureStream::next_non_primitive(int t) {
   switch (t) {
-    case 'L': {
+    case JVM_SIGNATURE_CLASS: {
       _type = T_OBJECT;
       Symbol* sig = _signature;
-      while (sig->char_at(_end++) != ';');
+      while (sig->char_at(_end++) != JVM_SIGNATURE_ENDCLASS);
       break;
     }
-    case '[': {
+    case JVM_SIGNATURE_ARRAY: {
       _type = T_ARRAY;
       Symbol* sig = _signature;
       char c = sig->char_at(_end);
       while ('0' <= c && c <= '9') c = sig->char_at(_end++);
-      while (sig->char_at(_end) == '[') {
+      while (sig->char_at(_end) == JVM_SIGNATURE_ARRAY) {
         _end++;
         c = sig->char_at(_end);
         while ('0' <= c && c <= '9') c = sig->char_at(_end++);
       }
       switch(sig->char_at(_end)) {
-        case 'B':
-        case 'C':
-        case 'D':
-        case 'F':
-        case 'I':
-        case 'J':
-        case 'S':
-        case 'Z':_end++; break;
+        case JVM_SIGNATURE_BYTE:
+        case JVM_SIGNATURE_CHAR:
+        case JVM_SIGNATURE_DOUBLE:
+        case JVM_SIGNATURE_FLOAT:
+        case JVM_SIGNATURE_INT:
+        case JVM_SIGNATURE_LONG:
+        case JVM_SIGNATURE_SHORT:
+        case JVM_SIGNATURE_BOOLEAN:_end++; break;
         default: {
-          while (sig->char_at(_end++) != ';');
+          while (sig->char_at(_end++) != JVM_SIGNATURE_ENDCLASS);
           break;
         }
       }
       break;
     }
-    case ')': _end++; next(); _at_return_type = true; break;
+    case JVM_SIGNATURE_ENDFUNC: _end++; next(); _at_return_type = true; break;
     default : ShouldNotReachHere();
   }
 }
@@ -341,8 +341,8 @@
   int begin = _begin;
   int end   = _end;
 
-  if (   _signature->char_at(_begin) == 'L'
-      && _signature->char_at(_end-1) == ';') {
+  if (   _signature->char_at(_begin) == JVM_SIGNATURE_CLASS
+      && _signature->char_at(_end-1) == JVM_SIGNATURE_ENDCLASS) {
     begin++;
     end--;
   }
@@ -407,8 +407,8 @@
   int begin = _begin;
   int end   = _end;
 
-  if (   _signature->char_at(_begin) == 'L'
-      && _signature->char_at(_end-1) == ';') {
+  if (   _signature->char_at(_begin) == JVM_SIGNATURE_CLASS
+      && _signature->char_at(_end-1) == JVM_SIGNATURE_ENDCLASS) {
     begin++;
     end--;
   }
@@ -436,9 +436,9 @@
   const char* method_sig = (const char*)sig->bytes();
   ssize_t len = sig->utf8_length();
   ssize_t index = 0;
-  if (method_sig != NULL && len > 1 && method_sig[index] == '(') {
+  if (method_sig != NULL && len > 1 && method_sig[index] == JVM_SIGNATURE_FUNC) {
     ++index;
-    while (index < len && method_sig[index] != ')') {
+    while (index < len && method_sig[index] != JVM_SIGNATURE_ENDFUNC) {
       ssize_t res = is_valid_type(&method_sig[index], len - index);
       if (res == -1) {
         return false;
@@ -446,7 +446,7 @@
         index += res;
       }
     }
-    if (index < len && method_sig[index] == ')') {
+    if (index < len && method_sig[index] == JVM_SIGNATURE_ENDFUNC) {
       // check the return type
       ++index;
       return (is_valid_type(&method_sig[index], len - index) == (len - index));
@@ -469,21 +469,28 @@
   ssize_t index = 0;
 
   // Iterate over any number of array dimensions
-  while (index < limit && type[index] == '[') ++index;
+  while (index < limit && type[index] == JVM_SIGNATURE_ARRAY) ++index;
   if (index >= limit) {
     return -1;
   }
   switch (type[index]) {
-    case 'B': case 'C': case 'D': case 'F': case 'I':
-    case 'J': case 'S': case 'Z': case 'V':
+    case JVM_SIGNATURE_BYTE:
+    case JVM_SIGNATURE_CHAR:
+    case JVM_SIGNATURE_DOUBLE:
+    case JVM_SIGNATURE_FLOAT:
+    case JVM_SIGNATURE_INT:
+    case JVM_SIGNATURE_LONG:
+    case JVM_SIGNATURE_SHORT:
+    case JVM_SIGNATURE_BOOLEAN:
+    case JVM_SIGNATURE_VOID:
       return index + 1;
-    case 'L':
+    case JVM_SIGNATURE_CLASS:
       for (index = index + 1; index < limit; ++index) {
         char c = type[index];
         switch (c) {
-          case ';':
+          case JVM_SIGNATURE_ENDCLASS:
             return index + 1;
-          case '\0': case '.': case '[':
+          case '\0': case JVM_SIGNATURE_DOT: case JVM_SIGNATURE_ARRAY:
             return -1;
           default: ; // fall through
         }