예제 #1
0
// Check if it is a valid array signature
bool FieldType::is_valid_array_signature(symbolOop sig) {
  assert(sig->utf8_length() > 1, "this should already have been checked");
  assert(sig->byte_at(0) == '[', "this should already have been checked");
  // The first character is already checked
  int i = 1;
  int len = sig->utf8_length();
  // First skip all '['s
  while(i < len - 1 && sig->byte_at(i) == '[') i++;

  // Check type
  switch(sig->byte_at(i)) {
    case 'B': // T_BYTE
    case 'C': // T_CHAR
    case 'D': // T_DOUBLE
    case 'F': // T_FLOAT
    case 'I': // T_INT
    case 'J': // T_LONG
    case 'S': // T_SHORT
    case 'Z': // T_BOOLEAN
      // If it is an array, the type is the last character
      return (i + 1 == len);
    case 'L':
      // If it is an object, the last character must be a ';'
      return sig->byte_at(len - 1) == ';';
  }

  return false;
}
 static bool is_obj(symbolOop signature) {
    int sig_length = signature->utf8_length();
    // Must start with 'L' and end with ';'
    return (sig_length >= 2 &&
            (signature->byte_at(0) == 'L') &&
            (signature->byte_at(sig_length - 1) == ';'));
 }
 // Testing
 static bool is_array(symbolOop signature) { return signature->utf8_length() > 1 && signature->byte_at(0) == '[' && is_valid_array_signature(signature); }