< prev index next >

src/hotspot/share/oops/symbol.hpp

Print this page

224   bool ends_with(char suffix_char) const {
225     return contains_byte_at(utf8_length() - 1, suffix_char);
226   }
227 
228   // Tests if the symbol contains the given utf8 substring
229   // at the given byte position.
230   bool contains_utf8_at(int position, const char* substring, int len) const {
231     assert(len >= 0 && substring != nullptr, "substring must be valid");
232     if (position < 0)  return false;  // can happen with ends_with
233     if (position + len > utf8_length()) return false;
234     return (memcmp((char*)base() + position, substring, len) == 0);
235   }
236 
237   // Tests if the symbol contains the given byte at the given position.
238   bool contains_byte_at(int position, char code_byte) const {
239     if (position < 0)  return false;  // can happen with ends_with
240     if (position >= utf8_length()) return false;
241     return code_byte == char_at(position);
242   }
243 












244   // Test if the symbol has the give substring at or after the i-th char.
245   int index_of_at(int i, const char* substr, int substr_len) const;
246 
247   // Three-way compare for sorting; returns -1/0/1 if receiver is </==/> than arg
248   // note that the ordering is not alfabetical
249   inline int fast_compare(const Symbol* other) const;
250 
251   // Returns receiver converted to null-terminated UTF-8 string; string is
252   // allocated in resource area, or in the char buffer provided by caller.
253   char* as_C_string() const;
254   char* as_C_string(char* buf, int size) const;
255 
256   // Returns an escaped form of a Java string.
257   char* as_quoted_ascii() const;
258 
259   // Returns a null terminated utf8 string in a resource array
260   char* as_utf8() const { return as_C_string(); }
261 
262   jchar* as_unicode(int& length) const;
263 

268   const char* as_klass_external_name(char* buf, int size) const;
269 
270   // Treating the symbol as a signature, print the return
271   // type to the outputStream. Prints external names as 'double' or
272   // 'java.lang.Object[][]'.
273   void print_as_signature_external_return_type(outputStream *os);
274   // Treating the symbol as a signature, print the parameter types
275   // separated by ', ' to the outputStream.  Prints external names as
276   //  'double' or 'java.lang.Object[][]'.
277   void print_as_signature_external_parameters(outputStream *os);
278   void print_as_field_external_type(outputStream *os);
279 
280   void metaspace_pointers_do(MetaspaceClosure* it);
281   MetaspaceObj::Type type() const { return SymbolType; }
282 
283   // Printing
284   void print_symbol_on(outputStream* st = nullptr) const;
285   void print_utf8_on(outputStream* st) const;
286   void print_on(outputStream* st) const;         // First level print
287   void print_value_on(outputStream* st) const;   // Second level print.

288 
289   // printing on default output stream
290   void print() const;
291   void print_value() const;
292 
293   static bool is_valid(Symbol* s);
294 
295   static bool is_valid_id(vmSymbolID vm_symbol_id) PRODUCT_RETURN_(return true;);
296 
297   static Symbol* vm_symbol_at(vmSymbolID vm_symbol_id) {
298     assert(is_valid_id(vm_symbol_id), "must be");
299     return _vm_symbols[static_cast<int>(vm_symbol_id)];
300   }
301 
302   static unsigned int compute_hash(const Symbol* const& name) {
303     return (unsigned int) name->identity_hash();
304   }
305 
306 #ifndef PRODUCT
307   // Empty constructor to create a dummy symbol object on stack

224   bool ends_with(char suffix_char) const {
225     return contains_byte_at(utf8_length() - 1, suffix_char);
226   }
227 
228   // Tests if the symbol contains the given utf8 substring
229   // at the given byte position.
230   bool contains_utf8_at(int position, const char* substring, int len) const {
231     assert(len >= 0 && substring != nullptr, "substring must be valid");
232     if (position < 0)  return false;  // can happen with ends_with
233     if (position + len > utf8_length()) return false;
234     return (memcmp((char*)base() + position, substring, len) == 0);
235   }
236 
237   // Tests if the symbol contains the given byte at the given position.
238   bool contains_byte_at(int position, char code_byte) const {
239     if (position < 0)  return false;  // can happen with ends_with
240     if (position >= utf8_length()) return false;
241     return code_byte == char_at(position);
242   }
243 
244   // True if this is a descriptor for a method with void return.
245   // (Assumes it is a valid descriptor.)
246   bool is_void_method_signature() const {
247     return starts_with('(') && ends_with('V');
248   }
249 
250   bool is_Q_signature() const;
251   bool is_Q_array_signature() const;
252   bool is_Q_method_signature() const;
253   Symbol* fundamental_name(TRAPS);
254   bool is_same_fundamental_type(Symbol*) const;
255 
256   // Test if the symbol has the give substring at or after the i-th char.
257   int index_of_at(int i, const char* substr, int substr_len) const;
258 
259   // Three-way compare for sorting; returns -1/0/1 if receiver is </==/> than arg
260   // note that the ordering is not alfabetical
261   inline int fast_compare(const Symbol* other) const;
262 
263   // Returns receiver converted to null-terminated UTF-8 string; string is
264   // allocated in resource area, or in the char buffer provided by caller.
265   char* as_C_string() const;
266   char* as_C_string(char* buf, int size) const;
267 
268   // Returns an escaped form of a Java string.
269   char* as_quoted_ascii() const;
270 
271   // Returns a null terminated utf8 string in a resource array
272   char* as_utf8() const { return as_C_string(); }
273 
274   jchar* as_unicode(int& length) const;
275 

280   const char* as_klass_external_name(char* buf, int size) const;
281 
282   // Treating the symbol as a signature, print the return
283   // type to the outputStream. Prints external names as 'double' or
284   // 'java.lang.Object[][]'.
285   void print_as_signature_external_return_type(outputStream *os);
286   // Treating the symbol as a signature, print the parameter types
287   // separated by ', ' to the outputStream.  Prints external names as
288   //  'double' or 'java.lang.Object[][]'.
289   void print_as_signature_external_parameters(outputStream *os);
290   void print_as_field_external_type(outputStream *os);
291 
292   void metaspace_pointers_do(MetaspaceClosure* it);
293   MetaspaceObj::Type type() const { return SymbolType; }
294 
295   // Printing
296   void print_symbol_on(outputStream* st = nullptr) const;
297   void print_utf8_on(outputStream* st) const;
298   void print_on(outputStream* st) const;         // First level print
299   void print_value_on(outputStream* st) const;   // Second level print.
300   void print_Qvalue_on(outputStream* st) const;  // Second level print for Q-types.
301 
302   // printing on default output stream
303   void print() const;
304   void print_value() const;
305 
306   static bool is_valid(Symbol* s);
307 
308   static bool is_valid_id(vmSymbolID vm_symbol_id) PRODUCT_RETURN_(return true;);
309 
310   static Symbol* vm_symbol_at(vmSymbolID vm_symbol_id) {
311     assert(is_valid_id(vm_symbol_id), "must be");
312     return _vm_symbols[static_cast<int>(vm_symbol_id)];
313   }
314 
315   static unsigned int compute_hash(const Symbol* const& name) {
316     return (unsigned int) name->identity_hash();
317   }
318 
319 #ifndef PRODUCT
320   // Empty constructor to create a dummy symbol object on stack
< prev index next >