< prev index next >

src/hotspot/share/classfile/javaClasses.cpp

Print this page
rev 49271 : 8199852: Print more information about class loaders in LinkageErrors.


4090   }
4091   return false;
4092 }
4093 
4094 oop java_lang_ClassLoader::non_reflection_class_loader(oop loader) {
4095   // See whether this is one of the class loaders associated with
4096   // the generated bytecodes for reflection, and if so, "magically"
4097   // delegate to its parent to prevent class loading from occurring
4098   // in places where applications using reflection didn't expect it.
4099   if (is_reflection_class_loader(loader)) {
4100     return parent(loader);
4101   }
4102   return loader;
4103 }
4104 
4105 oop java_lang_ClassLoader::unnamedModule(oop loader) {
4106   assert(is_instance(loader), "loader must be oop");
4107   return loader->obj_field(unnamedModule_offset);
4108 }
4109 









































4110 // Support for java_lang_System
4111 //
4112 #define SYSTEM_FIELDS_DO(macro) \
4113   macro(static_in_offset,  k, "in",  input_stream_signature, true); \
4114   macro(static_out_offset, k, "out", print_stream_signature, true); \
4115   macro(static_err_offset, k, "err", print_stream_signature, true); \
4116   macro(static_security_offset, k, "security", security_manager_signature, true)
4117 
4118 void java_lang_System::compute_offsets() {
4119   InstanceKlass* k = SystemDictionary::System_klass();
4120   SYSTEM_FIELDS_DO(FIELD_COMPUTE_OFFSET);
4121 }
4122 
4123 #if INCLUDE_CDS
4124 void java_lang_System::serialize(SerializeClosure* f) {
4125    SYSTEM_FIELDS_DO(FIELD_SERIALIZE_OFFSET);
4126 }
4127 #endif
4128 
4129 int java_lang_System::in_offset_in_bytes() { return static_in_offset; }




4090   }
4091   return false;
4092 }
4093 
4094 oop java_lang_ClassLoader::non_reflection_class_loader(oop loader) {
4095   // See whether this is one of the class loaders associated with
4096   // the generated bytecodes for reflection, and if so, "magically"
4097   // delegate to its parent to prevent class loading from occurring
4098   // in places where applications using reflection didn't expect it.
4099   if (is_reflection_class_loader(loader)) {
4100     return parent(loader);
4101   }
4102   return loader;
4103 }
4104 
4105 oop java_lang_ClassLoader::unnamedModule(oop loader) {
4106   assert(is_instance(loader), "loader must be oop");
4107   return loader->obj_field(unnamedModule_offset);
4108 }
4109 
4110 // Caller needs ResourceMark.
4111 const char* java_lang_ClassLoader::describe_external(const oop loader) {
4112   if (loader == NULL) {
4113     return "<bootstrap>";
4114   }
4115 
4116   const char* name = NULL;
4117   oop nameOop = java_lang_ClassLoader::name(loader);
4118   if (nameOop != NULL) {
4119     name = java_lang_String::as_utf8_string(nameOop);
4120   }
4121 
4122   stringStream ss;
4123   const char *seperator;
4124   // If we have a name set for this loader, display it. Otherwise use
4125   // the class of the loader.
4126   if (name != NULL) {
4127     ss.print("\"%s\" (instance of %s", name, loader->klass()->external_name());
4128     seperator = ", ";
4129   } else {
4130     ss.print("%s", loader->klass()->external_name());
4131     seperator = " (";
4132   }
4133 
4134   oop pl = java_lang_ClassLoader::parent(loader);
4135   if (pl != NULL) {
4136     ss.print("%sparent: ", seperator);
4137     oop parentNameOop = java_lang_ClassLoader::name(pl);
4138     if (parentNameOop != NULL) {
4139       const char* parentName = java_lang_String::as_utf8_string(parentNameOop);
4140       if (parentName != NULL) {
4141         ss.print("\"%s\" ", parentName);
4142       }
4143     }
4144     ss.print("%s)", pl->klass()->external_name());
4145   } else {
4146     ss.print("%sparent: <bootstrap>)", seperator);
4147   }
4148   return ss.as_string();
4149 }
4150 
4151 // Support for java_lang_System
4152 //
4153 #define SYSTEM_FIELDS_DO(macro) \
4154   macro(static_in_offset,  k, "in",  input_stream_signature, true); \
4155   macro(static_out_offset, k, "out", print_stream_signature, true); \
4156   macro(static_err_offset, k, "err", print_stream_signature, true); \
4157   macro(static_security_offset, k, "security", security_manager_signature, true)
4158 
4159 void java_lang_System::compute_offsets() {
4160   InstanceKlass* k = SystemDictionary::System_klass();
4161   SYSTEM_FIELDS_DO(FIELD_COMPUTE_OFFSET);
4162 }
4163 
4164 #if INCLUDE_CDS
4165 void java_lang_System::serialize(SerializeClosure* f) {
4166    SYSTEM_FIELDS_DO(FIELD_SERIALIZE_OFFSET);
4167 }
4168 #endif
4169 
4170 int java_lang_System::in_offset_in_bytes() { return static_in_offset; }


< prev index next >