< prev index next >

src/hotspot/share/oops/symbol.cpp

Print this page




  74 
  75 // ------------------------------------------------------------------
  76 // Symbol::starts_with
  77 //
  78 // Tests if the symbol starts with the specified prefix of the given
  79 // length.
  80 bool Symbol::starts_with(const char* prefix, int len) const {
  81   if (len > utf8_length()) return false;
  82   while (len-- > 0) {
  83     if (prefix[len] != char_at(len))
  84       return false;
  85   }
  86   assert(len == -1, "we should be at the beginning");
  87   return true;
  88 }
  89 
  90 bool Symbol::is_Q_signature() const {
  91   return utf8_length() > 2 && char_at(0) == 'Q' && char_at(utf8_length() - 1) == ';';
  92 }
  93 

















  94 Symbol* Symbol::fundamental_name(TRAPS) {
  95   if ((char_at(0) == 'Q' || char_at(0) == 'L') && char_at(utf8_length() - 1) == ';') {
  96     return SymbolTable::lookup(this, 1, utf8_length() - 1, CHECK_NULL);
  97   } else {
  98     // reference count is incremented to be consistent with the behavior with
  99     // the SymbolTable::lookup() call above
 100     this->increment_refcount();
 101     return this;
 102   }
 103 }
 104 
 105 bool Symbol::is_same_fundamental_type(Symbol* s) const {
 106   if (this == s) return true;
 107   if (utf8_length() < 3) return false;
 108   int offset1, offset2, len;
 109   if (char_at(utf8_length() - 1) == ';') {
 110     if (char_at(0) != 'Q' && char_at(0) != 'L') return false;
 111     offset1 = 1;
 112     len = utf8_length() - 2;
 113   } else {




  74 
  75 // ------------------------------------------------------------------
  76 // Symbol::starts_with
  77 //
  78 // Tests if the symbol starts with the specified prefix of the given
  79 // length.
  80 bool Symbol::starts_with(const char* prefix, int len) const {
  81   if (len > utf8_length()) return false;
  82   while (len-- > 0) {
  83     if (prefix[len] != char_at(len))
  84       return false;
  85   }
  86   assert(len == -1, "we should be at the beginning");
  87   return true;
  88 }
  89 
  90 bool Symbol::is_Q_signature() const {
  91   return utf8_length() > 2 && char_at(0) == 'Q' && char_at(utf8_length() - 1) == ';';
  92 }
  93 
  94 bool Symbol::is_Q_array_signature() const {
  95   int l = utf8_length();
  96   if (l < 2 || char_at(0) != '[' || char_at(l - 1) != ';') {
  97     return false;
  98   }
  99   for (int i = 1; i < (l - 2); i++) {
 100     char c = char_at(i);
 101     if (c == 'Q') {
 102       return true;
 103     }
 104     if (c != '[') {
 105       return false;
 106     }
 107   }
 108   return false;
 109 }
 110 
 111 Symbol* Symbol::fundamental_name(TRAPS) {
 112   if ((char_at(0) == 'Q' || char_at(0) == 'L') && char_at(utf8_length() - 1) == ';') {
 113     return SymbolTable::lookup(this, 1, utf8_length() - 1, CHECK_NULL);
 114   } else {
 115     // reference count is incremented to be consistent with the behavior with
 116     // the SymbolTable::lookup() call above
 117     this->increment_refcount();
 118     return this;
 119   }
 120 }
 121 
 122 bool Symbol::is_same_fundamental_type(Symbol* s) const {
 123   if (this == s) return true;
 124   if (utf8_length() < 3) return false;
 125   int offset1, offset2, len;
 126   if (char_at(utf8_length() - 1) == ';') {
 127     if (char_at(0) != 'Q' && char_at(0) != 'L') return false;
 128     offset1 = 1;
 129     len = utf8_length() - 2;
 130   } else {


< prev index next >