< prev index next >

src/hotspot/share/classfile/javaClasses.cpp

Print this page
rev 49800 : 8199852: Print more information about class loaders in LinkageErrors.
Reviewed-by: dholmes


4117   }
4118   return false;
4119 }
4120 
4121 oop java_lang_ClassLoader::non_reflection_class_loader(oop loader) {
4122   // See whether this is one of the class loaders associated with
4123   // the generated bytecodes for reflection, and if so, "magically"
4124   // delegate to its parent to prevent class loading from occurring
4125   // in places where applications using reflection didn't expect it.
4126   if (is_reflection_class_loader(loader)) {
4127     return parent(loader);
4128   }
4129   return loader;
4130 }
4131 
4132 oop java_lang_ClassLoader::unnamedModule(oop loader) {
4133   assert(is_instance(loader), "loader must be oop");
4134   return loader->obj_field(unnamedModule_offset);
4135 }
4136 










































4137 // Support for java_lang_System
4138 //
4139 #define SYSTEM_FIELDS_DO(macro) \
4140   macro(static_in_offset,  k, "in",  input_stream_signature, true); \
4141   macro(static_out_offset, k, "out", print_stream_signature, true); \
4142   macro(static_err_offset, k, "err", print_stream_signature, true); \
4143   macro(static_security_offset, k, "security", security_manager_signature, true)
4144 
4145 void java_lang_System::compute_offsets() {
4146   InstanceKlass* k = SystemDictionary::System_klass();
4147   SYSTEM_FIELDS_DO(FIELD_COMPUTE_OFFSET);
4148 }
4149 
4150 #if INCLUDE_CDS
4151 void java_lang_System::serialize(SerializeClosure* f) {
4152    SYSTEM_FIELDS_DO(FIELD_SERIALIZE_OFFSET);
4153 }
4154 #endif
4155 
4156 int java_lang_System::in_offset_in_bytes() { return static_in_offset; }




4117   }
4118   return false;
4119 }
4120 
4121 oop java_lang_ClassLoader::non_reflection_class_loader(oop loader) {
4122   // See whether this is one of the class loaders associated with
4123   // the generated bytecodes for reflection, and if so, "magically"
4124   // delegate to its parent to prevent class loading from occurring
4125   // in places where applications using reflection didn't expect it.
4126   if (is_reflection_class_loader(loader)) {
4127     return parent(loader);
4128   }
4129   return loader;
4130 }
4131 
4132 oop java_lang_ClassLoader::unnamedModule(oop loader) {
4133   assert(is_instance(loader), "loader must be oop");
4134   return loader->obj_field(unnamedModule_offset);
4135 }
4136 
4137 // Caller needs ResourceMark.
4138 const char* java_lang_ClassLoader::describe_external(const oop loader) {
4139   if (loader == NULL) {
4140     return "<bootstrap>";
4141   }
4142 
4143   bool well_known_loader = SystemDictionary::is_system_class_loader(loader) ||
4144                            SystemDictionary::is_platform_class_loader(loader);
4145 
4146   const char* name = NULL;
4147   oop nameOop = java_lang_ClassLoader::name(loader);
4148   if (nameOop != NULL) {
4149     name = java_lang_String::as_utf8_string(nameOop);
4150   }
4151   if (name == NULL) {
4152     // Use placeholder for missing name to have fixed message format.
4153     name = "<unnamed>";
4154   }
4155 
4156   stringStream ss;
4157   ss.print("\"%s\" (instance of %s", name, loader->klass()->external_name());
4158   if (!well_known_loader) {
4159     const char* parentName = NULL;
4160     oop pl = java_lang_ClassLoader::parent(loader);
4161     if (pl != NULL) {
4162       oop parentNameOop = java_lang_ClassLoader::name(pl);
4163       if (parentNameOop != NULL) {
4164         parentName = java_lang_String::as_utf8_string(parentNameOop);
4165         if (parentName == NULL) {
4166           parentName = "<unnamed>";
4167         }
4168       }
4169       ss.print(", child of \"%s\" %s", parentName, pl->klass()->external_name());
4170     } else {
4171       ss.print(", child of <bootstrap>");
4172     }
4173   }
4174   ss.print(")");
4175 
4176   return ss.as_string();
4177 }
4178 
4179 // Support for java_lang_System
4180 //
4181 #define SYSTEM_FIELDS_DO(macro) \
4182   macro(static_in_offset,  k, "in",  input_stream_signature, true); \
4183   macro(static_out_offset, k, "out", print_stream_signature, true); \
4184   macro(static_err_offset, k, "err", print_stream_signature, true); \
4185   macro(static_security_offset, k, "security", security_manager_signature, true)
4186 
4187 void java_lang_System::compute_offsets() {
4188   InstanceKlass* k = SystemDictionary::System_klass();
4189   SYSTEM_FIELDS_DO(FIELD_COMPUTE_OFFSET);
4190 }
4191 
4192 #if INCLUDE_CDS
4193 void java_lang_System::serialize(SerializeClosure* f) {
4194    SYSTEM_FIELDS_DO(FIELD_SERIALIZE_OFFSET);
4195 }
4196 #endif
4197 
4198 int java_lang_System::in_offset_in_bytes() { return static_in_offset; }


< prev index next >