src/hotspot/share/runtime/fieldType.cpp
changeset 51997 9ce37fa2e179
parent 49354 c6f2f91a1b4e
child 54786 ebf733a324d4
equal deleted inserted replaced
51996:84743156e780 51997:9ce37fa2e179
    30 #include "oops/typeArrayKlass.hpp"
    30 #include "oops/typeArrayKlass.hpp"
    31 #include "runtime/fieldType.hpp"
    31 #include "runtime/fieldType.hpp"
    32 #include "runtime/signature.hpp"
    32 #include "runtime/signature.hpp"
    33 
    33 
    34 BasicType FieldType::basic_type(Symbol* signature) {
    34 BasicType FieldType::basic_type(Symbol* signature) {
    35   return char2type(signature->byte_at(0));
    35   return char2type(signature->char_at(0));
    36 }
    36 }
    37 
    37 
    38 // Check if it is a valid array signature
    38 // Check if it is a valid array signature
    39 bool FieldType::is_valid_array_signature(Symbol* sig) {
    39 bool FieldType::is_valid_array_signature(Symbol* sig) {
    40   assert(sig->utf8_length() > 1, "this should already have been checked");
    40   assert(sig->utf8_length() > 1, "this should already have been checked");
    41   assert(sig->byte_at(0) == '[', "this should already have been checked");
    41   assert(sig->char_at(0) == '[', "this should already have been checked");
    42   // The first character is already checked
    42   // The first character is already checked
    43   int i = 1;
    43   int i = 1;
    44   int len = sig->utf8_length();
    44   int len = sig->utf8_length();
    45   // First skip all '['s
    45   // First skip all '['s
    46   while(i < len - 1 && sig->byte_at(i) == '[') i++;
    46   while(i < len - 1 && sig->char_at(i) == '[') i++;
    47 
    47 
    48   // Check type
    48   // Check type
    49   switch(sig->byte_at(i)) {
    49   switch(sig->char_at(i)) {
    50     case 'B': // T_BYTE
    50     case 'B': // T_BYTE
    51     case 'C': // T_CHAR
    51     case 'C': // T_CHAR
    52     case 'D': // T_DOUBLE
    52     case 'D': // T_DOUBLE
    53     case 'F': // T_FLOAT
    53     case 'F': // T_FLOAT
    54     case 'I': // T_INT
    54     case 'I': // T_INT
    57     case 'Z': // T_BOOLEAN
    57     case 'Z': // T_BOOLEAN
    58       // If it is an array, the type is the last character
    58       // If it is an array, the type is the last character
    59       return (i + 1 == len);
    59       return (i + 1 == len);
    60     case 'L':
    60     case 'L':
    61       // If it is an object, the last character must be a ';'
    61       // If it is an object, the last character must be a ';'
    62       return sig->byte_at(len - 1) == ';';
    62       return sig->char_at(len - 1) == ';';
    63   }
    63   }
    64 
    64 
    65   return false;
    65   return false;
    66 }
    66 }
    67 
    67 
    68 
    68 
    69 BasicType FieldType::get_array_info(Symbol* signature, FieldArrayInfo& fd, TRAPS) {
    69 BasicType FieldType::get_array_info(Symbol* signature, FieldArrayInfo& fd, TRAPS) {
    70   assert(basic_type(signature) == T_ARRAY, "must be array");
    70   assert(basic_type(signature) == T_ARRAY, "must be array");
    71   int index = 1;
    71   int index = 1;
    72   int dim   = 1;
    72   int dim   = 1;
    73   while (signature->byte_at(index) == '[') {
    73   while (signature->char_at(index) == '[') {
    74     index++;
    74     index++;
    75     dim++;
    75     dim++;
    76   }
    76   }
    77   ResourceMark rm;
    77   ResourceMark rm;
    78   char *element = signature->as_C_string() + index;
    78   char *element = signature->as_C_string() + index;