src/share/vm/oops/klass.cpp

Print this page


   1 /*
   2  * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   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
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "classfile/javaClasses.hpp"
  27 #include "classfile/dictionary.hpp"
  28 #include "classfile/systemDictionary.hpp"
  29 #include "classfile/vmSymbols.hpp"
  30 #include "gc_implementation/shared/markSweep.inline.hpp"
  31 #include "gc_interface/collectedHeap.inline.hpp"

  32 #include "memory/metadataFactory.hpp"
  33 #include "memory/oopFactory.hpp"
  34 #include "memory/resourceArea.hpp"
  35 #include "oops/instanceKlass.hpp"
  36 #include "oops/klass.inline.hpp"
  37 #include "oops/oop.inline2.hpp"
  38 #include "runtime/atomic.hpp"
  39 #include "utilities/stack.hpp"
  40 #ifndef SERIALGC
  41 #include "gc_implementation/parallelScavenge/psParallelCompact.hpp"
  42 #include "gc_implementation/parallelScavenge/psPromotionManager.hpp"
  43 #include "gc_implementation/parallelScavenge/psScavenge.hpp"
  44 #endif
  45 
  46 void Klass::set_name(Symbol* n) {
  47   _name = n;
  48   if (_name != NULL) _name->increment_refcount();
  49 }
  50 
  51 bool Klass::is_subclass_of(Klass* k) const {


 607   obj->print_address_on(st);
 608 
 609   if (WizardMode) {
 610      // print header
 611      obj->mark()->print_on(st);
 612   }
 613 
 614   // print class
 615   st->print(" - klass: ");
 616   obj->klass()->print_value_on(st);
 617   st->cr();
 618 }
 619 
 620 void Klass::oop_print_value_on(oop obj, outputStream* st) {
 621   // print title
 622   ResourceMark rm;              // Cannot print in debug mode without this
 623   st->print("%s", internal_name());
 624   obj->print_address_on(st);
 625 }
 626 











 627 
 628 // Verification
 629 
 630 void Klass::verify_on(outputStream* st) {
 631   guarantee(!Universe::heap()->is_in_reserved(this), "Shouldn't be");
 632   guarantee(this->is_metadata(), "should be in metaspace");
 633 
 634   assert(ClassLoaderDataGraph::contains((address)this), "Should be");
 635 
 636   guarantee(this->is_klass(),"should be klass");
 637 
 638   if (super() != NULL) {
 639     guarantee(super()->is_metadata(), "should be in metaspace");
 640     guarantee(super()->is_klass(), "should be klass");
 641   }
 642   if (secondary_super_cache() != NULL) {
 643     Klass* ko = secondary_super_cache();
 644     guarantee(ko->is_metadata(), "should be in metaspace");
 645     guarantee(ko->is_klass(), "should be klass");
 646   }


   1 /*
   2  * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   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
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "classfile/javaClasses.hpp"
  27 #include "classfile/dictionary.hpp"
  28 #include "classfile/systemDictionary.hpp"
  29 #include "classfile/vmSymbols.hpp"
  30 #include "gc_implementation/shared/markSweep.inline.hpp"
  31 #include "gc_interface/collectedHeap.inline.hpp"
  32 #include "memory/heapInspection.hpp"
  33 #include "memory/metadataFactory.hpp"
  34 #include "memory/oopFactory.hpp"
  35 #include "memory/resourceArea.hpp"
  36 #include "oops/instanceKlass.hpp"
  37 #include "oops/klass.inline.hpp"
  38 #include "oops/oop.inline2.hpp"
  39 #include "runtime/atomic.hpp"
  40 #include "utilities/stack.hpp"
  41 #ifndef SERIALGC
  42 #include "gc_implementation/parallelScavenge/psParallelCompact.hpp"
  43 #include "gc_implementation/parallelScavenge/psPromotionManager.hpp"
  44 #include "gc_implementation/parallelScavenge/psScavenge.hpp"
  45 #endif
  46 
  47 void Klass::set_name(Symbol* n) {
  48   _name = n;
  49   if (_name != NULL) _name->increment_refcount();
  50 }
  51 
  52 bool Klass::is_subclass_of(Klass* k) const {


 608   obj->print_address_on(st);
 609 
 610   if (WizardMode) {
 611      // print header
 612      obj->mark()->print_on(st);
 613   }
 614 
 615   // print class
 616   st->print(" - klass: ");
 617   obj->klass()->print_value_on(st);
 618   st->cr();
 619 }
 620 
 621 void Klass::oop_print_value_on(oop obj, outputStream* st) {
 622   // print title
 623   ResourceMark rm;              // Cannot print in debug mode without this
 624   st->print("%s", internal_name());
 625   obj->print_address_on(st);
 626 }
 627 
 628 #if INCLUDE_SERVICES
 629 // Size Statistics
 630 void Klass::collect_statistics(KlassSizeStats *sz) const {
 631   sz->_klass_bytes = sz->count(this);
 632   sz->_mirror_bytes = sz->count(java_mirror());
 633   sz->_secondary_supers_bytes = sz->count_array(secondary_supers());
 634 
 635   sz->_ro_bytes += sz->_secondary_supers_bytes;
 636   sz->_rw_bytes += sz->_klass_bytes + sz->_mirror_bytes;
 637 }
 638 #endif // INCLUDE_SERVICES
 639 
 640 // Verification
 641 
 642 void Klass::verify_on(outputStream* st) {
 643   guarantee(!Universe::heap()->is_in_reserved(this), "Shouldn't be");
 644   guarantee(this->is_metadata(), "should be in metaspace");
 645 
 646   assert(ClassLoaderDataGraph::contains((address)this), "Should be");
 647 
 648   guarantee(this->is_klass(),"should be klass");
 649 
 650   if (super() != NULL) {
 651     guarantee(super()->is_metadata(), "should be in metaspace");
 652     guarantee(super()->is_klass(), "should be klass");
 653   }
 654   if (secondary_super_cache() != NULL) {
 655     Klass* ko = secondary_super_cache();
 656     guarantee(ko->is_metadata(), "should be in metaspace");
 657     guarantee(ko->is_klass(), "should be klass");
 658   }