comparison src/share/vm/classfile/javaClasses.cpp @ 7457:35431a769282

8004823: Add VM support for type annotation reflection Reviewed-by: dholmes, coleenp Contributed-by: joel.franck@oracle.com
author stefank
date Thu, 20 Dec 2012 10:22:19 +0100
parents 90273fc0a981
children 4daebd4cc1dd
comparison
equal deleted inserted replaced
7456:7d42f3b08300 7457:35431a769282
1811 // The generic signature and annotations fields are only present in 1.5 1811 // The generic signature and annotations fields are only present in 1.5
1812 signature_offset = -1; 1812 signature_offset = -1;
1813 annotations_offset = -1; 1813 annotations_offset = -1;
1814 parameter_annotations_offset = -1; 1814 parameter_annotations_offset = -1;
1815 annotation_default_offset = -1; 1815 annotation_default_offset = -1;
1816 type_annotations_offset = -1;
1816 compute_optional_offset(signature_offset, k, vmSymbols::signature_name(), vmSymbols::string_signature()); 1817 compute_optional_offset(signature_offset, k, vmSymbols::signature_name(), vmSymbols::string_signature());
1817 compute_optional_offset(annotations_offset, k, vmSymbols::annotations_name(), vmSymbols::byte_array_signature()); 1818 compute_optional_offset(annotations_offset, k, vmSymbols::annotations_name(), vmSymbols::byte_array_signature());
1818 compute_optional_offset(parameter_annotations_offset, k, vmSymbols::parameter_annotations_name(), vmSymbols::byte_array_signature()); 1819 compute_optional_offset(parameter_annotations_offset, k, vmSymbols::parameter_annotations_name(), vmSymbols::byte_array_signature());
1819 compute_optional_offset(annotation_default_offset, k, vmSymbols::annotation_default_name(), vmSymbols::byte_array_signature()); 1820 compute_optional_offset(annotation_default_offset, k, vmSymbols::annotation_default_name(), vmSymbols::byte_array_signature());
1821 compute_optional_offset(type_annotations_offset, k, vmSymbols::type_annotations_name(), vmSymbols::byte_array_signature());
1820 } 1822 }
1821 1823
1822 Handle java_lang_reflect_Method::create(TRAPS) { 1824 Handle java_lang_reflect_Method::create(TRAPS) {
1823 assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem"); 1825 assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
1824 Klass* klass = SystemDictionary::reflect_Method_klass(); 1826 Klass* klass = SystemDictionary::reflect_Method_klass();
1958 1960
1959 void java_lang_reflect_Method::set_annotation_default(oop method, oop value) { 1961 void java_lang_reflect_Method::set_annotation_default(oop method, oop value) {
1960 assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem"); 1962 assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
1961 assert(has_annotation_default_field(), "annotation default field must be present"); 1963 assert(has_annotation_default_field(), "annotation default field must be present");
1962 method->obj_field_put(annotation_default_offset, value); 1964 method->obj_field_put(annotation_default_offset, value);
1965 }
1966
1967 bool java_lang_reflect_Method::has_type_annotations_field() {
1968 return (type_annotations_offset >= 0);
1969 }
1970
1971 oop java_lang_reflect_Method::type_annotations(oop method) {
1972 assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
1973 assert(has_type_annotations_field(), "type_annotations field must be present");
1974 return method->obj_field(type_annotations_offset);
1975 }
1976
1977 void java_lang_reflect_Method::set_type_annotations(oop method, oop value) {
1978 assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
1979 assert(has_type_annotations_field(), "type_annotations field must be present");
1980 method->obj_field_put(type_annotations_offset, value);
1963 } 1981 }
1964 1982
1965 void java_lang_reflect_Constructor::compute_offsets() { 1983 void java_lang_reflect_Constructor::compute_offsets() {
1966 Klass* k = SystemDictionary::reflect_Constructor_klass(); 1984 Klass* k = SystemDictionary::reflect_Constructor_klass();
1967 compute_offset(clazz_offset, k, vmSymbols::clazz_name(), vmSymbols::class_signature()); 1985 compute_offset(clazz_offset, k, vmSymbols::clazz_name(), vmSymbols::class_signature());
1971 compute_offset(modifiers_offset, k, vmSymbols::modifiers_name(), vmSymbols::int_signature()); 1989 compute_offset(modifiers_offset, k, vmSymbols::modifiers_name(), vmSymbols::int_signature());
1972 // The generic signature and annotations fields are only present in 1.5 1990 // The generic signature and annotations fields are only present in 1.5
1973 signature_offset = -1; 1991 signature_offset = -1;
1974 annotations_offset = -1; 1992 annotations_offset = -1;
1975 parameter_annotations_offset = -1; 1993 parameter_annotations_offset = -1;
1994 type_annotations_offset = -1;
1976 compute_optional_offset(signature_offset, k, vmSymbols::signature_name(), vmSymbols::string_signature()); 1995 compute_optional_offset(signature_offset, k, vmSymbols::signature_name(), vmSymbols::string_signature());
1977 compute_optional_offset(annotations_offset, k, vmSymbols::annotations_name(), vmSymbols::byte_array_signature()); 1996 compute_optional_offset(annotations_offset, k, vmSymbols::annotations_name(), vmSymbols::byte_array_signature());
1978 compute_optional_offset(parameter_annotations_offset, k, vmSymbols::parameter_annotations_name(), vmSymbols::byte_array_signature()); 1997 compute_optional_offset(parameter_annotations_offset, k, vmSymbols::parameter_annotations_name(), vmSymbols::byte_array_signature());
1998 compute_optional_offset(type_annotations_offset, k, vmSymbols::type_annotations_name(), vmSymbols::byte_array_signature());
1979 } 1999 }
1980 2000
1981 Handle java_lang_reflect_Constructor::create(TRAPS) { 2001 Handle java_lang_reflect_Constructor::create(TRAPS) {
1982 assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem"); 2002 assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
1983 Symbol* name = vmSymbols::java_lang_reflect_Constructor(); 2003 Symbol* name = vmSymbols::java_lang_reflect_Constructor();
2082 2102
2083 void java_lang_reflect_Constructor::set_parameter_annotations(oop method, oop value) { 2103 void java_lang_reflect_Constructor::set_parameter_annotations(oop method, oop value) {
2084 assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem"); 2104 assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
2085 assert(has_parameter_annotations_field(), "parameter annotations field must be present"); 2105 assert(has_parameter_annotations_field(), "parameter annotations field must be present");
2086 method->obj_field_put(parameter_annotations_offset, value); 2106 method->obj_field_put(parameter_annotations_offset, value);
2107 }
2108
2109 bool java_lang_reflect_Constructor::has_type_annotations_field() {
2110 return (type_annotations_offset >= 0);
2111 }
2112
2113 oop java_lang_reflect_Constructor::type_annotations(oop constructor) {
2114 assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
2115 assert(has_type_annotations_field(), "type_annotations field must be present");
2116 return constructor->obj_field(type_annotations_offset);
2117 }
2118
2119 void java_lang_reflect_Constructor::set_type_annotations(oop constructor, oop value) {
2120 assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
2121 assert(has_type_annotations_field(), "type_annotations field must be present");
2122 constructor->obj_field_put(type_annotations_offset, value);
2087 } 2123 }
2088 2124
2089 void java_lang_reflect_Field::compute_offsets() { 2125 void java_lang_reflect_Field::compute_offsets() {
2090 Klass* k = SystemDictionary::reflect_Field_klass(); 2126 Klass* k = SystemDictionary::reflect_Field_klass();
2091 compute_offset(clazz_offset, k, vmSymbols::clazz_name(), vmSymbols::class_signature()); 2127 compute_offset(clazz_offset, k, vmSymbols::clazz_name(), vmSymbols::class_signature());
2094 compute_offset(slot_offset, k, vmSymbols::slot_name(), vmSymbols::int_signature()); 2130 compute_offset(slot_offset, k, vmSymbols::slot_name(), vmSymbols::int_signature());
2095 compute_offset(modifiers_offset, k, vmSymbols::modifiers_name(), vmSymbols::int_signature()); 2131 compute_offset(modifiers_offset, k, vmSymbols::modifiers_name(), vmSymbols::int_signature());
2096 // The generic signature and annotations fields are only present in 1.5 2132 // The generic signature and annotations fields are only present in 1.5
2097 signature_offset = -1; 2133 signature_offset = -1;
2098 annotations_offset = -1; 2134 annotations_offset = -1;
2135 type_annotations_offset = -1;
2099 compute_optional_offset(signature_offset, k, vmSymbols::signature_name(), vmSymbols::string_signature()); 2136 compute_optional_offset(signature_offset, k, vmSymbols::signature_name(), vmSymbols::string_signature());
2100 compute_optional_offset(annotations_offset, k, vmSymbols::annotations_name(), vmSymbols::byte_array_signature()); 2137 compute_optional_offset(annotations_offset, k, vmSymbols::annotations_name(), vmSymbols::byte_array_signature());
2138 compute_optional_offset(type_annotations_offset, k, vmSymbols::type_annotations_name(), vmSymbols::byte_array_signature());
2101 } 2139 }
2102 2140
2103 Handle java_lang_reflect_Field::create(TRAPS) { 2141 Handle java_lang_reflect_Field::create(TRAPS) {
2104 assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem"); 2142 assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
2105 Symbol* name = vmSymbols::java_lang_reflect_Field(); 2143 Symbol* name = vmSymbols::java_lang_reflect_Field();
2190 assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem"); 2228 assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
2191 assert(has_annotations_field(), "annotations field must be present"); 2229 assert(has_annotations_field(), "annotations field must be present");
2192 field->obj_field_put(annotations_offset, value); 2230 field->obj_field_put(annotations_offset, value);
2193 } 2231 }
2194 2232
2233 bool java_lang_reflect_Field::has_type_annotations_field() {
2234 return (type_annotations_offset >= 0);
2235 }
2236
2237 oop java_lang_reflect_Field::type_annotations(oop field) {
2238 assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
2239 assert(has_type_annotations_field(), "type_annotations field must be present");
2240 return field->obj_field(type_annotations_offset);
2241 }
2242
2243 void java_lang_reflect_Field::set_type_annotations(oop field, oop value) {
2244 assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
2245 assert(has_type_annotations_field(), "type_annotations field must be present");
2246 field->obj_field_put(type_annotations_offset, value);
2247 }
2195 2248
2196 void sun_reflect_ConstantPool::compute_offsets() { 2249 void sun_reflect_ConstantPool::compute_offsets() {
2197 Klass* k = SystemDictionary::reflect_ConstantPool_klass(); 2250 Klass* k = SystemDictionary::reflect_ConstantPool_klass();
2198 // This null test can be removed post beta 2251 // This null test can be removed post beta
2199 if (k != NULL) { 2252 if (k != NULL) {
2855 int java_lang_reflect_Method::modifiers_offset; 2908 int java_lang_reflect_Method::modifiers_offset;
2856 int java_lang_reflect_Method::signature_offset; 2909 int java_lang_reflect_Method::signature_offset;
2857 int java_lang_reflect_Method::annotations_offset; 2910 int java_lang_reflect_Method::annotations_offset;
2858 int java_lang_reflect_Method::parameter_annotations_offset; 2911 int java_lang_reflect_Method::parameter_annotations_offset;
2859 int java_lang_reflect_Method::annotation_default_offset; 2912 int java_lang_reflect_Method::annotation_default_offset;
2913 int java_lang_reflect_Method::type_annotations_offset;
2860 int java_lang_reflect_Constructor::clazz_offset; 2914 int java_lang_reflect_Constructor::clazz_offset;
2861 int java_lang_reflect_Constructor::parameterTypes_offset; 2915 int java_lang_reflect_Constructor::parameterTypes_offset;
2862 int java_lang_reflect_Constructor::exceptionTypes_offset; 2916 int java_lang_reflect_Constructor::exceptionTypes_offset;
2863 int java_lang_reflect_Constructor::slot_offset; 2917 int java_lang_reflect_Constructor::slot_offset;
2864 int java_lang_reflect_Constructor::modifiers_offset; 2918 int java_lang_reflect_Constructor::modifiers_offset;
2865 int java_lang_reflect_Constructor::signature_offset; 2919 int java_lang_reflect_Constructor::signature_offset;
2866 int java_lang_reflect_Constructor::annotations_offset; 2920 int java_lang_reflect_Constructor::annotations_offset;
2867 int java_lang_reflect_Constructor::parameter_annotations_offset; 2921 int java_lang_reflect_Constructor::parameter_annotations_offset;
2922 int java_lang_reflect_Constructor::type_annotations_offset;
2868 int java_lang_reflect_Field::clazz_offset; 2923 int java_lang_reflect_Field::clazz_offset;
2869 int java_lang_reflect_Field::name_offset; 2924 int java_lang_reflect_Field::name_offset;
2870 int java_lang_reflect_Field::type_offset; 2925 int java_lang_reflect_Field::type_offset;
2871 int java_lang_reflect_Field::slot_offset; 2926 int java_lang_reflect_Field::slot_offset;
2872 int java_lang_reflect_Field::modifiers_offset; 2927 int java_lang_reflect_Field::modifiers_offset;
2873 int java_lang_reflect_Field::signature_offset; 2928 int java_lang_reflect_Field::signature_offset;
2874 int java_lang_reflect_Field::annotations_offset; 2929 int java_lang_reflect_Field::annotations_offset;
2930 int java_lang_reflect_Field::type_annotations_offset;
2875 int java_lang_boxing_object::value_offset; 2931 int java_lang_boxing_object::value_offset;
2876 int java_lang_boxing_object::long_value_offset; 2932 int java_lang_boxing_object::long_value_offset;
2877 int java_lang_ref_Reference::referent_offset; 2933 int java_lang_ref_Reference::referent_offset;
2878 int java_lang_ref_Reference::queue_offset; 2934 int java_lang_ref_Reference::queue_offset;
2879 int java_lang_ref_Reference::next_offset; 2935 int java_lang_ref_Reference::next_offset;