< prev index next >

src/hotspot/share/jfr/leakprofiler/checkpoint/objectSampleDescription.cpp

Print this page
rev 58565 : 8238358: Implementation of JEP 371: Hidden Classes
Reviewed-by: duke
Contributed-by: mandy.chung@oracle.com, lois.foltan@oracle.com, david.holmes@oracle.com, harold.seigel@oracle.com, serguei.spitsyn@oracle.com, alex.buckley@oracle.com, jamsheed.c.m@oracle.com
   1 /*
   2  * Copyright (c) 2017, 2019, 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  *


 145   }
 146 }
 147 
 148 void ObjectSampleDescription::write_class_name() {
 149   assert(_object->is_a(SystemDictionary::Class_klass()), "invariant");
 150   const Klass* const k = java_lang_Class::as_Klass(_object);
 151   if (k == NULL) {
 152     // might represent a primitive
 153     const Klass* const ak = java_lang_Class::array_klass_acquire(_object);
 154     // If ak is NULL, this is most likely a mirror associated with a
 155     // jvmti redefine/retransform scratch klass. We can't get any additional
 156     // information from it.
 157     if (ak != NULL) {
 158       write_text(type2name(java_lang_Class::primitive_type(_object)));
 159     }
 160     return;
 161   }
 162 
 163   if (k->is_instance_klass()) {
 164     const InstanceKlass* ik = InstanceKlass::cast(k);
 165     if (ik->is_unsafe_anonymous()) {
 166       return;
 167     }
 168     assert(!ik->is_unsafe_anonymous(), "invariant");
 169     const Symbol* name = ik->name();
 170     if (name != NULL) {
 171       write_text("Class Name: ");
 172       write_text(name->as_klass_external_name());
 173     }
 174   }
 175 }
 176 
 177 void ObjectSampleDescription::write_thread_group_name() {
 178   assert(_object->is_a(SystemDictionary::ThreadGroup_klass()), "invariant");
 179   const char* tg_name = java_lang_ThreadGroup::name(_object);
 180   if (tg_name != NULL) {
 181     write_text("Thread Group: ");
 182     write_text(tg_name);
 183   }
 184 }
 185 
 186 void ObjectSampleDescription::write_thread_name() {
 187   assert(_object->is_a(SystemDictionary::Thread_klass()), "invariant");
 188   oop name = java_lang_Thread::name(_object);


   1 /*
   2  * Copyright (c) 2017, 2020, 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  *


 145   }
 146 }
 147 
 148 void ObjectSampleDescription::write_class_name() {
 149   assert(_object->is_a(SystemDictionary::Class_klass()), "invariant");
 150   const Klass* const k = java_lang_Class::as_Klass(_object);
 151   if (k == NULL) {
 152     // might represent a primitive
 153     const Klass* const ak = java_lang_Class::array_klass_acquire(_object);
 154     // If ak is NULL, this is most likely a mirror associated with a
 155     // jvmti redefine/retransform scratch klass. We can't get any additional
 156     // information from it.
 157     if (ak != NULL) {
 158       write_text(type2name(java_lang_Class::primitive_type(_object)));
 159     }
 160     return;
 161   }
 162 
 163   if (k->is_instance_klass()) {
 164     const InstanceKlass* ik = InstanceKlass::cast(k);
 165     if (ik->is_unsafe_anonymous() || ik->is_hidden()) {
 166       return;
 167     }

 168     const Symbol* name = ik->name();
 169     if (name != NULL) {
 170       write_text("Class Name: ");
 171       write_text(name->as_klass_external_name());
 172     }
 173   }
 174 }
 175 
 176 void ObjectSampleDescription::write_thread_group_name() {
 177   assert(_object->is_a(SystemDictionary::ThreadGroup_klass()), "invariant");
 178   const char* tg_name = java_lang_ThreadGroup::name(_object);
 179   if (tg_name != NULL) {
 180     write_text("Thread Group: ");
 181     write_text(tg_name);
 182   }
 183 }
 184 
 185 void ObjectSampleDescription::write_thread_name() {
 186   assert(_object->is_a(SystemDictionary::Thread_klass()), "invariant");
 187   oop name = java_lang_Thread::name(_object);


< prev index next >