< prev index next >

src/hotspot/share/oops/symbol.hpp

Print this page




 185   int utf8_length() const { return length(); }
 186 
 187   // Compares the symbol with a string.
 188   bool equals(const char* str, int len) const {
 189     int l = utf8_length();
 190     if (l != len) return false;
 191     while (l-- > 0) {
 192       if (str[l] != char_at(l))
 193         return false;
 194     }
 195     assert(l == -1, "we should be at the beginning");
 196     return true;
 197   }
 198   bool equals(const char* str) const { return equals(str, (int) strlen(str)); }
 199 
 200   // Tests if the symbol starts with the given prefix.
 201   bool starts_with(const char* prefix, int len) const;
 202   bool starts_with(const char* prefix) const {
 203     return starts_with(prefix, (int) strlen(prefix));
 204   }



 205 
 206   // Tests if the symbol starts with the given prefix.
 207   int index_of_at(int i, const char* str, int len) const;
 208 
 209   // Three-way compare for sorting; returns -1/0/1 if receiver is </==/> than arg
 210   // note that the ordering is not alfabetical
 211   inline int fast_compare(const Symbol* other) const;
 212 
 213   // Returns receiver converted to null-terminated UTF-8 string; string is
 214   // allocated in resource area, or in the char buffer provided by caller.
 215   char* as_C_string() const;
 216   char* as_C_string(char* buf, int size) const;
 217 
 218   // Returns an escaped form of a Java string.
 219   char* as_quoted_ascii() const;
 220 
 221   // Returns a null terminated utf8 string in a resource array
 222   char* as_utf8() const { return as_C_string(); }
 223 
 224   jchar* as_unicode(int& length) const;
 225 
 226   // Treating this symbol as a class name, returns the Java name for the class.
 227   // String is allocated in resource area if buffer is not provided.
 228   // See Klass::external_name()
 229   const char* as_klass_external_name() const;
 230   const char* as_klass_external_name(char* buf, int size) const;
 231 
 232   void metaspace_pointers_do(MetaspaceClosure* it);
 233   MetaspaceObj::Type type() const { return SymbolType; }
 234 
 235   // Printing
 236   void print_symbol_on(outputStream* st = NULL) const;
 237   void print_utf8_on(outputStream* st) const;
 238   void print_on(outputStream* st) const;         // First level print
 239   void print_value_on(outputStream* st) const;   // Second level print.

 240 
 241   // printing on default output stream
 242   void print()         { print_on(tty);       }
 243   void print_value()   { print_value_on(tty); }
 244 
 245   static bool is_valid(Symbol* s);
 246 
 247 #ifndef PRODUCT
 248   // Empty constructor to create a dummy symbol object on stack
 249   // only for getting its vtable pointer.
 250   Symbol() { }
 251 
 252   static size_t _total_count;
 253 #endif
 254 };
 255 
 256 // Note: this comparison is used for vtable sorting only; it doesn't matter
 257 // what order it defines, as long as it is a total, time-invariant order
 258 // Since Symbol*s are in C_HEAP, their relative order in memory never changes,
 259 // so use address comparison for speed


 185   int utf8_length() const { return length(); }
 186 
 187   // Compares the symbol with a string.
 188   bool equals(const char* str, int len) const {
 189     int l = utf8_length();
 190     if (l != len) return false;
 191     while (l-- > 0) {
 192       if (str[l] != char_at(l))
 193         return false;
 194     }
 195     assert(l == -1, "we should be at the beginning");
 196     return true;
 197   }
 198   bool equals(const char* str) const { return equals(str, (int) strlen(str)); }
 199 
 200   // Tests if the symbol starts with the given prefix.
 201   bool starts_with(const char* prefix, int len) const;
 202   bool starts_with(const char* prefix) const {
 203     return starts_with(prefix, (int) strlen(prefix));
 204   }
 205   bool is_Q_signature() const;
 206   Symbol* fundamental_name(TRAPS);
 207   bool is_same_fundamental_type(Symbol*) const;
 208 
 209   // Tests if the symbol starts with the given prefix.
 210   int index_of_at(int i, const char* str, int len) const;
 211 
 212   // Three-way compare for sorting; returns -1/0/1 if receiver is </==/> than arg
 213   // note that the ordering is not alfabetical
 214   inline int fast_compare(const Symbol* other) const;
 215 
 216   // Returns receiver converted to null-terminated UTF-8 string; string is
 217   // allocated in resource area, or in the char buffer provided by caller.
 218   char* as_C_string() const;
 219   char* as_C_string(char* buf, int size) const;
 220 
 221   // Returns an escaped form of a Java string.
 222   char* as_quoted_ascii() const;
 223 
 224   // Returns a null terminated utf8 string in a resource array
 225   char* as_utf8() const { return as_C_string(); }
 226 
 227   jchar* as_unicode(int& length) const;
 228 
 229   // Treating this symbol as a class name, returns the Java name for the class.
 230   // String is allocated in resource area if buffer is not provided.
 231   // See Klass::external_name()
 232   const char* as_klass_external_name() const;
 233   const char* as_klass_external_name(char* buf, int size) const;
 234 
 235   void metaspace_pointers_do(MetaspaceClosure* it);
 236   MetaspaceObj::Type type() const { return SymbolType; }
 237 
 238   // Printing
 239   void print_symbol_on(outputStream* st = NULL) const;
 240   void print_utf8_on(outputStream* st) const;
 241   void print_on(outputStream* st) const;         // First level print
 242   void print_value_on(outputStream* st) const;   // Second level print.
 243   void print_Qvalue_on(outputStream* st) const;  // Second level print for Q-types.
 244 
 245   // printing on default output stream
 246   void print()         { print_on(tty);       }
 247   void print_value()   { print_value_on(tty); }
 248 
 249   static bool is_valid(Symbol* s);
 250 
 251 #ifndef PRODUCT
 252   // Empty constructor to create a dummy symbol object on stack
 253   // only for getting its vtable pointer.
 254   Symbol() { }
 255 
 256   static size_t _total_count;
 257 #endif
 258 };
 259 
 260 // Note: this comparison is used for vtable sorting only; it doesn't matter
 261 // what order it defines, as long as it is a total, time-invariant order
 262 // Since Symbol*s are in C_HEAP, their relative order in memory never changes,
 263 // so use address comparison for speed
< prev index next >