annotate hotspot/src/share/vm/ci/ciInstanceKlass.cpp @ 1:489c9b5090e2

Initial load
author duke
date Sat, 01 Dec 2007 00:00:00 +0000
parents
children c646ef2f5d58
rev   line source
duke@1 1 /*
duke@1 2 * Copyright 1999-2007 Sun Microsystems, Inc. All Rights Reserved.
duke@1 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@1 4 *
duke@1 5 * This code is free software; you can redistribute it and/or modify it
duke@1 6 * under the terms of the GNU General Public License version 2 only, as
duke@1 7 * published by the Free Software Foundation.
duke@1 8 *
duke@1 9 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@1 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@1 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@1 12 * version 2 for more details (a copy is included in the LICENSE file that
duke@1 13 * accompanied this code).
duke@1 14 *
duke@1 15 * You should have received a copy of the GNU General Public License version
duke@1 16 * 2 along with this work; if not, write to the Free Software Foundation,
duke@1 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@1 18 *
duke@1 19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
duke@1 20 * CA 95054 USA or visit www.sun.com if you need additional information or
duke@1 21 * have any questions.
duke@1 22 *
duke@1 23 */
duke@1 24
duke@1 25 #include "incls/_precompiled.incl"
duke@1 26 #include "incls/_ciInstanceKlass.cpp.incl"
duke@1 27
duke@1 28 // ciInstanceKlass
duke@1 29 //
duke@1 30 // This class represents a klassOop in the HotSpot virtual machine
duke@1 31 // whose Klass part in an instanceKlass.
duke@1 32
duke@1 33 // ------------------------------------------------------------------
duke@1 34 // ciInstanceKlass::ciInstanceKlass
duke@1 35 //
duke@1 36 // Loaded instance klass.
duke@1 37 ciInstanceKlass::ciInstanceKlass(KlassHandle h_k) : ciKlass(h_k) {
duke@1 38 assert(get_Klass()->oop_is_instance(), "wrong type");
duke@1 39 instanceKlass* ik = get_instanceKlass();
duke@1 40
duke@1 41 AccessFlags access_flags = ik->access_flags();
duke@1 42 _flags = ciFlags(access_flags);
duke@1 43 _has_finalizer = access_flags.has_finalizer();
duke@1 44 _has_subklass = ik->subklass() != NULL;
duke@1 45 _is_initialized = ik->is_initialized();
duke@1 46 // Next line must follow and use the result of the previous line:
duke@1 47 _is_linked = _is_initialized || ik->is_linked();
duke@1 48 _nonstatic_field_size = ik->nonstatic_field_size();
duke@1 49 _nonstatic_fields = NULL; // initialized lazily by compute_nonstatic_fields:
duke@1 50
duke@1 51 _nof_implementors = ik->nof_implementors();
duke@1 52 for (int i = 0; i < implementors_limit; i++) {
duke@1 53 _implementors[i] = NULL; // we will fill these lazily
duke@1 54 }
duke@1 55
duke@1 56 Thread *thread = Thread::current();
duke@1 57 if (ciObjectFactory::is_initialized()) {
duke@1 58 _loader = JNIHandles::make_local(thread, ik->class_loader());
duke@1 59 _protection_domain = JNIHandles::make_local(thread,
duke@1 60 ik->protection_domain());
duke@1 61 _is_shared = false;
duke@1 62 } else {
duke@1 63 Handle h_loader(thread, ik->class_loader());
duke@1 64 Handle h_protection_domain(thread, ik->protection_domain());
duke@1 65 _loader = JNIHandles::make_global(h_loader);
duke@1 66 _protection_domain = JNIHandles::make_global(h_protection_domain);
duke@1 67 _is_shared = true;
duke@1 68 }
duke@1 69
duke@1 70 // Lazy fields get filled in only upon request.
duke@1 71 _super = NULL;
duke@1 72 _java_mirror = NULL;
duke@1 73
duke@1 74 if (is_shared()) {
duke@1 75 if (h_k() != SystemDictionary::object_klass()) {
duke@1 76 super();
duke@1 77 }
duke@1 78 java_mirror();
duke@1 79 //compute_nonstatic_fields(); // done outside of constructor
duke@1 80 }
duke@1 81
duke@1 82 _field_cache = NULL;
duke@1 83 }
duke@1 84
duke@1 85 // Version for unloaded classes:
duke@1 86 ciInstanceKlass::ciInstanceKlass(ciSymbol* name,
duke@1 87 jobject loader, jobject protection_domain)
duke@1 88 : ciKlass(name, ciInstanceKlassKlass::make())
duke@1 89 {
duke@1 90 assert(name->byte_at(0) != '[', "not an instance klass");
duke@1 91 _is_initialized = false;
duke@1 92 _is_linked = false;
duke@1 93 _nonstatic_field_size = -1;
duke@1 94 _nonstatic_fields = NULL;
duke@1 95 _nof_implementors = -1;
duke@1 96 _loader = loader;
duke@1 97 _protection_domain = protection_domain;
duke@1 98 _is_shared = false;
duke@1 99 _super = NULL;
duke@1 100 _java_mirror = NULL;
duke@1 101 _field_cache = NULL;
duke@1 102 }
duke@1 103
duke@1 104
duke@1 105
duke@1 106 // ------------------------------------------------------------------
duke@1 107 // ciInstanceKlass::compute_shared_is_initialized
duke@1 108 bool ciInstanceKlass::compute_shared_is_initialized() {
duke@1 109 GUARDED_VM_ENTRY(
duke@1 110 instanceKlass* ik = get_instanceKlass();
duke@1 111 _is_initialized = ik->is_initialized();
duke@1 112 return _is_initialized;
duke@1 113 )
duke@1 114 }
duke@1 115
duke@1 116 // ------------------------------------------------------------------
duke@1 117 // ciInstanceKlass::compute_shared_is_linked
duke@1 118 bool ciInstanceKlass::compute_shared_is_linked() {
duke@1 119 GUARDED_VM_ENTRY(
duke@1 120 instanceKlass* ik = get_instanceKlass();
duke@1 121 _is_linked = ik->is_linked();
duke@1 122 return _is_linked;
duke@1 123 )
duke@1 124 }
duke@1 125
duke@1 126 // ------------------------------------------------------------------
duke@1 127 // ciInstanceKlass::compute_shared_has_subklass
duke@1 128 bool ciInstanceKlass::compute_shared_has_subklass() {
duke@1 129 GUARDED_VM_ENTRY(
duke@1 130 instanceKlass* ik = get_instanceKlass();
duke@1 131 _has_subklass = ik->subklass() != NULL;
duke@1 132 return _has_subklass;
duke@1 133 )
duke@1 134 }
duke@1 135
duke@1 136 // ------------------------------------------------------------------
duke@1 137 // ciInstanceKlass::compute_shared_nof_implementors
duke@1 138 int ciInstanceKlass::compute_shared_nof_implementors() {
duke@1 139 // We requery this property, since it is a very old ciObject.
duke@1 140 GUARDED_VM_ENTRY(
duke@1 141 instanceKlass* ik = get_instanceKlass();
duke@1 142 _nof_implementors = ik->nof_implementors();
duke@1 143 return _nof_implementors;
duke@1 144 )
duke@1 145 }
duke@1 146
duke@1 147 // ------------------------------------------------------------------
duke@1 148 // ciInstanceKlass::loader
duke@1 149 oop ciInstanceKlass::loader() {
duke@1 150 ASSERT_IN_VM;
duke@1 151 return JNIHandles::resolve(_loader);
duke@1 152 }
duke@1 153
duke@1 154 // ------------------------------------------------------------------
duke@1 155 // ciInstanceKlass::loader_handle
duke@1 156 jobject ciInstanceKlass::loader_handle() {
duke@1 157 return _loader;
duke@1 158 }
duke@1 159
duke@1 160 // ------------------------------------------------------------------
duke@1 161 // ciInstanceKlass::protection_domain
duke@1 162 oop ciInstanceKlass::protection_domain() {
duke@1 163 ASSERT_IN_VM;
duke@1 164 return JNIHandles::resolve(_protection_domain);
duke@1 165 }
duke@1 166
duke@1 167 // ------------------------------------------------------------------
duke@1 168 // ciInstanceKlass::protection_domain_handle
duke@1 169 jobject ciInstanceKlass::protection_domain_handle() {
duke@1 170 return _protection_domain;
duke@1 171 }
duke@1 172
duke@1 173 // ------------------------------------------------------------------
duke@1 174 // ciInstanceKlass::field_cache
duke@1 175 //
duke@1 176 // Get the field cache associated with this klass.
duke@1 177 ciConstantPoolCache* ciInstanceKlass::field_cache() {
duke@1 178 if (is_shared()) {
duke@1 179 return NULL;
duke@1 180 }
duke@1 181 if (_field_cache == NULL) {
duke@1 182 assert(!is_java_lang_Object(), "Object has no fields");
duke@1 183 Arena* arena = CURRENT_ENV->arena();
duke@1 184 _field_cache = new (arena) ciConstantPoolCache(arena, 5);
duke@1 185 }
duke@1 186 return _field_cache;
duke@1 187 }
duke@1 188
duke@1 189 // ------------------------------------------------------------------
duke@1 190 // ciInstanceKlass::get_canonical_holder
duke@1 191 //
duke@1 192 ciInstanceKlass* ciInstanceKlass::get_canonical_holder(int offset) {
duke@1 193 #ifdef ASSERT
duke@1 194 if (!(offset >= 0 && offset < layout_helper())) {
duke@1 195 tty->print("*** get_canonical_holder(%d) on ", offset);
duke@1 196 this->print();
duke@1 197 tty->print_cr(" ***");
duke@1 198 };
duke@1 199 assert(offset >= 0 && offset < layout_helper(), "offset must be tame");
duke@1 200 #endif
duke@1 201
duke@1 202 if (offset < (instanceOopDesc::header_size() * wordSize)) {
duke@1 203 // All header offsets belong properly to java/lang/Object.
duke@1 204 return CURRENT_ENV->Object_klass();
duke@1 205 }
duke@1 206
duke@1 207 ciInstanceKlass* self = this;
duke@1 208 for (;;) {
duke@1 209 assert(self->is_loaded(), "must be loaded to have size");
duke@1 210 ciInstanceKlass* super = self->super();
duke@1 211 if (super == NULL || !super->contains_field_offset(offset)) {
duke@1 212 return self;
duke@1 213 } else {
duke@1 214 self = super; // return super->get_canonical_holder(offset)
duke@1 215 }
duke@1 216 }
duke@1 217 }
duke@1 218
duke@1 219 // ------------------------------------------------------------------
duke@1 220 // ciInstanceKlass::is_java_lang_Object
duke@1 221 //
duke@1 222 // Is this klass java.lang.Object?
duke@1 223 bool ciInstanceKlass::is_java_lang_Object() {
duke@1 224 return equals(CURRENT_ENV->Object_klass());
duke@1 225 }
duke@1 226
duke@1 227 // ------------------------------------------------------------------
duke@1 228 // ciInstanceKlass::uses_default_loader
duke@1 229 bool ciInstanceKlass::uses_default_loader() {
duke@1 230 VM_ENTRY_MARK;
duke@1 231 return loader() == NULL;
duke@1 232 }
duke@1 233
duke@1 234 // ------------------------------------------------------------------
duke@1 235 // ciInstanceKlass::print_impl
duke@1 236 //
duke@1 237 // Implementation of the print method.
duke@1 238 void ciInstanceKlass::print_impl(outputStream* st) {
duke@1 239 ciKlass::print_impl(st);
duke@1 240 GUARDED_VM_ENTRY(st->print(" loader=0x%x", (address)loader());)
duke@1 241 if (is_loaded()) {
duke@1 242 st->print(" loaded=true initialized=%s finalized=%s subklass=%s size=%d flags=",
duke@1 243 bool_to_str(is_initialized()),
duke@1 244 bool_to_str(has_finalizer()),
duke@1 245 bool_to_str(has_subklass()),
duke@1 246 layout_helper());
duke@1 247
duke@1 248 _flags.print_klass_flags();
duke@1 249
duke@1 250 if (_super) {
duke@1 251 st->print(" super=");
duke@1 252 _super->print_name();
duke@1 253 }
duke@1 254 if (_java_mirror) {
duke@1 255 st->print(" mirror=PRESENT");
duke@1 256 }
duke@1 257 } else {
duke@1 258 st->print(" loaded=false");
duke@1 259 }
duke@1 260 }
duke@1 261
duke@1 262 // ------------------------------------------------------------------
duke@1 263 // ciInstanceKlass::super
duke@1 264 //
duke@1 265 // Get the superklass of this klass.
duke@1 266 ciInstanceKlass* ciInstanceKlass::super() {
duke@1 267 assert(is_loaded(), "must be loaded");
duke@1 268 if (_super == NULL && !is_java_lang_Object()) {
duke@1 269 GUARDED_VM_ENTRY(
duke@1 270 klassOop super_klass = get_instanceKlass()->super();
duke@1 271 _super = CURRENT_ENV->get_object(super_klass)->as_instance_klass();
duke@1 272 )
duke@1 273 }
duke@1 274 return _super;
duke@1 275 }
duke@1 276
duke@1 277 // ------------------------------------------------------------------
duke@1 278 // ciInstanceKlass::java_mirror
duke@1 279 //
duke@1 280 // Get the instance of java.lang.Class corresponding to this klass.
duke@1 281 ciInstance* ciInstanceKlass::java_mirror() {
duke@1 282 assert(is_loaded(), "must be loaded");
duke@1 283 if (_java_mirror == NULL) {
duke@1 284 _java_mirror = ciKlass::java_mirror();
duke@1 285 }
duke@1 286 return _java_mirror;
duke@1 287 }
duke@1 288
duke@1 289 // ------------------------------------------------------------------
duke@1 290 // ciInstanceKlass::unique_concrete_subklass
duke@1 291 ciInstanceKlass* ciInstanceKlass::unique_concrete_subklass() {
duke@1 292 if (!is_loaded()) return NULL; // No change if class is not loaded
duke@1 293 if (!is_abstract()) return NULL; // Only applies to abstract classes.
duke@1 294 if (!has_subklass()) return NULL; // Must have at least one subklass.
duke@1 295 VM_ENTRY_MARK;
duke@1 296 instanceKlass* ik = get_instanceKlass();
duke@1 297 Klass* up = ik->up_cast_abstract();
duke@1 298 assert(up->oop_is_instance(), "must be instanceKlass");
duke@1 299 if (ik == up) {
duke@1 300 return NULL;
duke@1 301 }
duke@1 302 return CURRENT_THREAD_ENV->get_object(up->as_klassOop())->as_instance_klass();
duke@1 303 }
duke@1 304
duke@1 305 // ------------------------------------------------------------------
duke@1 306 // ciInstanceKlass::has_finalizable_subclass
duke@1 307 bool ciInstanceKlass::has_finalizable_subclass() {
duke@1 308 if (!is_loaded()) return true;
duke@1 309 VM_ENTRY_MARK;
duke@1 310 return Dependencies::find_finalizable_subclass(get_instanceKlass()) != NULL;
duke@1 311 }
duke@1 312
duke@1 313 // ------------------------------------------------------------------
duke@1 314 // ciInstanceKlass::get_field_by_offset
duke@1 315 ciField* ciInstanceKlass::get_field_by_offset(int field_offset, bool is_static) {
duke@1 316 if (!is_static) {
duke@1 317 for (int i = 0, len = nof_nonstatic_fields(); i < len; i++) {
duke@1 318 ciField* field = _nonstatic_fields->at(i);
duke@1 319 int field_off = field->offset_in_bytes();
duke@1 320 if (field_off == field_offset)
duke@1 321 return field;
duke@1 322 if (field_off > field_offset)
duke@1 323 break;
duke@1 324 // could do binary search or check bins, but probably not worth it
duke@1 325 }
duke@1 326 return NULL;
duke@1 327 }
duke@1 328 VM_ENTRY_MARK;
duke@1 329 instanceKlass* k = get_instanceKlass();
duke@1 330 fieldDescriptor fd;
duke@1 331 if (!k->find_field_from_offset(field_offset, is_static, &fd)) {
duke@1 332 return NULL;
duke@1 333 }
duke@1 334 ciField* field = new (CURRENT_THREAD_ENV->arena()) ciField(&fd);
duke@1 335 return field;
duke@1 336 }
duke@1 337
duke@1 338 static int sort_field_by_offset(ciField** a, ciField** b) {
duke@1 339 return (*a)->offset_in_bytes() - (*b)->offset_in_bytes();
duke@1 340 // (no worries about 32-bit overflow...)
duke@1 341 }
duke@1 342
duke@1 343 // ------------------------------------------------------------------
duke@1 344 // ciInstanceKlass::compute_nonstatic_fields
duke@1 345 int ciInstanceKlass::compute_nonstatic_fields() {
duke@1 346 assert(is_loaded(), "must be loaded");
duke@1 347
duke@1 348 if (_nonstatic_fields != NULL)
duke@1 349 return _nonstatic_fields->length();
duke@1 350
duke@1 351 // Size in bytes of my fields, including inherited fields.
duke@1 352 // About equal to size_helper() - sizeof(oopDesc).
duke@1 353 int fsize = nonstatic_field_size() * wordSize;
duke@1 354 if (fsize == 0) { // easy shortcut
duke@1 355 Arena* arena = CURRENT_ENV->arena();
duke@1 356 _nonstatic_fields = new (arena) GrowableArray<ciField*>(arena, 0, 0, NULL);
duke@1 357 return 0;
duke@1 358 }
duke@1 359 assert(!is_java_lang_Object(), "bootstrap OK");
duke@1 360
duke@1 361 ciInstanceKlass* super = this->super();
duke@1 362 int super_fsize = 0;
duke@1 363 int super_flen = 0;
duke@1 364 GrowableArray<ciField*>* super_fields = NULL;
duke@1 365 if (super != NULL) {
duke@1 366 super_fsize = super->nonstatic_field_size() * wordSize;
duke@1 367 super_flen = super->nof_nonstatic_fields();
duke@1 368 super_fields = super->_nonstatic_fields;
duke@1 369 assert(super_flen == 0 || super_fields != NULL, "first get nof_fields");
duke@1 370 }
duke@1 371
duke@1 372 // See if I am no larger than my super; if so, I can use his fields.
duke@1 373 if (fsize == super_fsize) {
duke@1 374 _nonstatic_fields = super_fields;
duke@1 375 return super_fields->length();
duke@1 376 }
duke@1 377
duke@1 378 GrowableArray<ciField*>* fields = NULL;
duke@1 379 GUARDED_VM_ENTRY({
duke@1 380 fields = compute_nonstatic_fields_impl(super_fields);
duke@1 381 });
duke@1 382
duke@1 383 if (fields == NULL) {
duke@1 384 // This can happen if this class (java.lang.Class) has invisible fields.
duke@1 385 _nonstatic_fields = super_fields;
duke@1 386 return super_fields->length();
duke@1 387 }
duke@1 388
duke@1 389 int flen = fields->length();
duke@1 390
duke@1 391 // Now sort them by offset, ascending.
duke@1 392 // (In principle, they could mix with superclass fields.)
duke@1 393 fields->sort(sort_field_by_offset);
duke@1 394 #ifdef ASSERT
duke@1 395 int last_offset = sizeof(oopDesc);
duke@1 396 for (int i = 0; i < fields->length(); i++) {
duke@1 397 ciField* field = fields->at(i);
duke@1 398 int offset = field->offset_in_bytes();
duke@1 399 int size = (field->_type == NULL) ? oopSize : field->size_in_bytes();
duke@1 400 assert(last_offset <= offset, "no field overlap");
duke@1 401 if (last_offset > (int)sizeof(oopDesc))
duke@1 402 assert((offset - last_offset) < BytesPerLong, "no big holes");
duke@1 403 // Note: Two consecutive T_BYTE fields will be separated by wordSize-1
duke@1 404 // padding bytes if one of them is declared by a superclass.
duke@1 405 // This is a minor inefficiency classFileParser.cpp.
duke@1 406 last_offset = offset + size;
duke@1 407 }
duke@1 408 assert(last_offset <= (int)sizeof(oopDesc) + fsize, "no overflow");
duke@1 409 #endif
duke@1 410
duke@1 411 _nonstatic_fields = fields;
duke@1 412 return flen;
duke@1 413 }
duke@1 414
duke@1 415 GrowableArray<ciField*>*
duke@1 416 ciInstanceKlass::compute_nonstatic_fields_impl(GrowableArray<ciField*>*
duke@1 417 super_fields) {
duke@1 418 ASSERT_IN_VM;
duke@1 419 Arena* arena = CURRENT_ENV->arena();
duke@1 420 int flen = 0;
duke@1 421 GrowableArray<ciField*>* fields = NULL;
duke@1 422 instanceKlass* k = get_instanceKlass();
duke@1 423 typeArrayOop fields_array = k->fields();
duke@1 424 for (int pass = 0; pass <= 1; pass++) {
duke@1 425 for (int i = 0, alen = fields_array->length(); i < alen; i += instanceKlass::next_offset) {
duke@1 426 fieldDescriptor fd;
duke@1 427 fd.initialize(k->as_klassOop(), i);
duke@1 428 if (fd.is_static()) continue;
duke@1 429 if (pass == 0) {
duke@1 430 flen += 1;
duke@1 431 } else {
duke@1 432 ciField* field = new (arena) ciField(&fd);
duke@1 433 fields->append(field);
duke@1 434 }
duke@1 435 }
duke@1 436
duke@1 437 // Between passes, allocate the array:
duke@1 438 if (pass == 0) {
duke@1 439 if (flen == 0) {
duke@1 440 return NULL; // return nothing if none are locally declared
duke@1 441 }
duke@1 442 if (super_fields != NULL) {
duke@1 443 flen += super_fields->length();
duke@1 444 }
duke@1 445 fields = new (arena) GrowableArray<ciField*>(arena, flen, 0, NULL);
duke@1 446 if (super_fields != NULL) {
duke@1 447 fields->appendAll(super_fields);
duke@1 448 }
duke@1 449 }
duke@1 450 }
duke@1 451 assert(fields->length() == flen, "sanity");
duke@1 452 return fields;
duke@1 453 }
duke@1 454
duke@1 455 // ------------------------------------------------------------------
duke@1 456 // ciInstanceKlass::find_method
duke@1 457 //
duke@1 458 // Find a method in this klass.
duke@1 459 ciMethod* ciInstanceKlass::find_method(ciSymbol* name, ciSymbol* signature) {
duke@1 460 VM_ENTRY_MARK;
duke@1 461 instanceKlass* k = get_instanceKlass();
duke@1 462 symbolOop name_sym = name->get_symbolOop();
duke@1 463 symbolOop sig_sym= signature->get_symbolOop();
duke@1 464
duke@1 465 methodOop m = k->find_method(name_sym, sig_sym);
duke@1 466 if (m == NULL) return NULL;
duke@1 467
duke@1 468 return CURRENT_THREAD_ENV->get_object(m)->as_method();
duke@1 469 }
duke@1 470
duke@1 471 // ------------------------------------------------------------------
duke@1 472 // ciInstanceKlass::is_leaf_type
duke@1 473 bool ciInstanceKlass::is_leaf_type() {
duke@1 474 assert(is_loaded(), "must be loaded");
duke@1 475 if (is_shared()) {
duke@1 476 return is_final(); // approximately correct
duke@1 477 } else {
duke@1 478 return !_has_subklass && (_nof_implementors == 0);
duke@1 479 }
duke@1 480 }
duke@1 481
duke@1 482 // ------------------------------------------------------------------
duke@1 483 // ciInstanceKlass::implementor
duke@1 484 //
duke@1 485 // Report an implementor of this interface.
duke@1 486 // Returns NULL if exact information is not available.
duke@1 487 // Note that there are various races here, since my copy
duke@1 488 // of _nof_implementors might be out of date with respect
duke@1 489 // to results returned by instanceKlass::implementor.
duke@1 490 // This is OK, since any dependencies we decide to assert
duke@1 491 // will be checked later under the Compile_lock.
duke@1 492 ciInstanceKlass* ciInstanceKlass::implementor(int n) {
duke@1 493 if (n > implementors_limit) {
duke@1 494 return NULL;
duke@1 495 }
duke@1 496 ciInstanceKlass* impl = _implementors[n];
duke@1 497 if (impl == NULL) {
duke@1 498 if (_nof_implementors > implementors_limit) {
duke@1 499 return NULL;
duke@1 500 }
duke@1 501 // Go into the VM to fetch the implementor.
duke@1 502 {
duke@1 503 VM_ENTRY_MARK;
duke@1 504 klassOop k = get_instanceKlass()->implementor(n);
duke@1 505 if (k != NULL) {
duke@1 506 impl = CURRENT_THREAD_ENV->get_object(k)->as_instance_klass();
duke@1 507 }
duke@1 508 }
duke@1 509 // Memoize this result.
duke@1 510 if (!is_shared()) {
duke@1 511 _implementors[n] = (impl == NULL)? this: impl;
duke@1 512 }
duke@1 513 } else if (impl == this) {
duke@1 514 impl = NULL; // memoized null result from a VM query
duke@1 515 }
duke@1 516 return impl;
duke@1 517 }