Mercurial > hg > truffle
diff src/share/vm/classfile/javaClasses.cpp @ 6988:2cb439954abf
Merge with http://hg.openjdk.java.net/hsx/hsx25/hotspot/
author | Gilles Duboscq <duboscq@ssw.jku.at> |
---|---|
date | Mon, 19 Nov 2012 15:36:13 +0100 |
parents | e522a00b91aa 80e866b1d053 |
children | 291ffc492eb6 |
line wrap: on
line diff
--- a/src/share/vm/classfile/javaClasses.cpp Sun Nov 18 22:45:43 2012 +0100 +++ b/src/share/vm/classfile/javaClasses.cpp Mon Nov 19 15:36:13 2012 +0100 @@ -348,6 +348,22 @@ return java_lang_String::to_hash(value->char_at_addr(offset), length); } +char* java_lang_String::as_quoted_ascii(oop java_string) { + typeArrayOop value = java_lang_String::value(java_string); + int offset = java_lang_String::offset(java_string); + int length = java_lang_String::length(java_string); + + jchar* base = (length == 0) ? NULL : value->char_at_addr(offset); + if (base == NULL) return NULL; + + int result_length = UNICODE::quoted_ascii_length(base, length) + 1; + char* result = NEW_RESOURCE_ARRAY(char, result_length); + UNICODE::as_quoted_ascii(base, length, result, result_length); + assert(result_length >= length + 1, "must not be shorter"); + assert(result_length == (int)strlen(result) + 1, "must match"); + return result; +} + unsigned int java_lang_String::hash_string(oop java_string) { int length = java_lang_String::length(java_string); // Zero length string doesn't hash necessarily hash to zero. @@ -545,7 +561,7 @@ assert(k->oop_is_objArray(), "Must be"); Klass* element_klass = ObjArrayKlass::cast(k())->element_klass(); assert(element_klass != NULL, "Must have an element klass"); - comp_mirror = Klass::cast(element_klass)->java_mirror(); + comp_mirror = element_klass->java_mirror(); } assert(comp_mirror.not_null(), "must have a mirror"); @@ -634,8 +650,8 @@ name = vmSymbols::type_signature(primitive_type(java_class)); } else { Klass* k = as_Klass(java_class); - is_instance = Klass::cast(k)->oop_is_instance(); - name = Klass::cast(k)->name(); + is_instance = k->oop_is_instance(); + name = k->name(); } if (name == NULL) { st->print("<null>"); @@ -657,12 +673,12 @@ name->increment_refcount(); } else { Klass* k = as_Klass(java_class); - if (!Klass::cast(k)->oop_is_instance()) { - name = Klass::cast(k)->name(); + if (!k->oop_is_instance()) { + name = k->name(); name->increment_refcount(); } else { ResourceMark rm; - const char* sigstr = Klass::cast(k)->signature_name(); + const char* sigstr = k->signature_name(); int siglen = (int) strlen(sigstr); if (!intern_if_not_found) { name = SymbolTable::probe(sigstr, siglen); @@ -677,13 +693,13 @@ Klass* java_lang_Class::array_klass(oop java_class) { Klass* k = ((Klass*)java_class->metadata_field(_array_klass_offset)); - assert(k == NULL || k->is_klass() && Klass::cast(k)->oop_is_array(), "should be array klass"); + assert(k == NULL || k->is_klass() && k->oop_is_array(), "should be array klass"); return k; } void java_lang_Class::set_array_klass(oop java_class, Klass* klass) { - assert(klass->is_klass() && Klass::cast(klass)->oop_is_array(), "should be array klass"); + assert(klass->is_klass() && klass->oop_is_array(), "should be array klass"); java_class->metadata_field_put(_array_klass_offset, klass); }