< prev index next >

src/hotspot/share/oops/symbol.hpp

Print this page




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


 203   bool starts_with(const char* prefix) const {
 204     return starts_with(prefix, (int) strlen(prefix));
 205   }






























 206 
 207   // Tests if the symbol starts with the given prefix.
 208   int index_of_at(int i, const char* str, int len) const;
 209 
 210   // Three-way compare for sorting; returns -1/0/1 if receiver is </==/> than arg
 211   // note that the ordering is not alfabetical
 212   inline int fast_compare(const Symbol* other) const;
 213 
 214   // Returns receiver converted to null-terminated UTF-8 string; string is
 215   // allocated in resource area, or in the char buffer provided by caller.
 216   char* as_C_string() const;
 217   char* as_C_string(char* buf, int size) const;
 218 
 219   // Returns an escaped form of a Java string.
 220   char* as_quoted_ascii() const;
 221 
 222   // Returns a null terminated utf8 string in a resource array
 223   char* as_utf8() const { return as_C_string(); }
 224 
 225   jchar* as_unicode(int& length) const;


 230   const char* as_klass_external_name() const;
 231   const char* as_klass_external_name(char* buf, int size) const;
 232 
 233   // Treating the symbol as a signature, print the return
 234   // type to the outputStream. Prints external names as 'double' or
 235   // 'java.lang.Object[][]'.
 236   void print_as_signature_external_return_type(outputStream *os);
 237   // Treating the symbol as a signature, print the parameter types
 238   // seperated by ', ' to the outputStream.  Prints external names as
 239   //  'double' or 'java.lang.Object[][]'.
 240   void print_as_signature_external_parameters(outputStream *os);
 241 
 242   void metaspace_pointers_do(MetaspaceClosure* it);
 243   MetaspaceObj::Type type() const { return SymbolType; }
 244 
 245   // Printing
 246   void print_symbol_on(outputStream* st = NULL) const;
 247   void print_utf8_on(outputStream* st) const;
 248   void print_on(outputStream* st) const;         // First level print
 249   void print_value_on(outputStream* st) const;   // Second level print.

 250 
 251   // printing on default output stream
 252   void print() const;
 253   void print_value() const;
 254 
 255   static bool is_valid(Symbol* s);
 256 
 257 #ifndef PRODUCT
 258   // Empty constructor to create a dummy symbol object on stack
 259   // only for getting its vtable pointer.
 260   Symbol() { }
 261 
 262   static size_t _total_count;
 263 #endif
 264 };
 265 
 266 // Note: this comparison is used for vtable sorting only; it doesn't matter
 267 // what order it defines, as long as it is a total, time-invariant order
 268 // Since Symbol*s are in C_HEAP, their relative order in memory never changes,
 269 // so use address comparison for speed


 182   }
 183 
 184   const u1* bytes() const { return base(); }
 185 
 186   int utf8_length() const { return length(); }
 187 
 188   // Compares the symbol with a string.
 189   bool equals(const char* str, int len) const {
 190     int l = utf8_length();
 191     if (l != len) return false;
 192     while (l-- > 0) {
 193       if (str[l] != char_at(l))
 194         return false;
 195     }
 196     assert(l == -1, "we should be at the beginning");
 197     return true;
 198   }
 199   bool equals(const char* str) const { return equals(str, (int) strlen(str)); }
 200 
 201   // Tests if the symbol starts with the given prefix.
 202   bool starts_with(const char* prefix, int len) const {
 203     return contains_utf8_at(0, prefix, len);
 204   }
 205   bool starts_with(const char* prefix) const {
 206     return starts_with(prefix, (int) strlen(prefix));
 207   }
 208   bool starts_with(char prefix_char) const {
 209     return contains_byte_at(0, prefix_char);
 210   }
 211   // Tests if the symbol ends with the given suffix.
 212   bool ends_with(const char* suffix, int len) const {
 213     return contains_utf8_at(utf8_length() - len, suffix, len);
 214   }
 215   bool ends_with(const char* suffix) const {
 216     return ends_with(suffix, (int) strlen(suffix));
 217   }
 218   bool ends_with(char suffix_char) const {
 219     return contains_byte_at(utf8_length()-1, suffix_char);
 220   }
 221   // Tests if the symbol contains the given utf8 substring
 222   // or byte at the given byte position.
 223   bool contains_utf8_at(int position, const char* substring, int len) const;
 224   bool contains_byte_at(int position, char code_byte) const;
 225 
 226   // True if this is a descriptor for a method with void return.
 227   // (Assumes it is a valid descriptor.)
 228   bool is_void_method_signature() const {
 229     return starts_with('(') && ends_with('V');
 230   }
 231 
 232   bool is_Q_signature() const;
 233   bool is_Q_array_signature() const;
 234   bool is_Q_method_signature() const;
 235   bool is_Q_singledim_array_signature() const;
 236   Symbol* fundamental_name(TRAPS);
 237   bool is_same_fundamental_type(Symbol*) const;
 238 
 239   // Tests if the symbol starts with the given prefix.
 240   int index_of_at(int i, const char* str, int len) const;
 241 
 242   // Three-way compare for sorting; returns -1/0/1 if receiver is </==/> than arg
 243   // note that the ordering is not alfabetical
 244   inline int fast_compare(const Symbol* other) const;
 245 
 246   // Returns receiver converted to null-terminated UTF-8 string; string is
 247   // allocated in resource area, or in the char buffer provided by caller.
 248   char* as_C_string() const;
 249   char* as_C_string(char* buf, int size) const;
 250 
 251   // Returns an escaped form of a Java string.
 252   char* as_quoted_ascii() const;
 253 
 254   // Returns a null terminated utf8 string in a resource array
 255   char* as_utf8() const { return as_C_string(); }
 256 
 257   jchar* as_unicode(int& length) const;


 262   const char* as_klass_external_name() const;
 263   const char* as_klass_external_name(char* buf, int size) const;
 264 
 265   // Treating the symbol as a signature, print the return
 266   // type to the outputStream. Prints external names as 'double' or
 267   // 'java.lang.Object[][]'.
 268   void print_as_signature_external_return_type(outputStream *os);
 269   // Treating the symbol as a signature, print the parameter types
 270   // seperated by ', ' to the outputStream.  Prints external names as
 271   //  'double' or 'java.lang.Object[][]'.
 272   void print_as_signature_external_parameters(outputStream *os);
 273 
 274   void metaspace_pointers_do(MetaspaceClosure* it);
 275   MetaspaceObj::Type type() const { return SymbolType; }
 276 
 277   // Printing
 278   void print_symbol_on(outputStream* st = NULL) const;
 279   void print_utf8_on(outputStream* st) const;
 280   void print_on(outputStream* st) const;         // First level print
 281   void print_value_on(outputStream* st) const;   // Second level print.
 282   void print_Qvalue_on(outputStream* st) const;  // Second level print for Q-types.
 283 
 284   // printing on default output stream
 285   void print() const;
 286   void print_value() const;
 287 
 288   static bool is_valid(Symbol* s);
 289 
 290 #ifndef PRODUCT
 291   // Empty constructor to create a dummy symbol object on stack
 292   // only for getting its vtable pointer.
 293   Symbol() { }
 294 
 295   static size_t _total_count;
 296 #endif
 297 };
 298 
 299 // Note: this comparison is used for vtable sorting only; it doesn't matter
 300 // what order it defines, as long as it is a total, time-invariant order
 301 // Since Symbol*s are in C_HEAP, their relative order in memory never changes,
 302 // so use address comparison for speed
< prev index next >