< prev index next >

src/hotspot/share/classfile/javaClasses.cpp

Print this page




  69 
  70 #define INJECTED_FIELD_COMPUTE_OFFSET(klass, name, signature, may_be_java)    \
  71   klass::_##name##_offset = JavaClasses::compute_injected_offset(JavaClasses::klass##_##name##_enum);
  72 
  73 #if INCLUDE_CDS
  74 #define INJECTED_FIELD_SERIALIZE_OFFSET(klass, name, signature, may_be_java) \
  75   f->do_u4((u4*)&_##name##_offset);
  76 #endif
  77 
  78 #define DECLARE_INJECTED_FIELD(klass, name, signature, may_be_java)           \
  79   { SystemDictionary::WK_KLASS_ENUM_NAME(klass), vmSymbols::VM_SYMBOL_ENUM_NAME(name##_name), vmSymbols::VM_SYMBOL_ENUM_NAME(signature), may_be_java },
  80 
  81 InjectedField JavaClasses::_injected_fields[] = {
  82   ALL_INJECTED_FIELDS(DECLARE_INJECTED_FIELD)
  83 };
  84 
  85 int JavaClasses::compute_injected_offset(InjectedFieldID id) {
  86   return _injected_fields[id].compute_offset();
  87 }
  88 
  89 
  90 InjectedField* JavaClasses::get_injected(Symbol* class_name, int* field_count) {
  91   *field_count = 0;
  92 
  93   vmSymbols::SID sid = vmSymbols::find_sid(class_name);
  94   if (sid == vmSymbols::NO_SID) {
  95     // Only well known classes can inject fields
  96     return NULL;
  97   }
  98 
  99   int count = 0;
 100   int start = -1;
 101 
 102 #define LOOKUP_INJECTED_FIELD(klass, name, signature, may_be_java) \
 103   if (sid == vmSymbols::VM_SYMBOL_ENUM_NAME(klass)) {              \
 104     count++;                                                       \
 105     if (start == -1) start = klass##_##name##_enum;                \
 106   }
 107   ALL_INJECTED_FIELDS(LOOKUP_INJECTED_FIELD);
 108 #undef LOOKUP_INJECTED_FIELD
 109 


 139     ik->print_on(&ls);
 140 #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   }
 143   dest_offset = fd.offset();
 144 }
 145 
 146 // Overloading to pass name as a string.
 147 static void compute_offset(int& dest_offset, InstanceKlass* ik,
 148                            const char* name_string, Symbol* signature_symbol,
 149                            bool is_static = false) {
 150   TempNewSymbol name = SymbolTable::probe(name_string, (int)strlen(name_string));
 151   if (name == NULL) {
 152     ResourceMark rm;
 153     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   }
 156   compute_offset(dest_offset, ik, name, signature_symbol, is_static);
 157 }
 158 
 159 // Same as above but for "optional" offsets that might not be present in certain JDK versions
 160 // Old versions should be cleaned out since Hotspot only supports the current JDK, and this
 161 // function should be removed.
 162 static void
 163 compute_optional_offset(int& dest_offset,
 164                         InstanceKlass* ik, Symbol* name_symbol, Symbol* signature_symbol) {
 165   fieldDescriptor fd;
 166   if (ik->find_local_field(name_symbol, signature_symbol, &fd)) {
 167     dest_offset = fd.offset();
 168   }
 169 }
 170 
 171 int java_lang_String::value_offset  = 0;
 172 int java_lang_String::hash_offset   = 0;
 173 int java_lang_String::coder_offset  = 0;
 174 
 175 bool java_lang_String::initialized  = false;
 176 
 177 bool java_lang_String::is_instance(oop obj) {
 178   return is_instance_inlined(obj);
 179 }
 180 
 181 #if INCLUDE_CDS
 182 #define FIELD_SERIALIZE_OFFSET(offset, klass, name, signature, is_static) \
 183   f->do_u4((u4*)&offset)
 184 
 185 #define FIELD_SERIALIZE_OFFSET_OPTIONAL(offset, klass, name, signature) \
 186   f->do_u4((u4*)&offset)
 187 #endif
 188 
 189 #define FIELD_COMPUTE_OFFSET(offset, klass, name, signature, is_static) \
 190   compute_offset(offset, klass, name, vmSymbols::signature(), is_static)
 191 
 192 #define FIELD_COMPUTE_OFFSET_OPTIONAL(offset, klass, name, signature) \
 193   compute_optional_offset(offset, klass, name, vmSymbols::signature())
 194 
 195 #define STRING_FIELDS_DO(macro) \
 196   macro(value_offset, k, vmSymbols::value_name(), byte_array_signature, false); \
 197   macro(hash_offset,  k, "hash",                  int_signature,        false); \
 198   macro(coder_offset, k, "coder",                 byte_signature,       false)
 199 
 200 void java_lang_String::compute_offsets() {
 201   if (initialized) {
 202     return;
 203   }
 204 
 205   InstanceKlass* k = SystemDictionary::String_klass();
 206   STRING_FIELDS_DO(FIELD_COMPUTE_OFFSET);
 207 
 208   initialized = true;
 209 }
 210 
 211 #if INCLUDE_CDS
 212 void java_lang_String::serialize_offsets(SerializeClosure* f) {
 213   STRING_FIELDS_DO(FIELD_SERIALIZE_OFFSET);
 214   f->do_u4((u4*)&initialized);


2718 #endif
2719 
2720 jboolean java_lang_reflect_AccessibleObject::override(oop reflect) {
2721   assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
2722   return (jboolean) reflect->bool_field(override_offset);
2723 }
2724 
2725 void java_lang_reflect_AccessibleObject::set_override(oop reflect, jboolean value) {
2726   assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
2727   reflect->bool_field_put(override_offset, (int) value);
2728 }
2729 
2730 #define METHOD_FIELDS_DO(macro) \
2731   macro(clazz_offset,          k, vmSymbols::clazz_name(),          class_signature,       false); \
2732   macro(name_offset,           k, vmSymbols::name_name(),           string_signature,      false); \
2733   macro(returnType_offset,     k, vmSymbols::returnType_name(),     class_signature,       false); \
2734   macro(parameterTypes_offset, k, vmSymbols::parameterTypes_name(), class_array_signature, false); \
2735   macro(exceptionTypes_offset, k, vmSymbols::exceptionTypes_name(), class_array_signature, false); \
2736   macro(slot_offset,           k, vmSymbols::slot_name(),           int_signature,         false); \
2737   macro(modifiers_offset,      k, vmSymbols::modifiers_name(),      int_signature,         false); \
2738   macro##_OPTIONAL(signature_offset,             k, vmSymbols::signature_name(),             string_signature); \
2739   macro##_OPTIONAL(annotations_offset,           k, vmSymbols::annotations_name(),           byte_array_signature); \
2740   macro##_OPTIONAL(parameter_annotations_offset, k, vmSymbols::parameter_annotations_name(), byte_array_signature); \
2741   macro##_OPTIONAL(annotation_default_offset,    k, vmSymbols::annotation_default_name(),    byte_array_signature); \
2742   macro##_OPTIONAL(type_annotations_offset,      k, vmSymbols::type_annotations_name(),      byte_array_signature)
2743 
2744 void java_lang_reflect_Method::compute_offsets() {
2745   InstanceKlass* k = SystemDictionary::reflect_Method_klass();
2746   // The generic signature and annotations fields are only present in 1.5
2747   signature_offset = -1;
2748   annotations_offset = -1;
2749   parameter_annotations_offset = -1;
2750   annotation_default_offset = -1;
2751   type_annotations_offset = -1;
2752   METHOD_FIELDS_DO(FIELD_COMPUTE_OFFSET);
2753 }
2754 
2755 #if INCLUDE_CDS
2756 void java_lang_reflect_Method::serialize_offsets(SerializeClosure* f) {
2757   METHOD_FIELDS_DO(FIELD_SERIALIZE_OFFSET);
2758 }
2759 #endif
2760 
2761 Handle java_lang_reflect_Method::create(TRAPS) {
2762   assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
2763   Klass* klass = SystemDictionary::reflect_Method_klass();
2764   // This class is eagerly initialized during VM initialization, since we keep a refence
2765   // to one of the methods
2766   assert(InstanceKlass::cast(klass)->is_initialized(), "must be initialized");
2767   return InstanceKlass::cast(klass)->allocate_instance_handle(THREAD);
2768 }
2769 
2770 oop java_lang_reflect_Method::clazz(oop reflect) {
2771   assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
2772   return reflect->obj_field(clazz_offset);
2773 }
2774 
2775 void java_lang_reflect_Method::set_clazz(oop reflect, oop value) {
2776   assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
2777    reflect->obj_field_put(clazz_offset, value);
2778 }
2779 
2780 int java_lang_reflect_Method::slot(oop reflect) {
2781   assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
2782   return reflect->int_field(slot_offset);
2783 }
2784 
2785 void java_lang_reflect_Method::set_slot(oop reflect, int value) {
2786   assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
2787   reflect->int_field_put(slot_offset, value);
2788 }
2789 
2790 oop java_lang_reflect_Method::name(oop method) {
2791   assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
2792   return method->obj_field(name_offset);
2793 }
2794 
2795 void java_lang_reflect_Method::set_name(oop method, oop value) {
2796   assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
2797   method->obj_field_put(name_offset, value);
2798 }
2799 
2800 oop java_lang_reflect_Method::return_type(oop method) {
2801   assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
2802   return method->obj_field(returnType_offset);
2803 }
2804 
2805 void java_lang_reflect_Method::set_return_type(oop method, oop value) {
2806   assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
2807   method->obj_field_put(returnType_offset, value);
2808 }
2809 
2810 oop java_lang_reflect_Method::parameter_types(oop method) {
2811   assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
2812   return method->obj_field(parameterTypes_offset);
2813 }
2814 
2815 void java_lang_reflect_Method::set_parameter_types(oop method, oop value) {
2816   assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
2817   method->obj_field_put(parameterTypes_offset, value);
2818 }
2819 
2820 oop java_lang_reflect_Method::exception_types(oop method) {
2821   assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
2822   return method->obj_field(exceptionTypes_offset);
2823 }
2824 
2825 void java_lang_reflect_Method::set_exception_types(oop method, oop value) {
2826   assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
2827   method->obj_field_put(exceptionTypes_offset, value);
2828 }
2829 
2830 int java_lang_reflect_Method::modifiers(oop method) {
2831   assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
2832   return method->int_field(modifiers_offset);
2833 }
2834 
2835 void java_lang_reflect_Method::set_modifiers(oop method, int value) {
2836   assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
2837   method->int_field_put(modifiers_offset, value);
2838 }
2839 
2840 bool java_lang_reflect_Method::has_signature_field() {
2841   return (signature_offset >= 0);
2842 }
2843 
2844 oop java_lang_reflect_Method::signature(oop method) {
2845   assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
2846   assert(has_signature_field(), "signature field must be present");
2847   return method->obj_field(signature_offset);
2848 }
2849 
2850 void java_lang_reflect_Method::set_signature(oop method, oop value) {
2851   assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
2852   assert(has_signature_field(), "signature field must be present");
2853   method->obj_field_put(signature_offset, value);
2854 }
2855 
2856 bool java_lang_reflect_Method::has_annotations_field() {
2857   return (annotations_offset >= 0);
2858 }
2859 
2860 oop java_lang_reflect_Method::annotations(oop method) {
2861   assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
2862   assert(has_annotations_field(), "annotations field must be present");
2863   return method->obj_field(annotations_offset);
2864 }
2865 
2866 void java_lang_reflect_Method::set_annotations(oop method, oop value) {
2867   assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
2868   assert(has_annotations_field(), "annotations field must be present");
2869   method->obj_field_put(annotations_offset, value);
2870 }
2871 
2872 bool java_lang_reflect_Method::has_parameter_annotations_field() {
2873   return (parameter_annotations_offset >= 0);
2874 }
2875 
2876 oop java_lang_reflect_Method::parameter_annotations(oop method) {
2877   assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
2878   assert(has_parameter_annotations_field(), "parameter annotations field must be present");
2879   return method->obj_field(parameter_annotations_offset);
2880 }
2881 
2882 void java_lang_reflect_Method::set_parameter_annotations(oop method, oop value) {
2883   assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
2884   assert(has_parameter_annotations_field(), "parameter annotations field must be present");
2885   method->obj_field_put(parameter_annotations_offset, value);
2886 }
2887 
2888 bool java_lang_reflect_Method::has_annotation_default_field() {
2889   return (annotation_default_offset >= 0);
2890 }
2891 
2892 oop java_lang_reflect_Method::annotation_default(oop method) {
2893   assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
2894   assert(has_annotation_default_field(), "annotation default field must be present");
2895   return method->obj_field(annotation_default_offset);
2896 }
2897 
2898 void java_lang_reflect_Method::set_annotation_default(oop method, oop value) {
2899   assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
2900   assert(has_annotation_default_field(), "annotation default field must be present");
2901   method->obj_field_put(annotation_default_offset, value);
2902 }
2903 
2904 bool java_lang_reflect_Method::has_type_annotations_field() {
2905   return (type_annotations_offset >= 0);
2906 }
2907 
2908 oop java_lang_reflect_Method::type_annotations(oop method) {
2909   assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
2910   assert(has_type_annotations_field(), "type_annotations field must be present");
2911   return method->obj_field(type_annotations_offset);
2912 }
2913 
2914 void java_lang_reflect_Method::set_type_annotations(oop method, oop value) {
2915   assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
2916   assert(has_type_annotations_field(), "type_annotations field must be present");
2917   method->obj_field_put(type_annotations_offset, value);
2918 }
2919 
2920 #define CONSTRUCTOR_FIELDS_DO(macro) \
2921   macro(clazz_offset,          k, vmSymbols::clazz_name(),          class_signature,       false); \
2922   macro(parameterTypes_offset, k, vmSymbols::parameterTypes_name(), class_array_signature, false); \
2923   macro(exceptionTypes_offset, k, vmSymbols::exceptionTypes_name(), class_array_signature, false); \
2924   macro(slot_offset,           k, vmSymbols::slot_name(),           int_signature,         false); \
2925   macro(modifiers_offset,      k, vmSymbols::modifiers_name(),      int_signature,         false); \
2926   macro##_OPTIONAL(signature_offset,             k, vmSymbols::signature_name(),             string_signature); \
2927   macro##_OPTIONAL(annotations_offset,           k, vmSymbols::annotations_name(),           byte_array_signature); \
2928   macro##_OPTIONAL(parameter_annotations_offset, k, vmSymbols::parameter_annotations_name(), byte_array_signature); \
2929   macro##_OPTIONAL(type_annotations_offset,      k, vmSymbols::type_annotations_name(),      byte_array_signature)
2930 
2931 
2932 void java_lang_reflect_Constructor::compute_offsets() {
2933   InstanceKlass* k = SystemDictionary::reflect_Constructor_klass();
2934   // The generic signature and annotations fields are only present in 1.5
2935   signature_offset = -1;
2936   annotations_offset = -1;
2937   parameter_annotations_offset = -1;
2938   type_annotations_offset = -1;
2939   CONSTRUCTOR_FIELDS_DO(FIELD_COMPUTE_OFFSET);
2940 }
2941 
2942 #if INCLUDE_CDS
2943 void java_lang_reflect_Constructor::serialize_offsets(SerializeClosure* f) {
2944   CONSTRUCTOR_FIELDS_DO(FIELD_SERIALIZE_OFFSET);
2945 }
2946 #endif
2947 
2948 Handle java_lang_reflect_Constructor::create(TRAPS) {
2949   assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
2950   Symbol* name = vmSymbols::java_lang_reflect_Constructor();
2951   Klass* k = SystemDictionary::resolve_or_fail(name, true, CHECK_NH);
2952   InstanceKlass* ik = InstanceKlass::cast(k);
2953   // Ensure it is initialized
2954   ik->initialize(CHECK_NH);
2955   return ik->allocate_instance_handle(THREAD);
2956 }
2957 
2958 oop java_lang_reflect_Constructor::clazz(oop reflect) {
2959   assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
2960   return reflect->obj_field(clazz_offset);
2961 }
2962 
2963 void java_lang_reflect_Constructor::set_clazz(oop reflect, oop value) {
2964   assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
2965    reflect->obj_field_put(clazz_offset, value);
2966 }
2967 
2968 oop java_lang_reflect_Constructor::parameter_types(oop constructor) {
2969   assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
2970   return constructor->obj_field(parameterTypes_offset);
2971 }
2972 
2973 void java_lang_reflect_Constructor::set_parameter_types(oop constructor, oop value) {
2974   assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
2975   constructor->obj_field_put(parameterTypes_offset, value);
2976 }
2977 
2978 oop java_lang_reflect_Constructor::exception_types(oop constructor) {
2979   assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
2980   return constructor->obj_field(exceptionTypes_offset);
2981 }
2982 
2983 void java_lang_reflect_Constructor::set_exception_types(oop constructor, oop value) {
2984   assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
2985   constructor->obj_field_put(exceptionTypes_offset, value);
2986 }
2987 
2988 int java_lang_reflect_Constructor::slot(oop reflect) {
2989   assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
2990   return reflect->int_field(slot_offset);
2991 }
2992 
2993 void java_lang_reflect_Constructor::set_slot(oop reflect, int value) {
2994   assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
2995   reflect->int_field_put(slot_offset, value);
2996 }
2997 
2998 int java_lang_reflect_Constructor::modifiers(oop constructor) {
2999   assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
3000   return constructor->int_field(modifiers_offset);
3001 }
3002 
3003 void java_lang_reflect_Constructor::set_modifiers(oop constructor, int value) {
3004   assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
3005   constructor->int_field_put(modifiers_offset, value);
3006 }
3007 
3008 bool java_lang_reflect_Constructor::has_signature_field() {
3009   return (signature_offset >= 0);
3010 }
3011 
3012 oop java_lang_reflect_Constructor::signature(oop constructor) {
3013   assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
3014   assert(has_signature_field(), "signature field must be present");
3015   return constructor->obj_field(signature_offset);
3016 }
3017 
3018 void java_lang_reflect_Constructor::set_signature(oop constructor, oop value) {
3019   assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
3020   assert(has_signature_field(), "signature field must be present");
3021   constructor->obj_field_put(signature_offset, value);
3022 }
3023 
3024 bool java_lang_reflect_Constructor::has_annotations_field() {
3025   return (annotations_offset >= 0);
3026 }
3027 
3028 oop java_lang_reflect_Constructor::annotations(oop constructor) {
3029   assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
3030   assert(has_annotations_field(), "annotations field must be present");
3031   return constructor->obj_field(annotations_offset);
3032 }
3033 
3034 void java_lang_reflect_Constructor::set_annotations(oop constructor, oop value) {
3035   assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
3036   assert(has_annotations_field(), "annotations field must be present");
3037   constructor->obj_field_put(annotations_offset, value);
3038 }
3039 
3040 bool java_lang_reflect_Constructor::has_parameter_annotations_field() {
3041   return (parameter_annotations_offset >= 0);
3042 }
3043 
3044 oop java_lang_reflect_Constructor::parameter_annotations(oop method) {
3045   assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
3046   assert(has_parameter_annotations_field(), "parameter annotations field must be present");
3047   return method->obj_field(parameter_annotations_offset);
3048 }
3049 
3050 void java_lang_reflect_Constructor::set_parameter_annotations(oop method, oop value) {
3051   assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
3052   assert(has_parameter_annotations_field(), "parameter annotations field must be present");
3053   method->obj_field_put(parameter_annotations_offset, value);
3054 }
3055 
3056 bool java_lang_reflect_Constructor::has_type_annotations_field() {
3057   return (type_annotations_offset >= 0);
3058 }
3059 
3060 oop java_lang_reflect_Constructor::type_annotations(oop constructor) {
3061   assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
3062   assert(has_type_annotations_field(), "type_annotations field must be present");
3063   return constructor->obj_field(type_annotations_offset);
3064 }
3065 
3066 void java_lang_reflect_Constructor::set_type_annotations(oop constructor, oop value) {
3067   assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
3068   assert(has_type_annotations_field(), "type_annotations field must be present");
3069   constructor->obj_field_put(type_annotations_offset, value);
3070 }
3071 
3072 #define FIELD_FIELDS_DO(macro) \
3073   macro(clazz_offset,     k, vmSymbols::clazz_name(),     class_signature,  false); \
3074   macro(name_offset,      k, vmSymbols::name_name(),      string_signature, false); \
3075   macro(type_offset,      k, vmSymbols::type_name(),      class_signature,  false); \
3076   macro(slot_offset,      k, vmSymbols::slot_name(),      int_signature,    false); \
3077   macro(modifiers_offset, k, vmSymbols::modifiers_name(), int_signature,    false); \
3078   macro##_OPTIONAL(signature_offset,        k, vmSymbols::signature_name(), string_signature); \
3079   macro##_OPTIONAL(annotations_offset,      k, vmSymbols::annotations_name(),  byte_array_signature); \
3080   macro##_OPTIONAL(type_annotations_offset, k, vmSymbols::type_annotations_name(),  byte_array_signature)
3081 
3082 void java_lang_reflect_Field::compute_offsets() {
3083   InstanceKlass* k = SystemDictionary::reflect_Field_klass();
3084   // The generic signature and annotations fields are only present in 1.5
3085   signature_offset = -1;
3086   annotations_offset = -1;
3087   type_annotations_offset = -1;
3088   FIELD_FIELDS_DO(FIELD_COMPUTE_OFFSET);
3089 }
3090 
3091 #if INCLUDE_CDS
3092 void java_lang_reflect_Field::serialize_offsets(SerializeClosure* f) {
3093   FIELD_FIELDS_DO(FIELD_SERIALIZE_OFFSET);
3094 }
3095 #endif
3096 
3097 Handle java_lang_reflect_Field::create(TRAPS) {
3098   assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
3099   Symbol* name = vmSymbols::java_lang_reflect_Field();
3100   Klass* k = SystemDictionary::resolve_or_fail(name, true, CHECK_NH);
3101   InstanceKlass* ik = InstanceKlass::cast(k);
3102   // Ensure it is initialized
3103   ik->initialize(CHECK_NH);
3104   return ik->allocate_instance_handle(THREAD);
3105 }
3106 
3107 oop java_lang_reflect_Field::clazz(oop reflect) {


3137 int java_lang_reflect_Field::slot(oop reflect) {
3138   assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
3139   return reflect->int_field(slot_offset);
3140 }
3141 
3142 void java_lang_reflect_Field::set_slot(oop reflect, int value) {
3143   assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
3144   reflect->int_field_put(slot_offset, value);
3145 }
3146 
3147 int java_lang_reflect_Field::modifiers(oop field) {
3148   assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
3149   return field->int_field(modifiers_offset);
3150 }
3151 
3152 void java_lang_reflect_Field::set_modifiers(oop field, int value) {
3153   assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
3154   field->int_field_put(modifiers_offset, value);
3155 }
3156 
3157 bool java_lang_reflect_Field::has_signature_field() {
3158   return (signature_offset >= 0);
3159 }
3160 
3161 oop java_lang_reflect_Field::signature(oop field) {
3162   assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
3163   assert(has_signature_field(), "signature field must be present");
3164   return field->obj_field(signature_offset);
3165 }
3166 
3167 void java_lang_reflect_Field::set_signature(oop field, oop value) {
3168   assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
3169   assert(has_signature_field(), "signature field must be present");
3170   field->obj_field_put(signature_offset, value);
3171 }
3172 
3173 bool java_lang_reflect_Field::has_annotations_field() {
3174   return (annotations_offset >= 0);
3175 }
3176 
3177 oop java_lang_reflect_Field::annotations(oop field) {
3178   assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
3179   assert(has_annotations_field(), "annotations field must be present");
3180   return field->obj_field(annotations_offset);
3181 }
3182 
3183 void java_lang_reflect_Field::set_annotations(oop field, oop value) {
3184   assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
3185   assert(has_annotations_field(), "annotations field must be present");
3186   field->obj_field_put(annotations_offset, value);
3187 }
3188 
3189 bool java_lang_reflect_Field::has_type_annotations_field() {
3190   return (type_annotations_offset >= 0);
3191 }
3192 
3193 oop java_lang_reflect_Field::type_annotations(oop field) {
3194   assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
3195   assert(has_type_annotations_field(), "type_annotations field must be present");
3196   return field->obj_field(type_annotations_offset);
3197 }
3198 
3199 void java_lang_reflect_Field::set_type_annotations(oop field, oop value) {
3200   assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
3201   assert(has_type_annotations_field(), "type_annotations field must be present");
3202   field->obj_field_put(type_annotations_offset, value);
3203 }
3204 
3205 #define CONSTANTPOOL_FIELDS_DO(macro) \
3206   macro(_oop_offset, k, "constantPoolOop", object_signature, false)
3207 
3208 void reflect_ConstantPool::compute_offsets() {
3209   InstanceKlass* k = SystemDictionary::reflect_ConstantPool_klass();
3210   // The field is called ConstantPool* in the sun.reflect.ConstantPool class.
3211   CONSTANTPOOL_FIELDS_DO(FIELD_COMPUTE_OFFSET);
3212 }
3213 
3214 #if INCLUDE_CDS
3215 void reflect_ConstantPool::serialize_offsets(SerializeClosure* f) {
3216   CONSTANTPOOL_FIELDS_DO(FIELD_SERIALIZE_OFFSET);
3217 }
3218 #endif
3219 
3220 #define PARAMETER_FIELDS_DO(macro) \
3221   macro(name_offset,        k, vmSymbols::name_name(),        string_signature, false); \
3222   macro(modifiers_offset,   k, vmSymbols::modifiers_name(),   int_signature,    false); \
3223   macro(index_offset,       k, vmSymbols::index_name(),       int_signature,    false); \
3224   macro(executable_offset,  k, vmSymbols::executable_name(),  executable_signature, false)


4202 int java_lang_Class::_signers_offset;
4203 GrowableArray<Klass*>* java_lang_Class::_fixup_mirror_list = NULL;
4204 GrowableArray<Klass*>* java_lang_Class::_fixup_module_field_list = NULL;
4205 int java_lang_Throwable::backtrace_offset;
4206 int java_lang_Throwable::detailMessage_offset;
4207 int java_lang_Throwable::stackTrace_offset;
4208 int java_lang_Throwable::depth_offset;
4209 int java_lang_Throwable::static_unassigned_stacktrace_offset;
4210 int java_lang_reflect_AccessibleObject::override_offset;
4211 int java_lang_reflect_Method::clazz_offset;
4212 int java_lang_reflect_Method::name_offset;
4213 int java_lang_reflect_Method::returnType_offset;
4214 int java_lang_reflect_Method::parameterTypes_offset;
4215 int java_lang_reflect_Method::exceptionTypes_offset;
4216 int java_lang_reflect_Method::slot_offset;
4217 int java_lang_reflect_Method::modifiers_offset;
4218 int java_lang_reflect_Method::signature_offset;
4219 int java_lang_reflect_Method::annotations_offset;
4220 int java_lang_reflect_Method::parameter_annotations_offset;
4221 int java_lang_reflect_Method::annotation_default_offset;
4222 int java_lang_reflect_Method::type_annotations_offset;
4223 int java_lang_reflect_Constructor::clazz_offset;
4224 int java_lang_reflect_Constructor::parameterTypes_offset;
4225 int java_lang_reflect_Constructor::exceptionTypes_offset;
4226 int java_lang_reflect_Constructor::slot_offset;
4227 int java_lang_reflect_Constructor::modifiers_offset;
4228 int java_lang_reflect_Constructor::signature_offset;
4229 int java_lang_reflect_Constructor::annotations_offset;
4230 int java_lang_reflect_Constructor::parameter_annotations_offset;
4231 int java_lang_reflect_Constructor::type_annotations_offset;
4232 int java_lang_reflect_Field::clazz_offset;
4233 int java_lang_reflect_Field::name_offset;
4234 int java_lang_reflect_Field::type_offset;
4235 int java_lang_reflect_Field::slot_offset;
4236 int java_lang_reflect_Field::modifiers_offset;
4237 int java_lang_reflect_Field::signature_offset;
4238 int java_lang_reflect_Field::annotations_offset;
4239 int java_lang_reflect_Field::type_annotations_offset;
4240 int java_lang_reflect_Parameter::name_offset;
4241 int java_lang_reflect_Parameter::modifiers_offset;
4242 int java_lang_reflect_Parameter::index_offset;
4243 int java_lang_reflect_Parameter::executable_offset;
4244 int java_lang_boxing_object::value_offset;
4245 int java_lang_boxing_object::long_value_offset;
4246 int java_lang_ref_Reference::referent_offset;
4247 int java_lang_ref_Reference::queue_offset;
4248 int java_lang_ref_Reference::next_offset;
4249 int java_lang_ref_Reference::discovered_offset;
4250 int java_lang_ref_SoftReference::timestamp_offset;
4251 int java_lang_ref_SoftReference::static_clock_offset;
4252 int java_lang_ClassLoader::parent_offset;
4253 int java_lang_System::static_in_offset;
4254 int java_lang_System::static_out_offset;
4255 int java_lang_System::static_err_offset;
4256 int java_lang_System::static_security_offset;
4257 int java_lang_StackTraceElement::methodName_offset;
4258 int java_lang_StackTraceElement::fileName_offset;
4259 int java_lang_StackTraceElement::lineNumber_offset;




  69 
  70 #define INJECTED_FIELD_COMPUTE_OFFSET(klass, name, signature, may_be_java)    \
  71   klass::_##name##_offset = JavaClasses::compute_injected_offset(JavaClasses::klass##_##name##_enum);
  72 
  73 #if INCLUDE_CDS
  74 #define INJECTED_FIELD_SERIALIZE_OFFSET(klass, name, signature, may_be_java) \
  75   f->do_u4((u4*)&_##name##_offset);
  76 #endif
  77 
  78 #define DECLARE_INJECTED_FIELD(klass, name, signature, may_be_java)           \
  79   { SystemDictionary::WK_KLASS_ENUM_NAME(klass), vmSymbols::VM_SYMBOL_ENUM_NAME(name##_name), vmSymbols::VM_SYMBOL_ENUM_NAME(signature), may_be_java },
  80 
  81 InjectedField JavaClasses::_injected_fields[] = {
  82   ALL_INJECTED_FIELDS(DECLARE_INJECTED_FIELD)
  83 };
  84 
  85 int JavaClasses::compute_injected_offset(InjectedFieldID id) {
  86   return _injected_fields[id].compute_offset();
  87 }
  88 

  89 InjectedField* JavaClasses::get_injected(Symbol* class_name, int* field_count) {
  90   *field_count = 0;
  91 
  92   vmSymbols::SID sid = vmSymbols::find_sid(class_name);
  93   if (sid == vmSymbols::NO_SID) {
  94     // Only well known classes can inject fields
  95     return NULL;
  96   }
  97 
  98   int count = 0;
  99   int start = -1;
 100 
 101 #define LOOKUP_INJECTED_FIELD(klass, name, signature, may_be_java) \
 102   if (sid == vmSymbols::VM_SYMBOL_ENUM_NAME(klass)) {              \
 103     count++;                                                       \
 104     if (start == -1) start = klass##_##name##_enum;                \
 105   }
 106   ALL_INJECTED_FIELDS(LOOKUP_INJECTED_FIELD);
 107 #undef LOOKUP_INJECTED_FIELD
 108 


 138     ik->print_on(&ls);
 139 #endif //PRODUCT
 140     vm_exit_during_initialization("Invalid layout of preloaded class: use -Xlog:class+load=info to see the origin of the problem class");
 141   }
 142   dest_offset = fd.offset();
 143 }
 144 
 145 // Overloading to pass name as a string.
 146 static void compute_offset(int& dest_offset, InstanceKlass* ik,
 147                            const char* name_string, Symbol* signature_symbol,
 148                            bool is_static = false) {
 149   TempNewSymbol name = SymbolTable::probe(name_string, (int)strlen(name_string));
 150   if (name == NULL) {
 151     ResourceMark rm;
 152     log_error(class)("Name %s should be in the SymbolTable since its class is loaded", name_string);
 153     vm_exit_during_initialization("Invalid layout of preloaded class", ik->external_name());
 154   }
 155   compute_offset(dest_offset, ik, name, signature_symbol, is_static);
 156 }
 157 












 158 int java_lang_String::value_offset  = 0;
 159 int java_lang_String::hash_offset   = 0;
 160 int java_lang_String::coder_offset  = 0;
 161 
 162 bool java_lang_String::initialized  = false;
 163 
 164 bool java_lang_String::is_instance(oop obj) {
 165   return is_instance_inlined(obj);
 166 }
 167 
 168 #if INCLUDE_CDS
 169 #define FIELD_SERIALIZE_OFFSET(offset, klass, name, signature, is_static) \
 170   f->do_u4((u4*)&offset)



 171 #endif
 172 
 173 #define FIELD_COMPUTE_OFFSET(offset, klass, name, signature, is_static) \
 174   compute_offset(offset, klass, name, vmSymbols::signature(), is_static)
 175 



 176 #define STRING_FIELDS_DO(macro) \
 177   macro(value_offset, k, vmSymbols::value_name(), byte_array_signature, false); \
 178   macro(hash_offset,  k, "hash",                  int_signature,        false); \
 179   macro(coder_offset, k, "coder",                 byte_signature,       false)
 180 
 181 void java_lang_String::compute_offsets() {
 182   if (initialized) {
 183     return;
 184   }
 185 
 186   InstanceKlass* k = SystemDictionary::String_klass();
 187   STRING_FIELDS_DO(FIELD_COMPUTE_OFFSET);
 188 
 189   initialized = true;
 190 }
 191 
 192 #if INCLUDE_CDS
 193 void java_lang_String::serialize_offsets(SerializeClosure* f) {
 194   STRING_FIELDS_DO(FIELD_SERIALIZE_OFFSET);
 195   f->do_u4((u4*)&initialized);


2699 #endif
2700 
2701 jboolean java_lang_reflect_AccessibleObject::override(oop reflect) {
2702   assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
2703   return (jboolean) reflect->bool_field(override_offset);
2704 }
2705 
2706 void java_lang_reflect_AccessibleObject::set_override(oop reflect, jboolean value) {
2707   assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
2708   reflect->bool_field_put(override_offset, (int) value);
2709 }
2710 
2711 #define METHOD_FIELDS_DO(macro) \
2712   macro(clazz_offset,          k, vmSymbols::clazz_name(),          class_signature,       false); \
2713   macro(name_offset,           k, vmSymbols::name_name(),           string_signature,      false); \
2714   macro(returnType_offset,     k, vmSymbols::returnType_name(),     class_signature,       false); \
2715   macro(parameterTypes_offset, k, vmSymbols::parameterTypes_name(), class_array_signature, false); \
2716   macro(exceptionTypes_offset, k, vmSymbols::exceptionTypes_name(), class_array_signature, false); \
2717   macro(slot_offset,           k, vmSymbols::slot_name(),           int_signature,         false); \
2718   macro(modifiers_offset,      k, vmSymbols::modifiers_name(),      int_signature,         false); \
2719   macro(signature_offset,             k, vmSymbols::signature_name(),             string_signature,     false); \
2720   macro(annotations_offset,           k, vmSymbols::annotations_name(),           byte_array_signature, false); \
2721   macro(parameter_annotations_offset, k, vmSymbols::parameter_annotations_name(), byte_array_signature, false); \
2722   macro(annotation_default_offset,    k, vmSymbols::annotation_default_name(),    byte_array_signature, false);

2723 
2724 void java_lang_reflect_Method::compute_offsets() {
2725   InstanceKlass* k = SystemDictionary::reflect_Method_klass();






2726   METHOD_FIELDS_DO(FIELD_COMPUTE_OFFSET);
2727 }
2728 
2729 #if INCLUDE_CDS
2730 void java_lang_reflect_Method::serialize_offsets(SerializeClosure* f) {
2731   METHOD_FIELDS_DO(FIELD_SERIALIZE_OFFSET);
2732 }
2733 #endif
2734 
2735 Handle java_lang_reflect_Method::create(TRAPS) {
2736   assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
2737   Klass* klass = SystemDictionary::reflect_Method_klass();
2738   // This class is eagerly initialized during VM initialization, since we keep a refence
2739   // to one of the methods
2740   assert(InstanceKlass::cast(klass)->is_initialized(), "must be initialized");
2741   return InstanceKlass::cast(klass)->allocate_instance_handle(THREAD);
2742 }
2743 
2744 oop java_lang_reflect_Method::clazz(oop reflect) {
2745   assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
2746   return reflect->obj_field(clazz_offset);
2747 }
2748 
2749 void java_lang_reflect_Method::set_clazz(oop reflect, oop value) {
2750   assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
2751    reflect->obj_field_put(clazz_offset, value);
2752 }
2753 
2754 int java_lang_reflect_Method::slot(oop reflect) {
2755   assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
2756   return reflect->int_field(slot_offset);
2757 }
2758 
2759 void java_lang_reflect_Method::set_slot(oop reflect, int value) {
2760   assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
2761   reflect->int_field_put(slot_offset, value);
2762 }
2763 





2764 void java_lang_reflect_Method::set_name(oop method, oop value) {
2765   assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
2766   method->obj_field_put(name_offset, value);
2767 }
2768 
2769 oop java_lang_reflect_Method::return_type(oop method) {
2770   assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
2771   return method->obj_field(returnType_offset);
2772 }
2773 
2774 void java_lang_reflect_Method::set_return_type(oop method, oop value) {
2775   assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
2776   method->obj_field_put(returnType_offset, value);
2777 }
2778 
2779 oop java_lang_reflect_Method::parameter_types(oop method) {
2780   assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
2781   return method->obj_field(parameterTypes_offset);
2782 }
2783 
2784 void java_lang_reflect_Method::set_parameter_types(oop method, oop value) {
2785   assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
2786   method->obj_field_put(parameterTypes_offset, value);
2787 }
2788 





2789 void java_lang_reflect_Method::set_exception_types(oop method, oop value) {
2790   assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
2791   method->obj_field_put(exceptionTypes_offset, value);
2792 }
2793 





2794 void java_lang_reflect_Method::set_modifiers(oop method, int value) {
2795   assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
2796   method->int_field_put(modifiers_offset, value);
2797 }
2798 










2799 void java_lang_reflect_Method::set_signature(oop method, oop value) {
2800   assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");

2801   method->obj_field_put(signature_offset, value);
2802 }
2803 










2804 void java_lang_reflect_Method::set_annotations(oop method, oop value) {
2805   assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");

2806   method->obj_field_put(annotations_offset, value);
2807 }
2808 










2809 void java_lang_reflect_Method::set_parameter_annotations(oop method, oop value) {
2810   assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");

2811   method->obj_field_put(parameter_annotations_offset, value);
2812 }
2813 










2814 void java_lang_reflect_Method::set_annotation_default(oop method, oop value) {
2815   assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");

2816   method->obj_field_put(annotation_default_offset, value);
2817 }
2818 
















2819 #define CONSTRUCTOR_FIELDS_DO(macro) \
2820   macro(clazz_offset,          k, vmSymbols::clazz_name(),          class_signature,       false); \
2821   macro(parameterTypes_offset, k, vmSymbols::parameterTypes_name(), class_array_signature, false); \
2822   macro(exceptionTypes_offset, k, vmSymbols::exceptionTypes_name(), class_array_signature, false); \
2823   macro(slot_offset,           k, vmSymbols::slot_name(),           int_signature,         false); \
2824   macro(modifiers_offset,      k, vmSymbols::modifiers_name(),      int_signature,         false); \
2825   macro(signature_offset,             k, vmSymbols::signature_name(),             string_signature,     false); \
2826   macro(annotations_offset,           k, vmSymbols::annotations_name(),           byte_array_signature, false); \
2827   macro(parameter_annotations_offset, k, vmSymbols::parameter_annotations_name(), byte_array_signature, false);


2828 
2829 void java_lang_reflect_Constructor::compute_offsets() {
2830   InstanceKlass* k = SystemDictionary::reflect_Constructor_klass();





2831   CONSTRUCTOR_FIELDS_DO(FIELD_COMPUTE_OFFSET);
2832 }
2833 
2834 #if INCLUDE_CDS
2835 void java_lang_reflect_Constructor::serialize_offsets(SerializeClosure* f) {
2836   CONSTRUCTOR_FIELDS_DO(FIELD_SERIALIZE_OFFSET);
2837 }
2838 #endif
2839 
2840 Handle java_lang_reflect_Constructor::create(TRAPS) {
2841   assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
2842   Symbol* name = vmSymbols::java_lang_reflect_Constructor();
2843   Klass* k = SystemDictionary::resolve_or_fail(name, true, CHECK_NH);
2844   InstanceKlass* ik = InstanceKlass::cast(k);
2845   // Ensure it is initialized
2846   ik->initialize(CHECK_NH);
2847   return ik->allocate_instance_handle(THREAD);
2848 }
2849 
2850 oop java_lang_reflect_Constructor::clazz(oop reflect) {
2851   assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
2852   return reflect->obj_field(clazz_offset);
2853 }
2854 
2855 void java_lang_reflect_Constructor::set_clazz(oop reflect, oop value) {
2856   assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
2857    reflect->obj_field_put(clazz_offset, value);
2858 }
2859 
2860 oop java_lang_reflect_Constructor::parameter_types(oop constructor) {
2861   assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
2862   return constructor->obj_field(parameterTypes_offset);
2863 }
2864 
2865 void java_lang_reflect_Constructor::set_parameter_types(oop constructor, oop value) {
2866   assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
2867   constructor->obj_field_put(parameterTypes_offset, value);
2868 }
2869 





2870 void java_lang_reflect_Constructor::set_exception_types(oop constructor, oop value) {
2871   assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
2872   constructor->obj_field_put(exceptionTypes_offset, value);
2873 }
2874 
2875 int java_lang_reflect_Constructor::slot(oop reflect) {
2876   assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
2877   return reflect->int_field(slot_offset);
2878 }
2879 
2880 void java_lang_reflect_Constructor::set_slot(oop reflect, int value) {
2881   assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
2882   reflect->int_field_put(slot_offset, value);
2883 }
2884 





2885 void java_lang_reflect_Constructor::set_modifiers(oop constructor, int value) {
2886   assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
2887   constructor->int_field_put(modifiers_offset, value);
2888 }
2889 










2890 void java_lang_reflect_Constructor::set_signature(oop constructor, oop value) {
2891   assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");

2892   constructor->obj_field_put(signature_offset, value);
2893 }
2894 










2895 void java_lang_reflect_Constructor::set_annotations(oop constructor, oop value) {
2896   assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");

2897   constructor->obj_field_put(annotations_offset, value);
2898 }
2899 










2900 void java_lang_reflect_Constructor::set_parameter_annotations(oop method, oop value) {
2901   assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");

2902   method->obj_field_put(parameter_annotations_offset, value);
2903 }
2904 
















2905 #define FIELD_FIELDS_DO(macro) \
2906   macro(clazz_offset,     k, vmSymbols::clazz_name(),     class_signature,  false); \
2907   macro(name_offset,      k, vmSymbols::name_name(),      string_signature, false); \
2908   macro(type_offset,      k, vmSymbols::type_name(),      class_signature,  false); \
2909   macro(slot_offset,      k, vmSymbols::slot_name(),      int_signature,    false); \
2910   macro(modifiers_offset, k, vmSymbols::modifiers_name(), int_signature,    false); \
2911   macro(signature_offset,        k, vmSymbols::signature_name(),        string_signature,     false); \
2912   macro(annotations_offset,      k, vmSymbols::annotations_name(),      byte_array_signature, false);

2913 
2914 void java_lang_reflect_Field::compute_offsets() {
2915   InstanceKlass* k = SystemDictionary::reflect_Field_klass();




2916   FIELD_FIELDS_DO(FIELD_COMPUTE_OFFSET);
2917 }
2918 
2919 #if INCLUDE_CDS
2920 void java_lang_reflect_Field::serialize_offsets(SerializeClosure* f) {
2921   FIELD_FIELDS_DO(FIELD_SERIALIZE_OFFSET);
2922 }
2923 #endif
2924 
2925 Handle java_lang_reflect_Field::create(TRAPS) {
2926   assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
2927   Symbol* name = vmSymbols::java_lang_reflect_Field();
2928   Klass* k = SystemDictionary::resolve_or_fail(name, true, CHECK_NH);
2929   InstanceKlass* ik = InstanceKlass::cast(k);
2930   // Ensure it is initialized
2931   ik->initialize(CHECK_NH);
2932   return ik->allocate_instance_handle(THREAD);
2933 }
2934 
2935 oop java_lang_reflect_Field::clazz(oop reflect) {


2965 int java_lang_reflect_Field::slot(oop reflect) {
2966   assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
2967   return reflect->int_field(slot_offset);
2968 }
2969 
2970 void java_lang_reflect_Field::set_slot(oop reflect, int value) {
2971   assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
2972   reflect->int_field_put(slot_offset, value);
2973 }
2974 
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)


3992 int java_lang_Class::_signers_offset;
3993 GrowableArray<Klass*>* java_lang_Class::_fixup_mirror_list = NULL;
3994 GrowableArray<Klass*>* java_lang_Class::_fixup_module_field_list = NULL;
3995 int java_lang_Throwable::backtrace_offset;
3996 int java_lang_Throwable::detailMessage_offset;
3997 int java_lang_Throwable::stackTrace_offset;
3998 int java_lang_Throwable::depth_offset;
3999 int java_lang_Throwable::static_unassigned_stacktrace_offset;
4000 int java_lang_reflect_AccessibleObject::override_offset;
4001 int java_lang_reflect_Method::clazz_offset;
4002 int java_lang_reflect_Method::name_offset;
4003 int java_lang_reflect_Method::returnType_offset;
4004 int java_lang_reflect_Method::parameterTypes_offset;
4005 int java_lang_reflect_Method::exceptionTypes_offset;
4006 int java_lang_reflect_Method::slot_offset;
4007 int java_lang_reflect_Method::modifiers_offset;
4008 int java_lang_reflect_Method::signature_offset;
4009 int java_lang_reflect_Method::annotations_offset;
4010 int java_lang_reflect_Method::parameter_annotations_offset;
4011 int java_lang_reflect_Method::annotation_default_offset;

4012 int java_lang_reflect_Constructor::clazz_offset;
4013 int java_lang_reflect_Constructor::parameterTypes_offset;
4014 int java_lang_reflect_Constructor::exceptionTypes_offset;
4015 int java_lang_reflect_Constructor::slot_offset;
4016 int java_lang_reflect_Constructor::modifiers_offset;
4017 int java_lang_reflect_Constructor::signature_offset;
4018 int java_lang_reflect_Constructor::annotations_offset;
4019 int java_lang_reflect_Constructor::parameter_annotations_offset;

4020 int java_lang_reflect_Field::clazz_offset;
4021 int java_lang_reflect_Field::name_offset;
4022 int java_lang_reflect_Field::type_offset;
4023 int java_lang_reflect_Field::slot_offset;
4024 int java_lang_reflect_Field::modifiers_offset;
4025 int java_lang_reflect_Field::signature_offset;
4026 int java_lang_reflect_Field::annotations_offset;

4027 int java_lang_reflect_Parameter::name_offset;
4028 int java_lang_reflect_Parameter::modifiers_offset;
4029 int java_lang_reflect_Parameter::index_offset;
4030 int java_lang_reflect_Parameter::executable_offset;
4031 int java_lang_boxing_object::value_offset;
4032 int java_lang_boxing_object::long_value_offset;
4033 int java_lang_ref_Reference::referent_offset;
4034 int java_lang_ref_Reference::queue_offset;
4035 int java_lang_ref_Reference::next_offset;
4036 int java_lang_ref_Reference::discovered_offset;
4037 int java_lang_ref_SoftReference::timestamp_offset;
4038 int java_lang_ref_SoftReference::static_clock_offset;
4039 int java_lang_ClassLoader::parent_offset;
4040 int java_lang_System::static_in_offset;
4041 int java_lang_System::static_out_offset;
4042 int java_lang_System::static_err_offset;
4043 int java_lang_System::static_security_offset;
4044 int java_lang_StackTraceElement::methodName_offset;
4045 int java_lang_StackTraceElement::fileName_offset;
4046 int java_lang_StackTraceElement::lineNumber_offset;


< prev index next >