src/hotspot/share/classfile/javaClasses.cpp
changeset 51807 3221f5e14866
parent 51796 9d3a00c8c047
child 51823 2a51125b2794
equal deleted inserted replaced
51806:1ecc914fb707 51807:3221f5e14866
    84 
    84 
    85 int JavaClasses::compute_injected_offset(InjectedFieldID id) {
    85 int JavaClasses::compute_injected_offset(InjectedFieldID id) {
    86   return _injected_fields[id].compute_offset();
    86   return _injected_fields[id].compute_offset();
    87 }
    87 }
    88 
    88 
    89 
       
    90 InjectedField* JavaClasses::get_injected(Symbol* class_name, int* field_count) {
    89 InjectedField* JavaClasses::get_injected(Symbol* class_name, int* field_count) {
    91   *field_count = 0;
    90   *field_count = 0;
    92 
    91 
    93   vmSymbols::SID sid = vmSymbols::find_sid(class_name);
    92   vmSymbols::SID sid = vmSymbols::find_sid(class_name);
    94   if (sid == vmSymbols::NO_SID) {
    93   if (sid == vmSymbols::NO_SID) {
   154     vm_exit_during_initialization("Invalid layout of preloaded class", ik->external_name());
   153     vm_exit_during_initialization("Invalid layout of preloaded class", ik->external_name());
   155   }
   154   }
   156   compute_offset(dest_offset, ik, name, signature_symbol, is_static);
   155   compute_offset(dest_offset, ik, name, signature_symbol, is_static);
   157 }
   156 }
   158 
   157 
   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;
   158 int java_lang_String::value_offset  = 0;
   172 int java_lang_String::hash_offset   = 0;
   159 int java_lang_String::hash_offset   = 0;
   173 int java_lang_String::coder_offset  = 0;
   160 int java_lang_String::coder_offset  = 0;
   174 
   161 
   175 bool java_lang_String::initialized  = false;
   162 bool java_lang_String::initialized  = false;
   179 }
   166 }
   180 
   167 
   181 #if INCLUDE_CDS
   168 #if INCLUDE_CDS
   182 #define FIELD_SERIALIZE_OFFSET(offset, klass, name, signature, is_static) \
   169 #define FIELD_SERIALIZE_OFFSET(offset, klass, name, signature, is_static) \
   183   f->do_u4((u4*)&offset)
   170   f->do_u4((u4*)&offset)
   184 
       
   185 #define FIELD_SERIALIZE_OFFSET_OPTIONAL(offset, klass, name, signature) \
       
   186   f->do_u4((u4*)&offset)
       
   187 #endif
   171 #endif
   188 
   172 
   189 #define FIELD_COMPUTE_OFFSET(offset, klass, name, signature, is_static) \
   173 #define FIELD_COMPUTE_OFFSET(offset, klass, name, signature, is_static) \
   190   compute_offset(offset, klass, name, vmSymbols::signature(), is_static)
   174   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 
   175 
   195 #define STRING_FIELDS_DO(macro) \
   176 #define STRING_FIELDS_DO(macro) \
   196   macro(value_offset, k, vmSymbols::value_name(), byte_array_signature, false); \
   177   macro(value_offset, k, vmSymbols::value_name(), byte_array_signature, false); \
   197   macro(hash_offset,  k, "hash",                  int_signature,        false); \
   178   macro(hash_offset,  k, "hash",                  int_signature,        false); \
   198   macro(coder_offset, k, "coder",                 byte_signature,       false)
   179   macro(coder_offset, k, "coder",                 byte_signature,       false)
  2733   macro(returnType_offset,     k, vmSymbols::returnType_name(),     class_signature,       false); \
  2714   macro(returnType_offset,     k, vmSymbols::returnType_name(),     class_signature,       false); \
  2734   macro(parameterTypes_offset, k, vmSymbols::parameterTypes_name(), class_array_signature, false); \
  2715   macro(parameterTypes_offset, k, vmSymbols::parameterTypes_name(), class_array_signature, false); \
  2735   macro(exceptionTypes_offset, k, vmSymbols::exceptionTypes_name(), class_array_signature, false); \
  2716   macro(exceptionTypes_offset, k, vmSymbols::exceptionTypes_name(), class_array_signature, false); \
  2736   macro(slot_offset,           k, vmSymbols::slot_name(),           int_signature,         false); \
  2717   macro(slot_offset,           k, vmSymbols::slot_name(),           int_signature,         false); \
  2737   macro(modifiers_offset,      k, vmSymbols::modifiers_name(),      int_signature,         false); \
  2718   macro(modifiers_offset,      k, vmSymbols::modifiers_name(),      int_signature,         false); \
  2738   macro##_OPTIONAL(signature_offset,             k, vmSymbols::signature_name(),             string_signature); \
  2719   macro(signature_offset,             k, vmSymbols::signature_name(),             string_signature,     false); \
  2739   macro##_OPTIONAL(annotations_offset,           k, vmSymbols::annotations_name(),           byte_array_signature); \
  2720   macro(annotations_offset,           k, vmSymbols::annotations_name(),           byte_array_signature, false); \
  2740   macro##_OPTIONAL(parameter_annotations_offset, k, vmSymbols::parameter_annotations_name(), byte_array_signature); \
  2721   macro(parameter_annotations_offset, k, vmSymbols::parameter_annotations_name(), byte_array_signature, false); \
  2741   macro##_OPTIONAL(annotation_default_offset,    k, vmSymbols::annotation_default_name(),    byte_array_signature); \
  2722   macro(annotation_default_offset,    k, vmSymbols::annotation_default_name(),    byte_array_signature, false);
  2742   macro##_OPTIONAL(type_annotations_offset,      k, vmSymbols::type_annotations_name(),      byte_array_signature)
       
  2743 
  2723 
  2744 void java_lang_reflect_Method::compute_offsets() {
  2724 void java_lang_reflect_Method::compute_offsets() {
  2745   InstanceKlass* k = SystemDictionary::reflect_Method_klass();
  2725   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);
  2726   METHOD_FIELDS_DO(FIELD_COMPUTE_OFFSET);
  2753 }
  2727 }
  2754 
  2728 
  2755 #if INCLUDE_CDS
  2729 #if INCLUDE_CDS
  2756 void java_lang_reflect_Method::serialize_offsets(SerializeClosure* f) {
  2730 void java_lang_reflect_Method::serialize_offsets(SerializeClosure* f) {
  2785 void java_lang_reflect_Method::set_slot(oop reflect, int value) {
  2759 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");
  2760   assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
  2787   reflect->int_field_put(slot_offset, value);
  2761   reflect->int_field_put(slot_offset, value);
  2788 }
  2762 }
  2789 
  2763 
  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) {
  2764 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");
  2765   assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
  2797   method->obj_field_put(name_offset, value);
  2766   method->obj_field_put(name_offset, value);
  2798 }
  2767 }
  2799 
  2768 
  2815 void java_lang_reflect_Method::set_parameter_types(oop method, oop value) {
  2784 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");
  2785   assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
  2817   method->obj_field_put(parameterTypes_offset, value);
  2786   method->obj_field_put(parameterTypes_offset, value);
  2818 }
  2787 }
  2819 
  2788 
  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) {
  2789 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");
  2790   assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
  2827   method->obj_field_put(exceptionTypes_offset, value);
  2791   method->obj_field_put(exceptionTypes_offset, value);
  2828 }
  2792 }
  2829 
  2793 
  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) {
  2794 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");
  2795   assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
  2837   method->int_field_put(modifiers_offset, value);
  2796   method->int_field_put(modifiers_offset, value);
  2838 }
  2797 }
  2839 
  2798 
  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) {
  2799 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");
  2800   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);
  2801   method->obj_field_put(signature_offset, value);
  2854 }
  2802 }
  2855 
  2803 
  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) {
  2804 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");
  2805   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);
  2806   method->obj_field_put(annotations_offset, value);
  2870 }
  2807 }
  2871 
  2808 
  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) {
  2809 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");
  2810   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);
  2811   method->obj_field_put(parameter_annotations_offset, value);
  2886 }
  2812 }
  2887 
  2813 
  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) {
  2814 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");
  2815   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);
  2816   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 }
  2817 }
  2919 
  2818 
  2920 #define CONSTRUCTOR_FIELDS_DO(macro) \
  2819 #define CONSTRUCTOR_FIELDS_DO(macro) \
  2921   macro(clazz_offset,          k, vmSymbols::clazz_name(),          class_signature,       false); \
  2820   macro(clazz_offset,          k, vmSymbols::clazz_name(),          class_signature,       false); \
  2922   macro(parameterTypes_offset, k, vmSymbols::parameterTypes_name(), class_array_signature, false); \
  2821   macro(parameterTypes_offset, k, vmSymbols::parameterTypes_name(), class_array_signature, false); \
  2923   macro(exceptionTypes_offset, k, vmSymbols::exceptionTypes_name(), class_array_signature, false); \
  2822   macro(exceptionTypes_offset, k, vmSymbols::exceptionTypes_name(), class_array_signature, false); \
  2924   macro(slot_offset,           k, vmSymbols::slot_name(),           int_signature,         false); \
  2823   macro(slot_offset,           k, vmSymbols::slot_name(),           int_signature,         false); \
  2925   macro(modifiers_offset,      k, vmSymbols::modifiers_name(),      int_signature,         false); \
  2824   macro(modifiers_offset,      k, vmSymbols::modifiers_name(),      int_signature,         false); \
  2926   macro##_OPTIONAL(signature_offset,             k, vmSymbols::signature_name(),             string_signature); \
  2825   macro(signature_offset,             k, vmSymbols::signature_name(),             string_signature,     false); \
  2927   macro##_OPTIONAL(annotations_offset,           k, vmSymbols::annotations_name(),           byte_array_signature); \
  2826   macro(annotations_offset,           k, vmSymbols::annotations_name(),           byte_array_signature, false); \
  2928   macro##_OPTIONAL(parameter_annotations_offset, k, vmSymbols::parameter_annotations_name(), byte_array_signature); \
  2827   macro(parameter_annotations_offset, k, vmSymbols::parameter_annotations_name(), byte_array_signature, false);
  2929   macro##_OPTIONAL(type_annotations_offset,      k, vmSymbols::type_annotations_name(),      byte_array_signature)
       
  2930 
       
  2931 
  2828 
  2932 void java_lang_reflect_Constructor::compute_offsets() {
  2829 void java_lang_reflect_Constructor::compute_offsets() {
  2933   InstanceKlass* k = SystemDictionary::reflect_Constructor_klass();
  2830   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);
  2831   CONSTRUCTOR_FIELDS_DO(FIELD_COMPUTE_OFFSET);
  2940 }
  2832 }
  2941 
  2833 
  2942 #if INCLUDE_CDS
  2834 #if INCLUDE_CDS
  2943 void java_lang_reflect_Constructor::serialize_offsets(SerializeClosure* f) {
  2835 void java_lang_reflect_Constructor::serialize_offsets(SerializeClosure* f) {
  2973 void java_lang_reflect_Constructor::set_parameter_types(oop constructor, oop value) {
  2865 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");
  2866   assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
  2975   constructor->obj_field_put(parameterTypes_offset, value);
  2867   constructor->obj_field_put(parameterTypes_offset, value);
  2976 }
  2868 }
  2977 
  2869 
  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) {
  2870 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");
  2871   assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
  2985   constructor->obj_field_put(exceptionTypes_offset, value);
  2872   constructor->obj_field_put(exceptionTypes_offset, value);
  2986 }
  2873 }
  2987 
  2874 
  2993 void java_lang_reflect_Constructor::set_slot(oop reflect, int value) {
  2880 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");
  2881   assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
  2995   reflect->int_field_put(slot_offset, value);
  2882   reflect->int_field_put(slot_offset, value);
  2996 }
  2883 }
  2997 
  2884 
  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) {
  2885 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");
  2886   assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
  3005   constructor->int_field_put(modifiers_offset, value);
  2887   constructor->int_field_put(modifiers_offset, value);
  3006 }
  2888 }
  3007 
  2889 
  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) {
  2890 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");
  2891   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);
  2892   constructor->obj_field_put(signature_offset, value);
  3022 }
  2893 }
  3023 
  2894 
  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) {
  2895 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");
  2896   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);
  2897   constructor->obj_field_put(annotations_offset, value);
  3038 }
  2898 }
  3039 
  2899 
  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) {
  2900 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");
  2901   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);
  2902   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 }
  2903 }
  3071 
  2904 
  3072 #define FIELD_FIELDS_DO(macro) \
  2905 #define FIELD_FIELDS_DO(macro) \
  3073   macro(clazz_offset,     k, vmSymbols::clazz_name(),     class_signature,  false); \
  2906   macro(clazz_offset,     k, vmSymbols::clazz_name(),     class_signature,  false); \
  3074   macro(name_offset,      k, vmSymbols::name_name(),      string_signature, false); \
  2907   macro(name_offset,      k, vmSymbols::name_name(),      string_signature, false); \
  3075   macro(type_offset,      k, vmSymbols::type_name(),      class_signature,  false); \
  2908   macro(type_offset,      k, vmSymbols::type_name(),      class_signature,  false); \
  3076   macro(slot_offset,      k, vmSymbols::slot_name(),      int_signature,    false); \
  2909   macro(slot_offset,      k, vmSymbols::slot_name(),      int_signature,    false); \
  3077   macro(modifiers_offset, k, vmSymbols::modifiers_name(), int_signature,    false); \
  2910   macro(modifiers_offset, k, vmSymbols::modifiers_name(), int_signature,    false); \
  3078   macro##_OPTIONAL(signature_offset,        k, vmSymbols::signature_name(), string_signature); \
  2911   macro(signature_offset,        k, vmSymbols::signature_name(),        string_signature,     false); \
  3079   macro##_OPTIONAL(annotations_offset,      k, vmSymbols::annotations_name(),  byte_array_signature); \
  2912   macro(annotations_offset,      k, vmSymbols::annotations_name(),      byte_array_signature, false);
  3080   macro##_OPTIONAL(type_annotations_offset, k, vmSymbols::type_annotations_name(),  byte_array_signature)
       
  3081 
  2913 
  3082 void java_lang_reflect_Field::compute_offsets() {
  2914 void java_lang_reflect_Field::compute_offsets() {
  3083   InstanceKlass* k = SystemDictionary::reflect_Field_klass();
  2915   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);
  2916   FIELD_FIELDS_DO(FIELD_COMPUTE_OFFSET);
  3089 }
  2917 }
  3090 
  2918 
  3091 #if INCLUDE_CDS
  2919 #if INCLUDE_CDS
  3092 void java_lang_reflect_Field::serialize_offsets(SerializeClosure* f) {
  2920 void java_lang_reflect_Field::serialize_offsets(SerializeClosure* f) {
  3152 void java_lang_reflect_Field::set_modifiers(oop field, int value) {
  2980 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");
  2981   assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
  3154   field->int_field_put(modifiers_offset, value);
  2982   field->int_field_put(modifiers_offset, value);
  3155 }
  2983 }
  3156 
  2984 
  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) {
  2985 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");
  2986   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);
  2987   field->obj_field_put(signature_offset, value);
  3171 }
  2988 }
  3172 
  2989 
  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) {
  2990 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");
  2991   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);
  2992   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 }
  2993 }
  3204 
  2994 
  3205 #define CONSTANTPOOL_FIELDS_DO(macro) \
  2995 #define CONSTANTPOOL_FIELDS_DO(macro) \
  3206   macro(_oop_offset, k, "constantPoolOop", object_signature, false)
  2996   macro(_oop_offset, k, "constantPoolOop", object_signature, false)
  3207 
  2997 
  4217 int java_lang_reflect_Method::modifiers_offset;
  4007 int java_lang_reflect_Method::modifiers_offset;
  4218 int java_lang_reflect_Method::signature_offset;
  4008 int java_lang_reflect_Method::signature_offset;
  4219 int java_lang_reflect_Method::annotations_offset;
  4009 int java_lang_reflect_Method::annotations_offset;
  4220 int java_lang_reflect_Method::parameter_annotations_offset;
  4010 int java_lang_reflect_Method::parameter_annotations_offset;
  4221 int java_lang_reflect_Method::annotation_default_offset;
  4011 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;
  4012 int java_lang_reflect_Constructor::clazz_offset;
  4224 int java_lang_reflect_Constructor::parameterTypes_offset;
  4013 int java_lang_reflect_Constructor::parameterTypes_offset;
  4225 int java_lang_reflect_Constructor::exceptionTypes_offset;
  4014 int java_lang_reflect_Constructor::exceptionTypes_offset;
  4226 int java_lang_reflect_Constructor::slot_offset;
  4015 int java_lang_reflect_Constructor::slot_offset;
  4227 int java_lang_reflect_Constructor::modifiers_offset;
  4016 int java_lang_reflect_Constructor::modifiers_offset;
  4228 int java_lang_reflect_Constructor::signature_offset;
  4017 int java_lang_reflect_Constructor::signature_offset;
  4229 int java_lang_reflect_Constructor::annotations_offset;
  4018 int java_lang_reflect_Constructor::annotations_offset;
  4230 int java_lang_reflect_Constructor::parameter_annotations_offset;
  4019 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;
  4020 int java_lang_reflect_Field::clazz_offset;
  4233 int java_lang_reflect_Field::name_offset;
  4021 int java_lang_reflect_Field::name_offset;
  4234 int java_lang_reflect_Field::type_offset;
  4022 int java_lang_reflect_Field::type_offset;
  4235 int java_lang_reflect_Field::slot_offset;
  4023 int java_lang_reflect_Field::slot_offset;
  4236 int java_lang_reflect_Field::modifiers_offset;
  4024 int java_lang_reflect_Field::modifiers_offset;
  4237 int java_lang_reflect_Field::signature_offset;
  4025 int java_lang_reflect_Field::signature_offset;
  4238 int java_lang_reflect_Field::annotations_offset;
  4026 int java_lang_reflect_Field::annotations_offset;
  4239 int java_lang_reflect_Field::type_annotations_offset;
       
  4240 int java_lang_reflect_Parameter::name_offset;
  4027 int java_lang_reflect_Parameter::name_offset;
  4241 int java_lang_reflect_Parameter::modifiers_offset;
  4028 int java_lang_reflect_Parameter::modifiers_offset;
  4242 int java_lang_reflect_Parameter::index_offset;
  4029 int java_lang_reflect_Parameter::index_offset;
  4243 int java_lang_reflect_Parameter::executable_offset;
  4030 int java_lang_reflect_Parameter::executable_offset;
  4244 int java_lang_boxing_object::value_offset;
  4031 int java_lang_boxing_object::value_offset;