108 // The element type is already Object. Object[] has direct super of Object. |
108 // The element type is already Object. Object[] has direct super of Object. |
109 super_klass = KlassHandle(THREAD, SystemDictionary::Object_klass()); |
109 super_klass = KlassHandle(THREAD, SystemDictionary::Object_klass()); |
110 } |
110 } |
111 } |
111 } |
112 |
112 |
113 // Create type name for klass (except for symbol arrays, since symbolKlass |
113 // Create type name for klass. |
114 // does not have a name). This will potentially allocate an object, cause |
114 Symbol* name = NULL; |
115 // GC, and all other kinds of things. Hence, this must be done before we |
115 if (!element_klass->oop_is_instance() || |
116 // get a handle to the new objArrayKlass we want to construct. We cannot |
116 (name = instanceKlass::cast(element_klass())->array_name()) == NULL) { |
117 // block while holding a handling to a partly initialized object. |
117 |
118 symbolHandle name = symbolHandle(); |
|
119 |
|
120 if (!element_klass->oop_is_symbol()) { |
|
121 ResourceMark rm(THREAD); |
118 ResourceMark rm(THREAD); |
122 char *name_str = element_klass->name()->as_C_string(); |
119 char *name_str = element_klass->name()->as_C_string(); |
123 int len = element_klass->name()->utf8_length(); |
120 int len = element_klass->name()->utf8_length(); |
124 char *new_str = NEW_RESOURCE_ARRAY(char, len + 4); |
121 char *new_str = NEW_RESOURCE_ARRAY(char, len + 4); |
125 int idx = 0; |
122 int idx = 0; |
131 idx += len; |
128 idx += len; |
132 if (element_klass->oop_is_instance()) { |
129 if (element_klass->oop_is_instance()) { |
133 new_str[idx++] = ';'; |
130 new_str[idx++] = ';'; |
134 } |
131 } |
135 new_str[idx++] = '\0'; |
132 new_str[idx++] = '\0'; |
136 name = oopFactory::new_symbol_handle(new_str, CHECK_0); |
133 name = SymbolTable::new_symbol(new_str, CHECK_0); |
|
134 if (element_klass->oop_is_instance()) { |
|
135 instanceKlass* ik = instanceKlass::cast(element_klass()); |
|
136 ik->set_array_name(name); |
|
137 } |
137 } |
138 } |
138 |
139 |
139 objArrayKlass o; |
140 objArrayKlass o; |
140 arrayKlassHandle k = arrayKlass::base_create_array_klass(o.vtbl_value(), |
141 arrayKlassHandle k = arrayKlass::base_create_array_klass(o.vtbl_value(), |
141 objArrayKlass::header_size(), |
142 objArrayKlass::header_size(), |
142 this_oop, |
143 this_oop, |
143 CHECK_0); |
144 CHECK_0); |
144 |
145 |
145 |
|
146 // Initialize instance variables |
146 // Initialize instance variables |
147 objArrayKlass* oak = objArrayKlass::cast(k()); |
147 objArrayKlass* oak = objArrayKlass::cast(k()); |
148 oak->set_dimension(n); |
148 oak->set_dimension(n); |
149 oak->set_element_klass(element_klass()); |
149 oak->set_element_klass(element_klass()); |
150 oak->set_name(name()); |
150 oak->set_name(name); |
|
151 // decrement refcount because object arrays are not explicitly freed. The |
|
152 // instanceKlass array_name() keeps the name counted while the klass is |
|
153 // loaded. |
|
154 name->decrement_refcount(); |
151 |
155 |
152 klassOop bk; |
156 klassOop bk; |
153 if (element_klass->oop_is_objArray()) { |
157 if (element_klass->oop_is_objArray()) { |
154 bk = objArrayKlass::cast(element_klass())->bottom_klass(); |
158 bk = objArrayKlass::cast(element_klass())->bottom_klass(); |
155 } else { |
159 } else { |