237 symbolHandle java_lang_String::as_symbol(Handle java_string, TRAPS) { |
237 symbolHandle java_lang_String::as_symbol(Handle java_string, TRAPS) { |
238 oop obj = java_string(); |
238 oop obj = java_string(); |
239 typeArrayOop value = java_lang_String::value(obj); |
239 typeArrayOop value = java_lang_String::value(obj); |
240 int offset = java_lang_String::offset(obj); |
240 int offset = java_lang_String::offset(obj); |
241 int length = java_lang_String::length(obj); |
241 int length = java_lang_String::length(obj); |
242 |
242 jchar* base = value->char_at_addr(offset); |
243 ResourceMark rm(THREAD); |
243 symbolOop sym = SymbolTable::lookup_unicode(base, length, THREAD); |
244 symbolHandle result; |
244 return symbolHandle(THREAD, sym); |
245 |
245 } |
246 if (length > 0) { |
246 |
247 int utf8_length = UNICODE::utf8_length(value->char_at_addr(offset), length); |
247 symbolOop java_lang_String::as_symbol_or_null(oop java_string) { |
248 char* chars = NEW_RESOURCE_ARRAY(char, utf8_length + 1); |
248 typeArrayOop value = java_lang_String::value(java_string); |
249 UNICODE::convert_to_utf8(value->char_at_addr(offset), length, chars); |
249 int offset = java_lang_String::offset(java_string); |
250 // Allocate the symbol |
250 int length = java_lang_String::length(java_string); |
251 result = oopFactory::new_symbol_handle(chars, utf8_length, CHECK_(symbolHandle())); |
251 jchar* base = value->char_at_addr(offset); |
252 } else { |
252 return SymbolTable::probe_unicode(base, length); |
253 result = oopFactory::new_symbol_handle("", 0, CHECK_(symbolHandle())); |
253 } |
254 } |
254 |
255 return result; |
|
256 } |
|
257 |
255 |
258 int java_lang_String::utf8_length(oop java_string) { |
256 int java_lang_String::utf8_length(oop java_string) { |
259 typeArrayOop value = java_lang_String::value(java_string); |
257 typeArrayOop value = java_lang_String::value(java_string); |
260 int offset = java_lang_String::offset(java_string); |
258 int offset = java_lang_String::offset(java_string); |
261 int length = java_lang_String::length(java_string); |
259 int length = java_lang_String::length(java_string); |
383 assert(k == NULL || k->is_klass(), "type check"); |
381 assert(k == NULL || k->is_klass(), "type check"); |
384 return k; |
382 return k; |
385 } |
383 } |
386 |
384 |
387 |
385 |
|
386 void java_lang_Class::print_signature(oop java_class, outputStream* st) { |
|
387 assert(java_lang_Class::is_instance(java_class), "must be a Class object"); |
|
388 symbolOop name = NULL; |
|
389 bool is_instance = false; |
|
390 if (is_primitive(java_class)) { |
|
391 name = vmSymbols::type_signature(primitive_type(java_class)); |
|
392 } else { |
|
393 klassOop k = as_klassOop(java_class); |
|
394 is_instance = Klass::cast(k)->oop_is_instance(); |
|
395 name = Klass::cast(k)->name(); |
|
396 } |
|
397 if (name == NULL) { |
|
398 st->print("<null>"); |
|
399 return; |
|
400 } |
|
401 if (is_instance) st->print("L"); |
|
402 st->write((char*) name->base(), (int) name->utf8_length()); |
|
403 if (is_instance) st->print(";"); |
|
404 } |
|
405 |
|
406 symbolOop java_lang_Class::as_signature(oop java_class, bool intern_if_not_found, TRAPS) { |
|
407 assert(java_lang_Class::is_instance(java_class), "must be a Class object"); |
|
408 symbolOop name = NULL; |
|
409 if (is_primitive(java_class)) { |
|
410 return vmSymbols::type_signature(primitive_type(java_class)); |
|
411 } else { |
|
412 klassOop k = as_klassOop(java_class); |
|
413 if (!Klass::cast(k)->oop_is_instance()) { |
|
414 return Klass::cast(k)->name(); |
|
415 } else { |
|
416 ResourceMark rm; |
|
417 const char* sigstr = Klass::cast(k)->signature_name(); |
|
418 int siglen = (int) strlen(sigstr); |
|
419 if (!intern_if_not_found) |
|
420 return SymbolTable::probe(sigstr, siglen); |
|
421 else |
|
422 return oopFactory::new_symbol(sigstr, siglen, THREAD); |
|
423 } |
|
424 } |
|
425 } |
|
426 |
|
427 |
388 klassOop java_lang_Class::array_klass(oop java_class) { |
428 klassOop java_lang_Class::array_klass(oop java_class) { |
389 klassOop k = klassOop(java_class->obj_field(array_klass_offset)); |
429 klassOop k = klassOop(java_class->obj_field(array_klass_offset)); |
390 assert(k == NULL || k->is_klass() && Klass::cast(k)->oop_is_javaArray(), "should be array klass"); |
430 assert(k == NULL || k->is_klass() && Klass::cast(k)->oop_is_javaArray(), "should be array klass"); |
391 return k; |
431 return k; |
392 } |
432 } |
427 } else { |
469 } else { |
428 assert(java_class == Universe::void_mirror(), "only valid non-array primitive"); |
470 assert(java_class == Universe::void_mirror(), "only valid non-array primitive"); |
429 } |
471 } |
430 assert(Universe::java_mirror(type) == java_class, "must be consistent"); |
472 assert(Universe::java_mirror(type) == java_class, "must be consistent"); |
431 return type; |
473 return type; |
|
474 } |
|
475 |
|
476 BasicType java_lang_Class::as_BasicType(oop java_class, klassOop* reference_klass) { |
|
477 assert(java_lang_Class::is_instance(java_class), "must be a Class object"); |
|
478 if (is_primitive(java_class)) { |
|
479 if (reference_klass != NULL) |
|
480 (*reference_klass) = NULL; |
|
481 return primitive_type(java_class); |
|
482 } else { |
|
483 if (reference_klass != NULL) |
|
484 (*reference_klass) = as_klassOop(java_class); |
|
485 return T_OBJECT; |
|
486 } |
432 } |
487 } |
433 |
488 |
434 |
489 |
435 oop java_lang_Class::primitive_mirror(BasicType t) { |
490 oop java_lang_Class::primitive_mirror(BasicType t) { |
436 oop mirror = Universe::java_mirror(t); |
491 oop mirror = Universe::java_mirror(t); |
1983 break; |
2038 break; |
1984 default: |
2039 default: |
1985 return T_ILLEGAL; |
2040 return T_ILLEGAL; |
1986 } // end switch |
2041 } // end switch |
1987 return type; |
2042 return type; |
|
2043 } |
|
2044 |
|
2045 |
|
2046 void java_lang_boxing_object::print(BasicType type, jvalue* value, outputStream* st) { |
|
2047 switch (type) { |
|
2048 case T_BOOLEAN: st->print("%s", value->z ? "true" : "false"); break; |
|
2049 case T_CHAR: st->print("%d", value->c); break; |
|
2050 case T_BYTE: st->print("%d", value->b); break; |
|
2051 case T_SHORT: st->print("%d", value->s); break; |
|
2052 case T_INT: st->print("%d", value->i); break; |
|
2053 case T_LONG: st->print(INT64_FORMAT, value->j); break; |
|
2054 case T_FLOAT: st->print("%f", value->f); break; |
|
2055 case T_DOUBLE: st->print("%lf", value->d); break; |
|
2056 default: st->print("type %d?", type); break; |
|
2057 } |
1988 } |
2058 } |
1989 |
2059 |
1990 |
2060 |
1991 // Support for java_lang_ref_Reference |
2061 // Support for java_lang_ref_Reference |
1992 oop java_lang_ref_Reference::pending_list_lock() { |
2062 oop java_lang_ref_Reference::pending_list_lock() { |