153 Klass* Klass::find_field(Symbol* name, Symbol* sig, fieldDescriptor* fd) const { 154 #ifdef ASSERT 155 tty->print_cr("Error: find_field called on a klass oop." 156 " Likely error: reflection method does not correctly" 157 " wrap return value in a mirror object."); 158 #endif 159 ShouldNotReachHere(); 160 return NULL; 161 } 162 163 Method* Klass::uncached_lookup_method(const Symbol* name, const Symbol* signature, OverpassLookupMode overpass_mode) const { 164 #ifdef ASSERT 165 tty->print_cr("Error: uncached_lookup_method called on a klass oop." 166 " Likely error: reflection method does not correctly" 167 " wrap return value in a mirror object."); 168 #endif 169 ShouldNotReachHere(); 170 return NULL; 171 } 172 173 void* Klass::operator new(size_t size, ClassLoaderData* loader_data, size_t word_size, TRAPS) throw() { 174 return Metaspace::allocate(loader_data, word_size, MetaspaceObj::ClassType, THREAD); 175 } 176 177 // "Normal" instantiation is preceeded by a MetaspaceObj allocation 178 // which zeros out memory - calloc equivalent. 179 // The constructor is also used from CppVtableCloner, 180 // which doesn't zero out the memory before calling the constructor. 181 // Need to set the _java_mirror field explicitly to not hit an assert that the field 182 // should be NULL before setting it. 183 Klass::Klass() : _prototype_header(markOopDesc::prototype()), 184 _shared_class_path_index(-1), 185 _java_mirror(NULL) { 186 187 _primary_supers[0] = this; 188 set_super_check_offset(in_bytes(primary_supers_offset())); 189 } 190 191 jint Klass::array_layout_helper(BasicType etype) { 192 assert(etype >= T_BOOLEAN && etype <= T_OBJECT, "valid etype"); 193 // Note that T_ARRAY is not allowed here. 194 int hsize = arrayOopDesc::base_offset_in_bytes(etype); | 153 Klass* Klass::find_field(Symbol* name, Symbol* sig, fieldDescriptor* fd) const { 154 #ifdef ASSERT 155 tty->print_cr("Error: find_field called on a klass oop." 156 " Likely error: reflection method does not correctly" 157 " wrap return value in a mirror object."); 158 #endif 159 ShouldNotReachHere(); 160 return NULL; 161 } 162 163 Method* Klass::uncached_lookup_method(const Symbol* name, const Symbol* signature, OverpassLookupMode overpass_mode) const { 164 #ifdef ASSERT 165 tty->print_cr("Error: uncached_lookup_method called on a klass oop." 166 " Likely error: reflection method does not correctly" 167 " wrap return value in a mirror object."); 168 #endif 169 ShouldNotReachHere(); 170 return NULL; 171 } 172 173 void* Klass::operator new(size_t size, ClassLoaderData* loader_data, size_t word_size, bool is_value, TRAPS) throw () { 174 // Pad size in case need adjust to even/odd klass ptr 175 uintptr_t addr = (uintptr_t) Metaspace::allocate(loader_data, word_size + (1 << LogKlassAlignment), MetaspaceObj::ClassType, THREAD); 176 // values are odd, otherwise make even (and vice versa) 177 if (is_value ^ (((addr & KlassPtrValueTypeMask) >> LogKlassAlignmentInBytes) != 0)) { 178 addr += (1 << LogKlassAlignmentInBytes); 179 } 180 assert(is_aligned(addr, (1 << LogKlassAlignmentInBytes)), "Klass base alignment incorrect"); 181 assert( is_value || ((addr & KlassPtrValueTypeMask) == 0), "Klass even alignment incorrect"); 182 assert(!is_value || ((addr & KlassPtrValueTypeMask) != 0), "Klass odd alignment incorrect"); 183 return (void*) addr; 184 } 185 186 // "Normal" instantiation is preceeded by a MetaspaceObj allocation 187 // which zeros out memory - calloc equivalent. 188 // The constructor is also used from CppVtableCloner, 189 // which doesn't zero out the memory before calling the constructor. 190 // Need to set the _java_mirror field explicitly to not hit an assert that the field 191 // should be NULL before setting it. 192 Klass::Klass() : _prototype_header(markOopDesc::prototype()), 193 _shared_class_path_index(-1), 194 _java_mirror(NULL) { 195 196 _primary_supers[0] = this; 197 set_super_check_offset(in_bytes(primary_supers_offset())); 198 } 199 200 jint Klass::array_layout_helper(BasicType etype) { 201 assert(etype >= T_BOOLEAN && etype <= T_OBJECT, "valid etype"); 202 // Note that T_ARRAY is not allowed here. 203 int hsize = arrayOopDesc::base_offset_in_bytes(etype); |