< prev index next >

hotspot/src/share/vm/runtime/fieldType.cpp

Print this page




  57   switch(sig->byte_at(i)) {
  58     case 'B': // T_BYTE
  59     case 'C': // T_CHAR
  60     case 'D': // T_DOUBLE
  61     case 'F': // T_FLOAT
  62     case 'I': // T_INT
  63     case 'J': // T_LONG
  64     case 'S': // T_SHORT
  65     case 'Z': // T_BOOLEAN
  66       // If it is an array, the type is the last character
  67       return (i + 1 == len);
  68     case 'L':
  69     case 'Q':
  70       // If it is an object or a value type, the last character must be a ';'
  71       return sig->byte_at(len - 1) == ';';
  72   }
  73 
  74   return false;
  75 }
  76 
























  77 
  78 BasicType FieldType::get_array_info(Symbol* signature, FieldArrayInfo& fd, TRAPS) {
  79   assert(basic_type(signature) == T_ARRAY, "must be array");
  80   int index = 1;
  81   int dim   = 1;
  82   skip_optional_size(signature, &index);
  83   while (signature->byte_at(index) == '[') {
  84     index++;
  85     dim++;
  86     skip_optional_size(signature, &index);
  87   }
  88   ResourceMark rm;
  89   char *element = signature->as_C_string() + index;
  90   BasicType element_type = char2type(element[0]);
  91   if (element_type == T_OBJECT || element_type == T_VALUETYPE) {
  92     int len = (int)strlen(element);
  93     assert(element[len-1] == ';', "last char should be a semicolon");
  94     element[len-1] = '\0';        // chop off semicolon
  95     fd._object_key = SymbolTable::new_symbol(element + 1, CHECK_(T_BYTE));
  96   }


  57   switch(sig->byte_at(i)) {
  58     case 'B': // T_BYTE
  59     case 'C': // T_CHAR
  60     case 'D': // T_DOUBLE
  61     case 'F': // T_FLOAT
  62     case 'I': // T_INT
  63     case 'J': // T_LONG
  64     case 'S': // T_SHORT
  65     case 'Z': // T_BOOLEAN
  66       // If it is an array, the type is the last character
  67       return (i + 1 == len);
  68     case 'L':
  69     case 'Q':
  70       // If it is an object or a value type, the last character must be a ';'
  71       return sig->byte_at(len - 1) == ';';
  72   }
  73 
  74   return false;
  75 }
  76 
  77 static const char dvt_postfix[] = "$Value";
  78 static const int dvt_postfix_len = 6;
  79 
  80 bool FieldType::is_dvt_postfix(Symbol* signature) {
  81   int sig_length = signature->utf8_length();
  82   int pos = sig_length - dvt_postfix_len;
  83   if (pos <= 0) {
  84     return false;
  85   }
  86   for (int i = 0; i < dvt_postfix_len; i++) {
  87     if (signature->byte_at(pos) != dvt_postfix[i]) {
  88       return false;
  89     }
  90     pos++;
  91   }
  92   return true;
  93 }
  94 
  95 char* FieldType::dvt_unmangle_vcc(Symbol* signature) {
  96   assert(is_dvt_postfix(signature), "Unmangle that which is not managled");
  97   char* str = signature->as_C_string();
  98   str[signature->utf8_length() -dvt_postfix_len] = '\0';
  99   return str;
 100 }
 101 
 102 BasicType FieldType::get_array_info(Symbol* signature, FieldArrayInfo& fd, TRAPS) {
 103   assert(basic_type(signature) == T_ARRAY, "must be array");
 104   int index = 1;
 105   int dim   = 1;
 106   skip_optional_size(signature, &index);
 107   while (signature->byte_at(index) == '[') {
 108     index++;
 109     dim++;
 110     skip_optional_size(signature, &index);
 111   }
 112   ResourceMark rm;
 113   char *element = signature->as_C_string() + index;
 114   BasicType element_type = char2type(element[0]);
 115   if (element_type == T_OBJECT || element_type == T_VALUETYPE) {
 116     int len = (int)strlen(element);
 117     assert(element[len-1] == ';', "last char should be a semicolon");
 118     element[len-1] = '\0';        // chop off semicolon
 119     fd._object_key = SymbolTable::new_symbol(element + 1, CHECK_(T_BYTE));
 120   }
< prev index next >