comparison src/share/vm/classfile/javaClasses.cpp @ 11019:eaf3742822ec

Merge
author chegar
date Mon, 17 Jun 2013 11:17:49 +0100
parents 7ee0d5c53c78 6bd680e9ea35
children 3a0774193f71
comparison
equal deleted inserted replaced
11018:0861193d358a 11019:eaf3742822ec
510 void java_lang_Class::fixup_mirror(KlassHandle k, TRAPS) { 510 void java_lang_Class::fixup_mirror(KlassHandle k, TRAPS) {
511 assert(InstanceMirrorKlass::offset_of_static_fields() != 0, "must have been computed already"); 511 assert(InstanceMirrorKlass::offset_of_static_fields() != 0, "must have been computed already");
512 512
513 // If the offset was read from the shared archive, it was fixed up already 513 // If the offset was read from the shared archive, it was fixed up already
514 if (!k->is_shared()) { 514 if (!k->is_shared()) {
515 if (k->oop_is_instance()) { 515 if (k->oop_is_instance()) {
516 // During bootstrap, java.lang.Class wasn't loaded so static field 516 // During bootstrap, java.lang.Class wasn't loaded so static field
517 // offsets were computed without the size added it. Go back and 517 // offsets were computed without the size added it. Go back and
518 // update all the static field offsets to included the size. 518 // update all the static field offsets to included the size.
519 for (JavaFieldStream fs(InstanceKlass::cast(k())); !fs.done(); fs.next()) { 519 for (JavaFieldStream fs(InstanceKlass::cast(k())); !fs.done(); fs.next()) {
520 if (fs.access_flags().is_static()) { 520 if (fs.access_flags().is_static()) {
521 int real_offset = fs.offset() + InstanceMirrorKlass::offset_of_static_fields(); 521 int real_offset = fs.offset() + InstanceMirrorKlass::offset_of_static_fields();
522 fs.set_offset(real_offset); 522 fs.set_offset(real_offset);
523 }
523 } 524 }
524 } 525 }
525 } 526 }
526 } 527 create_mirror(k, Handle(NULL), CHECK);
527 create_mirror(k, CHECK); 528 }
528 } 529
529 530 oop java_lang_Class::create_mirror(KlassHandle k, Handle protection_domain, TRAPS) {
530 oop java_lang_Class::create_mirror(KlassHandle k, TRAPS) {
531 assert(k->java_mirror() == NULL, "should only assign mirror once"); 531 assert(k->java_mirror() == NULL, "should only assign mirror once");
532 // Use this moment of initialization to cache modifier_flags also, 532 // Use this moment of initialization to cache modifier_flags also,
533 // to support Class.getModifiers(). Instance classes recalculate 533 // to support Class.getModifiers(). Instance classes recalculate
534 // the cached flags after the class file is parsed, but before the 534 // the cached flags after the class file is parsed, but before the
535 // class is put into the system dictionary. 535 // class is put into the system dictionary.
561 // Two-way link between the array klass and its component mirror: 561 // Two-way link between the array klass and its component mirror:
562 ArrayKlass::cast(k())->set_component_mirror(comp_mirror()); 562 ArrayKlass::cast(k())->set_component_mirror(comp_mirror());
563 set_array_klass(comp_mirror(), k()); 563 set_array_klass(comp_mirror(), k());
564 } else { 564 } else {
565 assert(k->oop_is_instance(), "Must be"); 565 assert(k->oop_is_instance(), "Must be");
566
567 // Allocate a simple java object for a lock.
568 // This needs to be a java object because during class initialization
569 // it can be held across a java call.
570 typeArrayOop r = oopFactory::new_typeArray(T_INT, 0, CHECK_NULL);
571 set_init_lock(mirror(), r);
572
573 // Set protection domain also
574 set_protection_domain(mirror(), protection_domain());
575
566 // Initialize static fields 576 // Initialize static fields
567 InstanceKlass::cast(k())->do_local_static_fields(&initialize_static_field, CHECK_NULL); 577 InstanceKlass::cast(k())->do_local_static_fields(&initialize_static_field, CHECK_NULL);
568 } 578 }
569 return mirror(); 579 return mirror();
570 } else { 580 } else {
594 } 604 }
595 void java_lang_Class::set_static_oop_field_count(oop java_class, int size) { 605 void java_lang_Class::set_static_oop_field_count(oop java_class, int size) {
596 assert(_static_oop_field_count_offset != 0, "must be set"); 606 assert(_static_oop_field_count_offset != 0, "must be set");
597 java_class->int_field_put(_static_oop_field_count_offset, size); 607 java_class->int_field_put(_static_oop_field_count_offset, size);
598 } 608 }
609
610 oop java_lang_Class::protection_domain(oop java_class) {
611 assert(_protection_domain_offset != 0, "must be set");
612 return java_class->obj_field(_protection_domain_offset);
613 }
614 void java_lang_Class::set_protection_domain(oop java_class, oop pd) {
615 assert(_protection_domain_offset != 0, "must be set");
616 java_class->obj_field_put(_protection_domain_offset, pd);
617 }
618
619 oop java_lang_Class::init_lock(oop java_class) {
620 assert(_init_lock_offset != 0, "must be set");
621 return java_class->obj_field(_init_lock_offset);
622 }
623 void java_lang_Class::set_init_lock(oop java_class, oop init_lock) {
624 assert(_init_lock_offset != 0, "must be set");
625 java_class->obj_field_put(_init_lock_offset, init_lock);
626 }
627
628 objArrayOop java_lang_Class::signers(oop java_class) {
629 assert(_signers_offset != 0, "must be set");
630 return (objArrayOop)java_class->obj_field(_signers_offset);
631 }
632 void java_lang_Class::set_signers(oop java_class, objArrayOop signers) {
633 assert(_signers_offset != 0, "must be set");
634 java_class->obj_field_put(_signers_offset, (oop)signers);
635 }
636
599 637
600 oop java_lang_Class::create_basic_type_mirror(const char* basic_type_name, BasicType type, TRAPS) { 638 oop java_lang_Class::create_basic_type_mirror(const char* basic_type_name, BasicType type, TRAPS) {
601 // This should be improved by adding a field at the Java level or by 639 // This should be improved by adding a field at the Java level or by
602 // introducing a new VM klass (see comment in ClassFileParser) 640 // introducing a new VM klass (see comment in ClassFileParser)
603 oop java_class = InstanceMirrorKlass::cast(SystemDictionary::Class_klass())->allocate_instance(NULL, CHECK_0); 641 oop java_class = InstanceMirrorKlass::cast(SystemDictionary::Class_klass())->allocate_instance(NULL, CHECK_0);
2957 2995
2958 int java_lang_Class::_klass_offset; 2996 int java_lang_Class::_klass_offset;
2959 int java_lang_Class::_array_klass_offset; 2997 int java_lang_Class::_array_klass_offset;
2960 int java_lang_Class::_oop_size_offset; 2998 int java_lang_Class::_oop_size_offset;
2961 int java_lang_Class::_static_oop_field_count_offset; 2999 int java_lang_Class::_static_oop_field_count_offset;
3000 int java_lang_Class::_protection_domain_offset;
3001 int java_lang_Class::_init_lock_offset;
3002 int java_lang_Class::_signers_offset;
2962 GrowableArray<Klass*>* java_lang_Class::_fixup_mirror_list = NULL; 3003 GrowableArray<Klass*>* java_lang_Class::_fixup_mirror_list = NULL;
2963 int java_lang_Throwable::backtrace_offset; 3004 int java_lang_Throwable::backtrace_offset;
2964 int java_lang_Throwable::detailMessage_offset; 3005 int java_lang_Throwable::detailMessage_offset;
2965 int java_lang_Throwable::cause_offset; 3006 int java_lang_Throwable::cause_offset;
2966 int java_lang_Throwable::stackTrace_offset; 3007 int java_lang_Throwable::stackTrace_offset;