Mercurial > hg > graal-jvmci-8
comparison src/share/vm/oops/klass.cpp @ 18041:52b4284cb496
Merge with jdk8u20-b26
author | Gilles Duboscq <duboscq@ssw.jku.at> |
---|---|
date | Wed, 15 Oct 2014 16:02:50 +0200 |
parents | 4ca6dc0799b6 7384f6a12fc1 |
children | eaf39a954227 |
comparison
equal
deleted
inserted
replaced
17606:45d7b2c7029d | 18041:52b4284cb496 |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. | 2 * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | 4 * |
5 * This code is free software; you can redistribute it and/or modify it | 5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as | 6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
127 assert(k->is_klass(), "argument must be a class"); | 127 assert(k->is_klass(), "argument must be a class"); |
128 return is_subclass_of(k); | 128 return is_subclass_of(k); |
129 } | 129 } |
130 | 130 |
131 | 131 |
132 Method* Klass::uncached_lookup_method(Symbol* name, Symbol* signature) const { | 132 Method* Klass::uncached_lookup_method(Symbol* name, Symbol* signature, MethodLookupMode mode) const { |
133 #ifdef ASSERT | 133 #ifdef ASSERT |
134 tty->print_cr("Error: uncached_lookup_method called on a klass oop." | 134 tty->print_cr("Error: uncached_lookup_method called on a klass oop." |
135 " Likely error: reflection method does not correctly" | 135 " Likely error: reflection method does not correctly" |
136 " wrap return value in a mirror object."); | 136 " wrap return value in a mirror object."); |
137 #endif | 137 #endif |
374 super->set_subklass(this); | 374 super->set_subklass(this); |
375 debug_only(verify();) | 375 debug_only(verify();) |
376 } | 376 } |
377 | 377 |
378 bool Klass::is_loader_alive(BoolObjectClosure* is_alive) { | 378 bool Klass::is_loader_alive(BoolObjectClosure* is_alive) { |
379 assert(ClassLoaderDataGraph::contains((address)this), "is in the metaspace"); | |
380 | |
381 #ifdef ASSERT | 379 #ifdef ASSERT |
382 // The class is alive iff the class loader is alive. | 380 // The class is alive iff the class loader is alive. |
383 oop loader = class_loader(); | 381 oop loader = class_loader(); |
384 bool loader_alive = (loader == NULL) || is_alive->do_object_b(loader); | 382 bool loader_alive = (loader == NULL) || is_alive->do_object_b(loader); |
385 #endif // ASSERT | 383 #endif // ASSERT |
483 void Klass::oops_do(OopClosure* cl) { | 481 void Klass::oops_do(OopClosure* cl) { |
484 cl->do_oop(&_java_mirror); | 482 cl->do_oop(&_java_mirror); |
485 } | 483 } |
486 | 484 |
487 void Klass::remove_unshareable_info() { | 485 void Klass::remove_unshareable_info() { |
488 if (!DumpSharedSpaces) { | 486 assert (DumpSharedSpaces, "only called for DumpSharedSpaces"); |
489 // Clean up after OOM during class loading | 487 |
490 if (class_loader_data() != NULL) { | |
491 class_loader_data()->remove_class(this); | |
492 } | |
493 } | |
494 set_subklass(NULL); | 488 set_subklass(NULL); |
495 set_next_sibling(NULL); | 489 set_next_sibling(NULL); |
496 // Clear the java mirror | 490 // Clear the java mirror |
497 set_java_mirror(NULL); | 491 set_java_mirror(NULL); |
498 set_next_link(NULL); | 492 set_next_link(NULL); |
500 // Null out class_loader_data because we don't share that yet. | 494 // Null out class_loader_data because we don't share that yet. |
501 set_class_loader_data(NULL); | 495 set_class_loader_data(NULL); |
502 } | 496 } |
503 | 497 |
504 void Klass::restore_unshareable_info(TRAPS) { | 498 void Klass::restore_unshareable_info(TRAPS) { |
505 ClassLoaderData* loader_data = ClassLoaderData::the_null_class_loader_data(); | 499 TRACE_INIT_ID(this); |
506 // Restore class_loader_data to the null class loader data | 500 // If an exception happened during CDS restore, some of these fields may already be |
507 set_class_loader_data(loader_data); | 501 // set. We leave the class on the CLD list, even if incomplete so that we don't |
508 | 502 // modify the CLD list outside a safepoint. |
509 // Add to null class loader list first before creating the mirror | 503 if (class_loader_data() == NULL) { |
510 // (same order as class file parsing) | 504 ClassLoaderData* loader_data = ClassLoaderData::the_null_class_loader_data(); |
511 loader_data->add_class(this); | 505 // Restore class_loader_data to the null class loader data |
506 set_class_loader_data(loader_data); | |
507 | |
508 // Add to null class loader list first before creating the mirror | |
509 // (same order as class file parsing) | |
510 loader_data->add_class(this); | |
511 } | |
512 | 512 |
513 // Recreate the class mirror. The protection_domain is always null for | 513 // Recreate the class mirror. The protection_domain is always null for |
514 // boot loader, for now. | 514 // boot loader, for now. |
515 java_lang_Class::create_mirror(this, Handle(NULL), CHECK); | 515 // Only recreate it if not present. A previous attempt to restore may have |
516 // gotten an OOM later but keep the mirror if it was created. | |
517 if (java_mirror() == NULL) { | |
518 java_lang_Class::create_mirror(this, Handle(NULL), CHECK); | |
519 } | |
516 } | 520 } |
517 | 521 |
518 Klass* Klass::array_klass_or_null(int rank) { | 522 Klass* Klass::array_klass_or_null(int rank) { |
519 EXCEPTION_MARK; | 523 EXCEPTION_MARK; |
520 // No exception can be thrown by array_klass_impl when called with or_null == true. | 524 // No exception can be thrown by array_klass_impl when called with or_null == true. |
638 } | 642 } |
639 #endif // INCLUDE_SERVICES | 643 #endif // INCLUDE_SERVICES |
640 | 644 |
641 // Verification | 645 // Verification |
642 | 646 |
643 void Klass::verify_on(outputStream* st, bool check_dictionary) { | 647 void Klass::verify_on(outputStream* st) { |
644 | 648 |
645 // This can be expensive, but it is worth checking that this klass is actually | 649 // This can be expensive, but it is worth checking that this klass is actually |
646 // in the CLD graph but not in production. | 650 // in the CLD graph but not in production. |
647 assert(ClassLoaderDataGraph::contains((address)this), "Should be"); | 651 assert(Metaspace::contains((address)this), "Should be"); |
648 | 652 |
649 guarantee(this->is_klass(),"should be klass"); | 653 guarantee(this->is_klass(),"should be klass"); |
650 | 654 |
651 if (super() != NULL) { | 655 if (super() != NULL) { |
652 guarantee(super()->is_klass(), "should be klass"); | 656 guarantee(super()->is_klass(), "should be klass"); |