2975 int java_lang_reflect_Field::modifiers(oop field) {
2976 assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
2977 return field->int_field(modifiers_offset);
2978 }
2979
2980 void java_lang_reflect_Field::set_modifiers(oop field, int value) {
2981 assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
2982 field->int_field_put(modifiers_offset, value);
2983 }
2984
2985 void java_lang_reflect_Field::set_signature(oop field, oop value) {
2986 assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
2987 field->obj_field_put(signature_offset, value);
2988 }
2989
2990 void java_lang_reflect_Field::set_annotations(oop field, oop value) {
2991 assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
2992 field->obj_field_put(annotations_offset, value);
2993 }
2994
2995 #define CONSTANTPOOL_FIELDS_DO(macro) \
2996 macro(_oop_offset, k, "constantPoolOop", object_signature, false)
2997
2998 void reflect_ConstantPool::compute_offsets() {
2999 InstanceKlass* k = SystemDictionary::reflect_ConstantPool_klass();
3000 // The field is called ConstantPool* in the sun.reflect.ConstantPool class.
3001 CONSTANTPOOL_FIELDS_DO(FIELD_COMPUTE_OFFSET);
3002 }
3003
3004 #if INCLUDE_CDS
3005 void reflect_ConstantPool::serialize_offsets(SerializeClosure* f) {
3006 CONSTANTPOOL_FIELDS_DO(FIELD_SERIALIZE_OFFSET);
3007 }
3008 #endif
3009
3010 #define PARAMETER_FIELDS_DO(macro) \
3011 macro(name_offset, k, vmSymbols::name_name(), string_signature, false); \
3012 macro(modifiers_offset, k, vmSymbols::modifiers_name(), int_signature, false); \
3013 macro(index_offset, k, vmSymbols::index_name(), int_signature, false); \
3014 macro(executable_offset, k, vmSymbols::executable_name(), executable_signature, false)
3015
3016 void java_lang_reflect_Parameter::compute_offsets() {
3017 InstanceKlass* k = SystemDictionary::reflect_Parameter_klass();
3018 PARAMETER_FIELDS_DO(FIELD_COMPUTE_OFFSET);
3019 }
3020
3021 #if INCLUDE_CDS
3022 void java_lang_reflect_Parameter::serialize_offsets(SerializeClosure* f) {
3023 PARAMETER_FIELDS_DO(FIELD_SERIALIZE_OFFSET);
3024 }
3025 #endif
3026
3130
3131 ModuleEntry* module_entry = (ModuleEntry*)module->address_field(_module_entry_offset);
3132 if (module_entry == NULL) {
3133 // If the inject field containing the ModuleEntry* is null then return the
3134 // class loader's unnamed module.
3135 oop loader = java_lang_Module::loader(module);
3136 Handle h_loader = Handle(Thread::current(), loader);
3137 ClassLoaderData* loader_cld = SystemDictionary::register_loader(h_loader);
3138 return loader_cld->unnamed_module();
3139 }
3140 return module_entry;
3141 }
3142
3143 void java_lang_Module::set_module_entry(oop module, ModuleEntry* module_entry) {
3144 assert(_module_entry_offset != -1, "Uninitialized module_entry_offset");
3145 assert(module != NULL, "module can't be null");
3146 assert(oopDesc::is_oop(module), "module must be oop");
3147 module->address_field_put(_module_entry_offset, (address)module_entry);
3148 }
3149
3150 Handle reflect_ConstantPool::create(TRAPS) {
3151 assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
3152 InstanceKlass* k = SystemDictionary::reflect_ConstantPool_klass();
3153 // Ensure it is initialized
3154 k->initialize(CHECK_NH);
3155 return k->allocate_instance_handle(THREAD);
3156 }
3157
3158
3159 void reflect_ConstantPool::set_cp(oop reflect, ConstantPool* value) {
3160 assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
3161 oop mirror = value->pool_holder()->java_mirror();
3162 // Save the mirror to get back the constant pool.
3163 reflect->obj_field_put(_oop_offset, mirror);
3164 }
3165
3166 ConstantPool* reflect_ConstantPool::get_cp(oop reflect) {
3167 assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
3168
3169 oop mirror = reflect->obj_field(_oop_offset);
3170 Klass* k = java_lang_Class::as_Klass(mirror);
3171 assert(k->is_instance_klass(), "Must be");
3172
3173 // Get the constant pool back from the klass. Since class redefinition
3174 // merges the new constant pool into the old, this is essentially the
3175 // same constant pool as the original. If constant pool merging is
3176 // no longer done in the future, this will have to change to save
3177 // the original.
3178 return InstanceKlass::cast(k)->constants();
3179 }
3180
3181 #define UNSAFESTATICFIELDACCESSORIMPL_FIELDS_DO(macro) \
3182 macro(_base_offset, k, "base", object_signature, false)
3183
3184 void reflect_UnsafeStaticFieldAccessorImpl::compute_offsets() {
3185 InstanceKlass* k = SystemDictionary::reflect_UnsafeStaticFieldAccessorImpl_klass();
3186 UNSAFESTATICFIELDACCESSORIMPL_FIELDS_DO(FIELD_COMPUTE_OFFSET);
3187 }
3188
3189 #if INCLUDE_CDS
4046 int java_lang_StackTraceElement::lineNumber_offset;
4047 int java_lang_StackTraceElement::moduleName_offset;
4048 int java_lang_StackTraceElement::moduleVersion_offset;
4049 int java_lang_StackTraceElement::classLoaderName_offset;
4050 int java_lang_StackTraceElement::declaringClass_offset;
4051 int java_lang_StackTraceElement::declaringClassObject_offset;
4052 int java_lang_StackFrameInfo::_memberName_offset;
4053 int java_lang_StackFrameInfo::_bci_offset;
4054 int java_lang_StackFrameInfo::_version_offset;
4055 int java_lang_LiveStackFrameInfo::_monitors_offset;
4056 int java_lang_LiveStackFrameInfo::_locals_offset;
4057 int java_lang_LiveStackFrameInfo::_operands_offset;
4058 int java_lang_LiveStackFrameInfo::_mode_offset;
4059 int java_lang_AssertionStatusDirectives::classes_offset;
4060 int java_lang_AssertionStatusDirectives::classEnabled_offset;
4061 int java_lang_AssertionStatusDirectives::packages_offset;
4062 int java_lang_AssertionStatusDirectives::packageEnabled_offset;
4063 int java_lang_AssertionStatusDirectives::deflt_offset;
4064 int java_nio_Buffer::_limit_offset;
4065 int java_util_concurrent_locks_AbstractOwnableSynchronizer::_owner_offset;
4066 int reflect_ConstantPool::_oop_offset;
4067 int reflect_UnsafeStaticFieldAccessorImpl::_base_offset;
4068
4069
4070 #define STACKTRACEELEMENT_FIELDS_DO(macro) \
4071 macro(declaringClassObject_offset, k, "declaringClassObject", class_signature, false); \
4072 macro(classLoaderName_offset, k, "classLoaderName", string_signature, false); \
4073 macro(moduleName_offset, k, "moduleName", string_signature, false); \
4074 macro(moduleVersion_offset, k, "moduleVersion", string_signature, false); \
4075 macro(declaringClass_offset, k, "declaringClass", string_signature, false); \
4076 macro(methodName_offset, k, "methodName", string_signature, false); \
4077 macro(fileName_offset, k, "fileName", string_signature, false); \
4078 macro(lineNumber_offset, k, "lineNumber", int_signature, false)
4079
4080 // Support for java_lang_StackTraceElement
4081 void java_lang_StackTraceElement::compute_offsets() {
4082 InstanceKlass* k = SystemDictionary::StackTraceElement_klass();
4083 STACKTRACEELEMENT_FIELDS_DO(FIELD_COMPUTE_OFFSET);
4084 }
4085
4086 #if INCLUDE_CDS
|
2975 int java_lang_reflect_Field::modifiers(oop field) {
2976 assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
2977 return field->int_field(modifiers_offset);
2978 }
2979
2980 void java_lang_reflect_Field::set_modifiers(oop field, int value) {
2981 assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
2982 field->int_field_put(modifiers_offset, value);
2983 }
2984
2985 void java_lang_reflect_Field::set_signature(oop field, oop value) {
2986 assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
2987 field->obj_field_put(signature_offset, value);
2988 }
2989
2990 void java_lang_reflect_Field::set_annotations(oop field, oop value) {
2991 assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
2992 field->obj_field_put(annotations_offset, value);
2993 }
2994
2995
2996 void reflect_ConstantPool::compute_offsets() {
2997 InstanceKlass* k = SystemDictionary::reflect_ConstantPool_klass();
2998 CONSTANTPOOL_INJECTED_FIELDS(INJECTED_FIELD_COMPUTE_OFFSET);
2999 }
3000
3001 #if INCLUDE_CDS
3002 void reflect_ConstantPool::serialize_offsets(SerializeClosure* f) {
3003 CONSTANTPOOL_INJECTED_FIELDS(INJECTED_FIELD_SERIALIZE_OFFSET);
3004 }
3005 #endif
3006
3007 #define PARAMETER_FIELDS_DO(macro) \
3008 macro(name_offset, k, vmSymbols::name_name(), string_signature, false); \
3009 macro(modifiers_offset, k, vmSymbols::modifiers_name(), int_signature, false); \
3010 macro(index_offset, k, vmSymbols::index_name(), int_signature, false); \
3011 macro(executable_offset, k, vmSymbols::executable_name(), executable_signature, false)
3012
3013 void java_lang_reflect_Parameter::compute_offsets() {
3014 InstanceKlass* k = SystemDictionary::reflect_Parameter_klass();
3015 PARAMETER_FIELDS_DO(FIELD_COMPUTE_OFFSET);
3016 }
3017
3018 #if INCLUDE_CDS
3019 void java_lang_reflect_Parameter::serialize_offsets(SerializeClosure* f) {
3020 PARAMETER_FIELDS_DO(FIELD_SERIALIZE_OFFSET);
3021 }
3022 #endif
3023
3127
3128 ModuleEntry* module_entry = (ModuleEntry*)module->address_field(_module_entry_offset);
3129 if (module_entry == NULL) {
3130 // If the inject field containing the ModuleEntry* is null then return the
3131 // class loader's unnamed module.
3132 oop loader = java_lang_Module::loader(module);
3133 Handle h_loader = Handle(Thread::current(), loader);
3134 ClassLoaderData* loader_cld = SystemDictionary::register_loader(h_loader);
3135 return loader_cld->unnamed_module();
3136 }
3137 return module_entry;
3138 }
3139
3140 void java_lang_Module::set_module_entry(oop module, ModuleEntry* module_entry) {
3141 assert(_module_entry_offset != -1, "Uninitialized module_entry_offset");
3142 assert(module != NULL, "module can't be null");
3143 assert(oopDesc::is_oop(module), "module must be oop");
3144 module->address_field_put(_module_entry_offset, (address)module_entry);
3145 }
3146
3147 Handle reflect_ConstantPool::create_from_pool(ConstantPool* value, TRAPS) {
3148 assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
3149 InstanceKlass* k = SystemDictionary::reflect_ConstantPool_klass();
3150 // Ensure it is initialized
3151 k->initialize(CHECK_NH);
3152 Handle reflect = k->allocate_instance_handle(THREAD);
3153 oop mirror = value->pool_holder()->java_mirror();
3154 // Save the mirror to get back the constant pool.
3155 reflect->obj_field_put(_constantPoolOop_offset, mirror);
3156 return reflect;
3157 }
3158
3159 ConstantPool* reflect_ConstantPool::get_cp(oop reflect) {
3160 assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
3161
3162 oop mirror = reflect->obj_field(_constantPoolOop_offset);
3163 Klass* k = java_lang_Class::as_Klass(mirror);
3164 assert(k->is_instance_klass(), "Must be");
3165
3166 // Get the constant pool back from the klass. Since class redefinition
3167 // merges the new constant pool into the old, this is essentially the
3168 // same constant pool as the original. If constant pool merging is
3169 // no longer done in the future, this will have to change to save
3170 // the original.
3171 return InstanceKlass::cast(k)->constants();
3172 }
3173
3174 #define UNSAFESTATICFIELDACCESSORIMPL_FIELDS_DO(macro) \
3175 macro(_base_offset, k, "base", object_signature, false)
3176
3177 void reflect_UnsafeStaticFieldAccessorImpl::compute_offsets() {
3178 InstanceKlass* k = SystemDictionary::reflect_UnsafeStaticFieldAccessorImpl_klass();
3179 UNSAFESTATICFIELDACCESSORIMPL_FIELDS_DO(FIELD_COMPUTE_OFFSET);
3180 }
3181
3182 #if INCLUDE_CDS
4039 int java_lang_StackTraceElement::lineNumber_offset;
4040 int java_lang_StackTraceElement::moduleName_offset;
4041 int java_lang_StackTraceElement::moduleVersion_offset;
4042 int java_lang_StackTraceElement::classLoaderName_offset;
4043 int java_lang_StackTraceElement::declaringClass_offset;
4044 int java_lang_StackTraceElement::declaringClassObject_offset;
4045 int java_lang_StackFrameInfo::_memberName_offset;
4046 int java_lang_StackFrameInfo::_bci_offset;
4047 int java_lang_StackFrameInfo::_version_offset;
4048 int java_lang_LiveStackFrameInfo::_monitors_offset;
4049 int java_lang_LiveStackFrameInfo::_locals_offset;
4050 int java_lang_LiveStackFrameInfo::_operands_offset;
4051 int java_lang_LiveStackFrameInfo::_mode_offset;
4052 int java_lang_AssertionStatusDirectives::classes_offset;
4053 int java_lang_AssertionStatusDirectives::classEnabled_offset;
4054 int java_lang_AssertionStatusDirectives::packages_offset;
4055 int java_lang_AssertionStatusDirectives::packageEnabled_offset;
4056 int java_lang_AssertionStatusDirectives::deflt_offset;
4057 int java_nio_Buffer::_limit_offset;
4058 int java_util_concurrent_locks_AbstractOwnableSynchronizer::_owner_offset;
4059 int reflect_ConstantPool::_constantPoolOop_offset;
4060 int reflect_UnsafeStaticFieldAccessorImpl::_base_offset;
4061
4062
4063 #define STACKTRACEELEMENT_FIELDS_DO(macro) \
4064 macro(declaringClassObject_offset, k, "declaringClassObject", class_signature, false); \
4065 macro(classLoaderName_offset, k, "classLoaderName", string_signature, false); \
4066 macro(moduleName_offset, k, "moduleName", string_signature, false); \
4067 macro(moduleVersion_offset, k, "moduleVersion", string_signature, false); \
4068 macro(declaringClass_offset, k, "declaringClass", string_signature, false); \
4069 macro(methodName_offset, k, "methodName", string_signature, false); \
4070 macro(fileName_offset, k, "fileName", string_signature, false); \
4071 macro(lineNumber_offset, k, "lineNumber", int_signature, false)
4072
4073 // Support for java_lang_StackTraceElement
4074 void java_lang_StackTraceElement::compute_offsets() {
4075 InstanceKlass* k = SystemDictionary::StackTraceElement_klass();
4076 STACKTRACEELEMENT_FIELDS_DO(FIELD_COMPUTE_OFFSET);
4077 }
4078
4079 #if INCLUDE_CDS
|