src/share/vm/oops/symbol.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File hotspot Sdiff src/share/vm/oops

src/share/vm/oops/symbol.cpp

Print this page
rev 9166 : 8139996: CompileCommand prints quoted ascii strings
Summary: Print symbols as utf8
Reviewed-by:


 137 
 138 char* Symbol::as_C_string() const {
 139   int len = utf8_length();
 140   char* str = NEW_RESOURCE_ARRAY(char, len + 1);
 141   return as_C_string(str, len + 1);
 142 }
 143 
 144 char* Symbol::as_C_string_flexible_buffer(Thread* t,
 145                                                  char* buf, int size) const {
 146   char* str;
 147   int len = utf8_length();
 148   int buf_len = len + 1;
 149   if (size < buf_len) {
 150     str = NEW_RESOURCE_ARRAY(char, buf_len);
 151   } else {
 152     str = buf;
 153   }
 154   return as_C_string(str, buf_len);
 155 }
 156 




 157 void Symbol::print_symbol_on(outputStream* st) const {
 158   ResourceMark rm;
 159   st = st ? st : tty;
 160   st->print("%s", as_quoted_ascii());
 161 }
 162 
 163 char* Symbol::as_quoted_ascii() const {
 164   const char *ptr = (const char *)&_body[0];
 165   int quoted_length = UTF8::quoted_ascii_length(ptr, utf8_length());
 166   char* result = NEW_RESOURCE_ARRAY(char, quoted_length + 1);
 167   UTF8::as_quoted_ascii(ptr, utf8_length(), result, quoted_length + 1);
 168   return result;
 169 }
 170 
 171 jchar* Symbol::as_unicode(int& length) const {
 172   Symbol* this_ptr = (Symbol*)this;
 173   length = UTF8::unicode_length((char*)this_ptr->bytes(), utf8_length());
 174   jchar* result = NEW_RESOURCE_ARRAY(jchar, length);
 175   if (length > 0) {
 176     UTF8::convert_to_unicode((char*)this_ptr->bytes(), result, length);




 137 
 138 char* Symbol::as_C_string() const {
 139   int len = utf8_length();
 140   char* str = NEW_RESOURCE_ARRAY(char, len + 1);
 141   return as_C_string(str, len + 1);
 142 }
 143 
 144 char* Symbol::as_C_string_flexible_buffer(Thread* t,
 145                                                  char* buf, int size) const {
 146   char* str;
 147   int len = utf8_length();
 148   int buf_len = len + 1;
 149   if (size < buf_len) {
 150     str = NEW_RESOURCE_ARRAY(char, buf_len);
 151   } else {
 152     str = buf;
 153   }
 154   return as_C_string(str, buf_len);
 155 }
 156 
 157 void Symbol::print_utf8_on(outputStream* st) const {
 158   st->print("%s", as_C_string());
 159 }
 160 
 161 void Symbol::print_symbol_on(outputStream* st) const {
 162   ResourceMark rm;
 163   st = st ? st : tty;
 164   st->print("%s", as_quoted_ascii());
 165 }
 166 
 167 char* Symbol::as_quoted_ascii() const {
 168   const char *ptr = (const char *)&_body[0];
 169   int quoted_length = UTF8::quoted_ascii_length(ptr, utf8_length());
 170   char* result = NEW_RESOURCE_ARRAY(char, quoted_length + 1);
 171   UTF8::as_quoted_ascii(ptr, utf8_length(), result, quoted_length + 1);
 172   return result;
 173 }
 174 
 175 jchar* Symbol::as_unicode(int& length) const {
 176   Symbol* this_ptr = (Symbol*)this;
 177   length = UTF8::unicode_length((char*)this_ptr->bytes(), utf8_length());
 178   jchar* result = NEW_RESOURCE_ARRAY(jchar, length);
 179   if (length > 0) {
 180     UTF8::convert_to_unicode((char*)this_ptr->bytes(), result, length);


src/share/vm/oops/symbol.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File