hotspot/src/share/vm/oops/instanceKlass.cpp
changeset 35917 463d67f86eaa
parent 35900 d64cf9290fc4
child 36300 5b47f168b948
equal deleted inserted replaced
35912:679f5181ef91 35917:463d67f86eaa
     1 /*
     1 /*
     2  * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 1997, 2015, 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.
    22  *
    22  *
    23  */
    23  */
    24 
    24 
    25 #include "precompiled.hpp"
    25 #include "precompiled.hpp"
    26 #include "classfile/classFileParser.hpp"
    26 #include "classfile/classFileParser.hpp"
       
    27 #include "classfile/classFileStream.hpp"
    27 #include "classfile/javaClasses.hpp"
    28 #include "classfile/javaClasses.hpp"
    28 #include "classfile/systemDictionary.hpp"
    29 #include "classfile/systemDictionary.hpp"
    29 #include "classfile/verifier.hpp"
    30 #include "classfile/verifier.hpp"
    30 #include "classfile/vmSymbols.hpp"
    31 #include "classfile/vmSymbols.hpp"
    31 #include "code/dependencyContext.hpp"
    32 #include "code/dependencyContext.hpp"
    33 #include "gc/shared/collectedHeap.inline.hpp"
    34 #include "gc/shared/collectedHeap.inline.hpp"
    34 #include "gc/shared/specialized_oop_closures.hpp"
    35 #include "gc/shared/specialized_oop_closures.hpp"
    35 #include "interpreter/oopMapCache.hpp"
    36 #include "interpreter/oopMapCache.hpp"
    36 #include "interpreter/rewriter.hpp"
    37 #include "interpreter/rewriter.hpp"
    37 #include "jvmtifiles/jvmti.h"
    38 #include "jvmtifiles/jvmti.h"
       
    39 #include "logging/log.hpp"
    38 #include "memory/heapInspection.hpp"
    40 #include "memory/heapInspection.hpp"
    39 #include "memory/iterator.inline.hpp"
    41 #include "memory/iterator.inline.hpp"
    40 #include "memory/metadataFactory.hpp"
    42 #include "memory/metadataFactory.hpp"
    41 #include "memory/oopFactory.hpp"
    43 #include "memory/oopFactory.hpp"
    42 #include "oops/fieldStreams.hpp"
    44 #include "oops/fieldStreams.hpp"
  2902 
  2904 
  2903 const char* InstanceKlass::internal_name() const {
  2905 const char* InstanceKlass::internal_name() const {
  2904   return external_name();
  2906   return external_name();
  2905 }
  2907 }
  2906 
  2908 
       
  2909 void InstanceKlass::print_loading_log(LogLevel::type type,
       
  2910                                       ClassLoaderData* loader_data,
       
  2911                                       const ClassFileStream* cfs) const {
       
  2912   ResourceMark rm;
       
  2913   outputStream* log;
       
  2914 
       
  2915   assert(type == LogLevel::Info || type == LogLevel::Debug, "sanity");
       
  2916 
       
  2917   if (type == LogLevel::Info) {
       
  2918     log = LogHandle(classload)::info_stream();
       
  2919   } else {
       
  2920     assert(type == LogLevel::Debug,
       
  2921            "print_loading_log supports only Debug and Info levels");
       
  2922     log = LogHandle(classload)::debug_stream();
       
  2923   }
       
  2924 
       
  2925   // Name and class hierarchy info
       
  2926   log->print("%s", external_name());
       
  2927 
       
  2928   // Source
       
  2929   if (cfs != NULL) {
       
  2930     if (cfs->source() != NULL) {
       
  2931       log->print(" source: %s", cfs->source());
       
  2932     } else if (loader_data == ClassLoaderData::the_null_class_loader_data()) {
       
  2933       Thread* THREAD = Thread::current();
       
  2934       Klass* caller =
       
  2935             THREAD->is_Java_thread()
       
  2936                 ? ((JavaThread*)THREAD)->security_get_caller_class(1)
       
  2937                 : NULL;
       
  2938       // caller can be NULL, for example, during a JVMTI VM_Init hook
       
  2939       if (caller != NULL) {
       
  2940         log->print(" source: instance of %s", caller->external_name());
       
  2941       } else {
       
  2942         // source is unknown
       
  2943       }
       
  2944     } else {
       
  2945       Handle class_loader(loader_data->class_loader());
       
  2946       log->print(" source: %s", class_loader->klass()->external_name());
       
  2947     }
       
  2948   } else {
       
  2949     log->print(" source: shared objects file");
       
  2950   }
       
  2951 
       
  2952   if (type == LogLevel::Debug) {
       
  2953     // Class hierarchy info
       
  2954     log->print(" klass: " INTPTR_FORMAT " super: " INTPTR_FORMAT,
       
  2955                p2i(this),  p2i(superklass()));
       
  2956 
       
  2957     if (local_interfaces() != NULL && local_interfaces()->length() > 0) {
       
  2958       log->print(" interfaces:");
       
  2959       int length = local_interfaces()->length();
       
  2960       for (int i = 0; i < length; i++) {
       
  2961         log->print(" " INTPTR_FORMAT,
       
  2962                    p2i(InstanceKlass::cast(local_interfaces()->at(i))));
       
  2963       }
       
  2964     }
       
  2965 
       
  2966     // Class loader
       
  2967     log->print(" loader: [");
       
  2968     loader_data->print_value_on(log);
       
  2969     log->print("]");
       
  2970 
       
  2971     // Classfile checksum
       
  2972     if (cfs) {
       
  2973       log->print(" bytes: %d checksum: %08x",
       
  2974                  cfs->length(),
       
  2975                  ClassLoader::crc32(0, (const char*)cfs->buffer(),
       
  2976                  cfs->length()));
       
  2977     }
       
  2978   }
       
  2979   log->cr();
       
  2980 }
       
  2981 
  2907 #if INCLUDE_SERVICES
  2982 #if INCLUDE_SERVICES
  2908 // Size Statistics
  2983 // Size Statistics
  2909 void InstanceKlass::collect_statistics(KlassSizeStats *sz) const {
  2984 void InstanceKlass::collect_statistics(KlassSizeStats *sz) const {
  2910   Klass::collect_statistics(sz);
  2985   Klass::collect_statistics(sz);
  2911 
  2986