src/share/vm/classfile/classFileParser.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File
*** old/src/share/vm/classfile/classFileParser.cpp	Fri Mar 18 14:58:42 2011
--- new/src/share/vm/classfile/classFileParser.cpp	Fri Mar 18 14:58:42 2011

*** 35,44 **** --- 35,45 ---- #include "memory/gcLocker.hpp" #include "memory/oopFactory.hpp" #include "memory/universe.inline.hpp" #include "oops/constantPoolOop.hpp" #include "oops/instanceKlass.hpp" + #include "oops/instanceMirrorKlass.hpp" #include "oops/klass.inline.hpp" #include "oops/klassOop.hpp" #include "oops/klassVtable.hpp" #include "oops/methodOop.hpp" #include "oops/symbol.hpp"
*** 2604,2661 **** --- 2605,2614 ---- } return annotations; } static void initialize_static_field(fieldDescriptor* fd, TRAPS) { KlassHandle h_k (THREAD, fd->field_holder()); assert(h_k.not_null() && fd->is_static(), "just checking"); if (fd->has_initial_value()) { BasicType t = fd->field_type(); switch (t) { case T_BYTE: h_k()->byte_field_put(fd->offset(), fd->int_initial_value()); break; case T_BOOLEAN: h_k()->bool_field_put(fd->offset(), fd->int_initial_value()); break; case T_CHAR: h_k()->char_field_put(fd->offset(), fd->int_initial_value()); break; case T_SHORT: h_k()->short_field_put(fd->offset(), fd->int_initial_value()); break; case T_INT: h_k()->int_field_put(fd->offset(), fd->int_initial_value()); break; case T_FLOAT: h_k()->float_field_put(fd->offset(), fd->float_initial_value()); break; case T_DOUBLE: h_k()->double_field_put(fd->offset(), fd->double_initial_value()); break; case T_LONG: h_k()->long_field_put(fd->offset(), fd->long_initial_value()); break; case T_OBJECT: { #ifdef ASSERT TempNewSymbol sym = SymbolTable::new_symbol("Ljava/lang/String;", CHECK); assert(fd->signature() == sym, "just checking"); #endif oop string = fd->string_initial_value(CHECK); h_k()->obj_field_put(fd->offset(), string); } break; default: THROW_MSG(vmSymbols::java_lang_ClassFormatError(), "Illegal ConstantValue attribute in class file"); } } } void ClassFileParser::java_lang_ref_Reference_fix_pre(typeArrayHandle* fields_ptr, constantPoolHandle cp, FieldAllocationCount *fac_ptr, TRAPS) { // This code is for compatibility with earlier jdk's that do not // have the "discovered" field in java.lang.ref.Reference. For 1.5 // the check for the "discovered" field should issue a warning if
*** 2767,2778 **** --- 2720,2731 ---- } return; } ! void ClassFileParser::java_lang_Class_fix_pre(objArrayHandle* methods_ptr, ! FieldAllocationCount *fac_ptr, TRAPS) { ! void ClassFileParser::java_lang_Class_fix_pre(int* nonstatic_field_size, ! FieldAllocationCount *fac_ptr) { // Add fake fields for java.lang.Class instances // // This is not particularly nice. We should consider adding a // private transient object field at the Java level to // java.lang.Class. Alternatively we could add a subclass of
*** 2785,2798 **** --- 2738,2754 ---- // nonstatic oop fields were added at the Java level. The offsets // of these fake fields can't change between these two JDK // versions because when the offsets are computed at bootstrap // time we don't know yet which version of the JDK we're running in. ! // The values below are fake but will force two non-static oop fields and ! // The values below are fake but will force three non-static oop fields and // a corresponding non-static oop map block to be allocated. const int extra = java_lang_Class::number_of_fake_oop_fields; fac_ptr->nonstatic_oop_count += extra; + + // Reserve some leading space for fake ints + *nonstatic_field_size += align_size_up(java_lang_Class::hc_number_of_fake_int_fields * BytesPerInt, heapOopSize) / heapOopSize; } void ClassFileParser::java_lang_Class_fix_post(int* next_nonstatic_oop_offset_ptr) { // Cause the extra fake fields in java.lang.Class to show up before
*** 3203,3215 **** --- 3159,3169 ---- int first_nonstatic_oop_offset; int first_nonstatic_field_offset; int next_nonstatic_field_offset; // Calculate the starting byte offsets ! next_static_oop_offset = (instanceKlass::header_size() + align_object_offset(vtable_size) + align_object_offset(itable_size)) * wordSize; ! next_static_oop_offset = instanceMirrorKlass::offset_of_static_fields(); next_static_double_offset = next_static_oop_offset + (fac.static_oop_count * heapOopSize); if ( fac.static_double_count && (Universe::field_type_should_be_aligned(T_DOUBLE) || Universe::field_type_should_be_aligned(T_LONG)) ) {
*** 3224,3242 **** --- 3178,3197 ---- (fac.static_short_count * BytesPerShort); next_static_type_offset = align_size_up((next_static_byte_offset + fac.static_byte_count ), wordSize ); static_field_size = (next_static_type_offset - next_static_oop_offset) / wordSize; first_nonstatic_field_offset = instanceOopDesc::base_offset_in_bytes() + nonstatic_field_size * heapOopSize; next_nonstatic_field_offset = first_nonstatic_field_offset; // Add fake fields for java.lang.Class instances (also see below) if (class_name == vmSymbols::java_lang_Class() && class_loader.is_null()) { ! java_lang_Class_fix_pre(&methods, &fac, CHECK_(nullHandle)); ! java_lang_Class_fix_pre(&nonstatic_field_size, &fac); } + first_nonstatic_field_offset = instanceOopDesc::base_offset_in_bytes() + + nonstatic_field_size * heapOopSize; + next_nonstatic_field_offset = first_nonstatic_field_offset; + // adjust the vmentry field declaration in java.lang.invoke.MethodHandle if (EnableMethodHandles && class_name == vmSymbols::java_lang_invoke_MethodHandle() && class_loader.is_null()) { java_lang_invoke_MethodHandle_fix_pre(cp, fields, &fac, CHECK_(nullHandle)); } if (AllowTransitionalJSR292 &&
*** 3564,3574 **** --- 3519,3529 ---- } else { rt = super_klass->reference_type(); } // We can now create the basic klassOop for this klass ! klassOop ik = oopFactory::new_instanceKlass(name, vtable_size, itable_size, static_field_size, total_oop_map_count, rt, CHECK_(nullHandle)); instanceKlassHandle this_klass (THREAD, ik);
*** 3586,3596 **** --- 3541,3551 ---- // Not yet: supers are done below to support the new subtype-checking fields //this_klass->set_super(super_klass()); this_klass->set_class_loader(class_loader()); this_klass->set_nonstatic_field_size(nonstatic_field_size); this_klass->set_has_nonstatic_fields(has_nonstatic_fields); ! this_klass->set_static_oop_field_size(fac.static_oop_count); ! this_klass->set_static_oop_field_count(fac.static_oop_count); cp->set_pool_holder(this_klass()); error_handler.set_in_error(false); // turn off error handler for cp this_klass->set_constants(cp()); this_klass->set_local_interfaces(local_interfaces()); this_klass->set_fields(fields());
*** 3647,3659 **** --- 3602,3611 ---- parse_classfile_attributes(cp, this_klass, CHECK_(nullHandle)); // Make sure this is the end of class file stream guarantee_property(cfs->at_eos(), "Extra bytes at the end of class file %s", CHECK_(nullHandle)); // Initialize static fields this_klass->do_local_static_fields(&initialize_static_field, CHECK_(nullHandle)); // VerifyOops believes that once this has been set, the object is completely loaded. // Compute transitive closure of interfaces this class implements this_klass->set_transitive_interfaces(transitive_interfaces()); // Fill in information needed to compute superclasses.
*** 3683,3692 **** --- 3635,3647 ---- // check that if this class is an interface then it doesn't have static methods if (this_klass->is_interface()) { check_illegal_static_method(this_klass, CHECK_(nullHandle)); } + // Allocate mirror and initialize static fields + java_lang_Class::create_mirror(this_klass, CHECK_(nullHandle)); + ClassLoadingService::notify_class_loaded(instanceKlass::cast(this_klass()), false /* not shared class */); if (TraceClassLoading) { // print in a single call to reduce interleaving of output

src/share/vm/classfile/classFileParser.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File