src/hotspot/share/classfile/javaClasses.cpp
changeset 52319 625f6c742392
parent 52062 8dbf1a13af49
child 52411 35ebea32a23c
equal deleted inserted replaced
52318:124af9276e44 52319:625f6c742392
    48 #include "oops/method.inline.hpp"
    48 #include "oops/method.inline.hpp"
    49 #include "oops/objArrayOop.inline.hpp"
    49 #include "oops/objArrayOop.inline.hpp"
    50 #include "oops/oop.inline.hpp"
    50 #include "oops/oop.inline.hpp"
    51 #include "oops/symbol.hpp"
    51 #include "oops/symbol.hpp"
    52 #include "oops/typeArrayOop.inline.hpp"
    52 #include "oops/typeArrayOop.inline.hpp"
       
    53 #include "prims/jvmtiExport.hpp"
    53 #include "prims/resolvedMethodTable.hpp"
    54 #include "prims/resolvedMethodTable.hpp"
    54 #include "runtime/fieldDescriptor.inline.hpp"
    55 #include "runtime/fieldDescriptor.inline.hpp"
    55 #include "runtime/frame.inline.hpp"
    56 #include "runtime/frame.inline.hpp"
    56 #include "runtime/handles.inline.hpp"
    57 #include "runtime/handles.inline.hpp"
    57 #include "runtime/interfaceSupport.inline.hpp"
    58 #include "runtime/interfaceSupport.inline.hpp"
   123                            bool is_static = false) {
   124                            bool is_static = false) {
   124   fieldDescriptor fd;
   125   fieldDescriptor fd;
   125   if (ik == NULL) {
   126   if (ik == NULL) {
   126     ResourceMark rm;
   127     ResourceMark rm;
   127     log_error(class)("Mismatch JDK version for field: %s type: %s", name_symbol->as_C_string(), signature_symbol->as_C_string());
   128     log_error(class)("Mismatch JDK version for field: %s type: %s", name_symbol->as_C_string(), signature_symbol->as_C_string());
   128     vm_exit_during_initialization("Invalid layout of preloaded class");
   129     vm_exit_during_initialization("Invalid layout of well-known class");
   129   }
   130   }
   130 
   131 
   131   if (!ik->find_local_field(name_symbol, signature_symbol, &fd) || fd.is_static() != is_static) {
   132   if (!ik->find_local_field(name_symbol, signature_symbol, &fd) || fd.is_static() != is_static) {
   132     ResourceMark rm;
   133     ResourceMark rm;
   133     log_error(class)("Invalid layout of %s field: %s type: %s", ik->external_name(),
   134     log_error(class)("Invalid layout of %s field: %s type: %s", ik->external_name(),
   136     // Prints all fields and offsets
   137     // Prints all fields and offsets
   137     Log(class) lt;
   138     Log(class) lt;
   138     LogStream ls(lt.error());
   139     LogStream ls(lt.error());
   139     ik->print_on(&ls);
   140     ik->print_on(&ls);
   140 #endif //PRODUCT
   141 #endif //PRODUCT
   141     vm_exit_during_initialization("Invalid layout of preloaded class: use -Xlog:class+load=info to see the origin of the problem class");
   142     vm_exit_during_initialization("Invalid layout of well-known class: use -Xlog:class+load=info to see the origin of the problem class");
   142   }
   143   }
   143   dest_offset = fd.offset();
   144   dest_offset = fd.offset();
   144 }
   145 }
   145 
   146 
   146 // Overloading to pass name as a string.
   147 // Overloading to pass name as a string.
   149                            bool is_static = false) {
   150                            bool is_static = false) {
   150   TempNewSymbol name = SymbolTable::probe(name_string, (int)strlen(name_string));
   151   TempNewSymbol name = SymbolTable::probe(name_string, (int)strlen(name_string));
   151   if (name == NULL) {
   152   if (name == NULL) {
   152     ResourceMark rm;
   153     ResourceMark rm;
   153     log_error(class)("Name %s should be in the SymbolTable since its class is loaded", name_string);
   154     log_error(class)("Name %s should be in the SymbolTable since its class is loaded", name_string);
   154     vm_exit_during_initialization("Invalid layout of preloaded class", ik->external_name());
   155     vm_exit_during_initialization("Invalid layout of well-known class", ik->external_name());
   155   }
   156   }
   156   compute_offset(dest_offset, ik, name, signature_symbol, is_static);
   157   compute_offset(dest_offset, ik, name, signature_symbol, is_static);
   157 }
   158 }
   158 
   159 
   159 int java_lang_String::value_offset  = 0;
   160 int java_lang_String::value_offset  = 0;
  1194 // shared klass' _has_raw_archived_mirror flag is cleared.
  1195 // shared klass' _has_raw_archived_mirror flag is cleared.
  1195 bool java_lang_Class::restore_archived_mirror(Klass *k,
  1196 bool java_lang_Class::restore_archived_mirror(Klass *k,
  1196                                               Handle class_loader, Handle module,
  1197                                               Handle class_loader, Handle module,
  1197                                               Handle protection_domain, TRAPS) {
  1198                                               Handle protection_domain, TRAPS) {
  1198   // Postpone restoring archived mirror until java.lang.Class is loaded. Please
  1199   // Postpone restoring archived mirror until java.lang.Class is loaded. Please
  1199   // see more details in SystemDictionary::resolve_preloaded_classes().
  1200   // see more details in SystemDictionary::resolve_well_known_classes().
  1200   if (!SystemDictionary::Class_klass_loaded()) {
  1201   if (!SystemDictionary::Class_klass_loaded()) {
  1201     assert(fixup_mirror_list() != NULL, "fixup_mirror_list not initialized");
  1202     assert(fixup_mirror_list() != NULL, "fixup_mirror_list not initialized");
  1202     fixup_mirror_list()->push(k);
  1203     fixup_mirror_list()->push(k);
  1203     return true;
  1204     return true;
  1204   }
  1205   }
  4248 #define DO_COMPUTE_OFFSETS(k) k::compute_offsets();
  4249 #define DO_COMPUTE_OFFSETS(k) k::compute_offsets();
  4249 
  4250 
  4250 // Compute non-hard-coded field offsets of all the classes in this file
  4251 // Compute non-hard-coded field offsets of all the classes in this file
  4251 void JavaClasses::compute_offsets() {
  4252 void JavaClasses::compute_offsets() {
  4252   if (UseSharedSpaces) {
  4253   if (UseSharedSpaces) {
  4253     return; // field offsets are loaded from archive
  4254     assert(JvmtiExport::is_early_phase() && !(JvmtiExport::should_post_class_file_load_hook() &&
       
  4255                                               JvmtiExport::has_early_class_hook_env()),
       
  4256            "JavaClasses::compute_offsets() must be called in early JVMTI phase.");
       
  4257     // None of the classes used by the rest of this function can be replaced by
       
  4258     // JMVTI ClassFileLoadHook.
       
  4259     // We are safe to use the archived offsets, which have already been restored
       
  4260     // by JavaClasses::serialize_offsets, without computing the offsets again.
       
  4261     return;
  4254   }
  4262   }
  4255 
  4263 
  4256   // We have already called the compute_offsets() of the
  4264   // We have already called the compute_offsets() of the
  4257   // BASIC_JAVA_CLASSES_DO_PART1 classes (java_lang_String and java_lang_Class)
  4265   // BASIC_JAVA_CLASSES_DO_PART1 classes (java_lang_String and java_lang_Class)
  4258   // earlier inside SystemDictionary::resolve_preloaded_classes()
  4266   // earlier inside SystemDictionary::resolve_well_known_classes()
  4259   BASIC_JAVA_CLASSES_DO_PART2(DO_COMPUTE_OFFSETS);
  4267   BASIC_JAVA_CLASSES_DO_PART2(DO_COMPUTE_OFFSETS);
  4260 
  4268 
  4261   // generated interpreter code wants to know about the offsets we just computed:
  4269   // generated interpreter code wants to know about the offsets we just computed:
  4262   AbstractAssembler::update_delayed_values();
  4270   AbstractAssembler::update_delayed_values();
  4263 }
  4271 }
  4354   tty->print_cr("all fields:");
  4362   tty->print_cr("all fields:");
  4355   for (AllFieldStream fs(ik); !fs.done(); fs.next()) {
  4363   for (AllFieldStream fs(ik); !fs.done(); fs.next()) {
  4356     tty->print_cr("  name: %s, sig: %s, flags: %08x", fs.name()->as_C_string(), fs.signature()->as_C_string(), fs.access_flags().as_int());
  4364     tty->print_cr("  name: %s, sig: %s, flags: %08x", fs.name()->as_C_string(), fs.signature()->as_C_string(), fs.access_flags().as_int());
  4357   }
  4365   }
  4358 #endif //PRODUCT
  4366 #endif //PRODUCT
  4359   vm_exit_during_initialization("Invalid layout of preloaded class: use -Xlog:class+load=info to see the origin of the problem class");
  4367   vm_exit_during_initialization("Invalid layout of well-known class: use -Xlog:class+load=info to see the origin of the problem class");
  4360   return -1;
  4368   return -1;
  4361 }
  4369 }
  4362 
  4370 
  4363 void javaClasses_init() {
  4371 void javaClasses_init() {
  4364   JavaClasses::compute_offsets();
  4372   JavaClasses::compute_offsets();