192 classfile_parse_error(
193 "Unknown constant tag %u in class file %s", tag, CHECK);
194 break;
195 }
196 }
197
198 // Allocate the remaining symbols
199 if (names_count > 0) {
200 oopFactory::new_symbols(cp, names_count, names, lengths, indices, hashValues, CHECK);
201 }
202
203 // Copy _current pointer of local copy back to stream().
204 #ifdef ASSERT
205 assert(cfs0->current() == old_current, "non-exclusive use of stream()");
206 #endif
207 cfs0->set_current(cfs1.current());
208 }
209
210 bool inline valid_cp_range(int index, int length) { return (index > 0 && index < length); }
211
212 constantPoolHandle ClassFileParser::parse_constant_pool(TRAPS) {
213 ClassFileStream* cfs = stream();
214 constantPoolHandle nullHandle;
215
216 cfs->guarantee_more(3, CHECK_(nullHandle)); // length, first cp tag
217 u2 length = cfs->get_u2_fast();
218 guarantee_property(
219 length >= 1, "Illegal constant pool size %u in class file %s",
220 length, CHECK_(nullHandle));
221 constantPoolOop constant_pool =
222 oopFactory::new_constantPool(length, CHECK_(nullHandle));
223 constantPoolHandle cp (THREAD, constant_pool);
224
225 cp->set_partially_loaded(); // Enables heap verify to work on partial constantPoolOops
226
227 // parsing constant pool entries
228 parse_constant_pool_entries(cp, length, CHECK_(nullHandle));
229
230 int index = 1; // declared outside of loops for portability
231
1179 u2 len = *checked_exceptions_length;
1180 cfs->guarantee_more(2 * len, CHECK_NULL);
1181 for (int i = 0; i < len; i++) {
1182 checked_exception = cfs->get_u2_fast();
1183 check_property(
1184 valid_cp_range(checked_exception, cp->length()) &&
1185 cp->tag_at(checked_exception).is_klass_reference(),
1186 "Exception name has bad type at constant pool %u in class file %s",
1187 checked_exception, CHECK_NULL);
1188 }
1189 }
1190 // check exceptions attribute length
1191 if (_need_verify) {
1192 guarantee_property(method_attribute_length == (sizeof(*checked_exceptions_length) +
1193 sizeof(u2) * size),
1194 "Exceptions attribute has wrong length in class file %s", CHECK_NULL);
1195 }
1196 return checked_exceptions_start;
1197 }
1198
1199
1200 #define MAX_ARGS_SIZE 255
1201 #define MAX_CODE_SIZE 65535
1202 #define INITIAL_MAX_LVT_NUMBER 256
1203
1204 // Note: the parse_method below is big and clunky because all parsing of the code and exceptions
1205 // attribute is inlined. This is curbersome to avoid since we inline most of the parts in the
1206 // methodOop to save footprint, so we only know the size of the resulting methodOop when the
1207 // entire method attribute is parsed.
1208 //
1209 // The promoted_flags parameter is used to pass relevant access_flags
1210 // from the method back up to the containing klass. These flag values
1211 // are added to klass's access_flags.
1212
1213 methodHandle ClassFileParser::parse_method(constantPoolHandle cp, bool is_interface,
1214 AccessFlags *promoted_flags,
1215 typeArrayHandle* method_annotations,
1216 typeArrayHandle* method_parameter_annotations,
1217 typeArrayHandle* method_default_annotations,
1218 TRAPS) {
1219 ClassFileStream* cfs = stream();
1220 methodHandle nullHandle;
1221 ResourceMark rm(THREAD);
1222 // Parse fixed parts
1223 cfs->guarantee_more(8, CHECK_(nullHandle)); // access_flags, name_index, descriptor_index, attributes_count
1224
1225 int flags = cfs->get_u2_fast();
1845 methods_default_annotations());
1846
1847 // If JVMTI original method ordering is enabled construct int array remembering the original ordering
1848 if (JvmtiExport::can_maintain_original_method_order()) {
1849 typeArrayOop new_ordering = oopFactory::new_permanent_intArray(length, CHECK_(nullHandle));
1850 typeArrayHandle method_ordering(THREAD, new_ordering);
1851 for (int index = 0; index < length; index++) {
1852 methodOop m = methodOop(methods->obj_at(index));
1853 int old_index = m->vtable_index();
1854 assert(old_index >= 0 && old_index < length, "invalid method index");
1855 method_ordering->int_at_put(index, old_index);
1856 m->set_vtable_index(methodOopDesc::invalid_vtable_index);
1857 }
1858 return method_ordering;
1859 } else {
1860 return typeArrayHandle(THREAD, Universe::the_empty_int_array());
1861 }
1862 }
1863
1864
1865 void ClassFileParser::parse_classfile_sourcefile_attribute(constantPoolHandle cp, instanceKlassHandle k, TRAPS) {
1866 ClassFileStream* cfs = stream();
1867 cfs->guarantee_more(2, CHECK); // sourcefile_index
1868 u2 sourcefile_index = cfs->get_u2_fast();
1869 check_property(
1870 valid_cp_range(sourcefile_index, cp->length()) &&
1871 cp->tag_at(sourcefile_index).is_utf8(),
1872 "Invalid SourceFile attribute at constant pool index %u in class file %s",
1873 sourcefile_index, CHECK);
1874 k->set_source_file_name(cp->symbol_at(sourcefile_index));
1875 }
1876
1877
1878
1879 void ClassFileParser::parse_classfile_source_debug_extension_attribute(constantPoolHandle cp,
1880 instanceKlassHandle k,
1881 int length, TRAPS) {
1882 ClassFileStream* cfs = stream();
1883 u1* sde_buffer = cfs->get_u1_buffer();
1884 assert(sde_buffer != NULL, "null sde buffer");
1885
1886 // Don't bother storing it if there is no way to retrieve it
1887 if (JvmtiExport::can_get_source_debug_extension()) {
1888 // Optimistically assume that only 1 byte UTF format is used
1889 // (common case)
1890 symbolOop sde_symbol = oopFactory::new_symbol((char*)sde_buffer,
1891 length, CHECK);
1892 k->set_source_debug_extension(sde_symbol);
1893 }
1894 // Got utf8 string, set stream position forward
1895 cfs->skip_u1(length, CHECK);
1896 }
1897
1898
1899 // Inner classes can be static, private or protected (classic VM does this)
1900 #define RECOGNIZED_INNER_CLASS_MODIFIERS (JVM_RECOGNIZED_CLASS_MODIFIERS | JVM_ACC_PRIVATE | JVM_ACC_PROTECTED | JVM_ACC_STATIC)
1901
1902 // Return number of classes in the inner classes attribute table
1903 u2 ClassFileParser::parse_classfile_inner_classes_attribute(constantPoolHandle cp, instanceKlassHandle k, TRAPS) {
1904 ClassFileStream* cfs = stream();
1905 cfs->guarantee_more(2, CHECK_0); // length
1906 u2 length = cfs->get_u2_fast();
1907
1908 // 4-tuples of shorts [inner_class_info_index, outer_class_info_index, inner_name_index, inner_class_access_flags]
1909 typeArrayOop ic = oopFactory::new_permanent_shortArray(length*4, CHECK_0);
1910 typeArrayHandle inner_classes(THREAD, ic);
1911 int index = 0;
1912 int cp_size = cp->length();
1913 cfs->guarantee_more(8 * length, CHECK_0); // 4-tuples of u2
1914 for (int n = 0; n < length; n++) {
1915 // Inner class index
1916 u2 inner_class_info_index = cfs->get_u2_fast();
1917 check_property(
1918 inner_class_info_index == 0 ||
1919 (valid_cp_range(inner_class_info_index, cp_size) &&
1920 cp->tag_at(inner_class_info_index).is_klass_reference()),
1921 "inner_class_info_index %u has bad constant type in class file %s",
1922 inner_class_info_index, CHECK_0);
1923 // Outer class index
1953 inner_classes->short_at_put(index++, outer_class_info_index);
1954 inner_classes->short_at_put(index++, inner_name_index);
1955 inner_classes->short_at_put(index++, inner_access_flags.as_short());
1956 }
1957
1958 // 4347400: make sure there's no duplicate entry in the classes array
1959 if (_need_verify && _major_version >= JAVA_1_5_VERSION) {
1960 for(int i = 0; i < inner_classes->length(); i += 4) {
1961 for(int j = i + 4; j < inner_classes->length(); j += 4) {
1962 guarantee_property((inner_classes->ushort_at(i) != inner_classes->ushort_at(j) ||
1963 inner_classes->ushort_at(i+1) != inner_classes->ushort_at(j+1) ||
1964 inner_classes->ushort_at(i+2) != inner_classes->ushort_at(j+2) ||
1965 inner_classes->ushort_at(i+3) != inner_classes->ushort_at(j+3)),
1966 "Duplicate entry in InnerClasses in class file %s",
1967 CHECK_0);
1968 }
1969 }
1970 }
1971
1972 // Update instanceKlass with inner class info.
1973 k->set_inner_classes(inner_classes());
1974 return length;
1975 }
1976
1977 void ClassFileParser::parse_classfile_synthetic_attribute(constantPoolHandle cp, instanceKlassHandle k, TRAPS) {
1978 k->set_is_synthetic();
1979 }
1980
1981 void ClassFileParser::parse_classfile_signature_attribute(constantPoolHandle cp, instanceKlassHandle k, TRAPS) {
1982 ClassFileStream* cfs = stream();
1983 u2 signature_index = cfs->get_u2(CHECK);
1984 check_property(
1985 valid_cp_range(signature_index, cp->length()) &&
1986 cp->tag_at(signature_index).is_utf8(),
1987 "Invalid constant pool index %u in Signature attribute in class file %s",
1988 signature_index, CHECK);
1989 k->set_generic_signature(cp->symbol_at(signature_index));
1990 }
1991
1992 void ClassFileParser::parse_classfile_attributes(constantPoolHandle cp, instanceKlassHandle k, TRAPS) {
1993 ClassFileStream* cfs = stream();
1994 // Set inner classes attribute to default sentinel
1995 k->set_inner_classes(Universe::the_empty_short_array());
1996 cfs->guarantee_more(2, CHECK); // attributes_count
1997 u2 attributes_count = cfs->get_u2_fast();
1998 bool parsed_sourcefile_attribute = false;
1999 bool parsed_innerclasses_attribute = false;
2000 bool parsed_enclosingmethod_attribute = false;
2001 u1* runtime_visible_annotations = NULL;
2002 int runtime_visible_annotations_length = 0;
2003 u1* runtime_invisible_annotations = NULL;
2004 int runtime_invisible_annotations_length = 0;
2005 // Iterate over attributes
2006 while (attributes_count--) {
2007 cfs->guarantee_more(6, CHECK); // attribute_name_index, attribute_length
2008 u2 attribute_name_index = cfs->get_u2_fast();
2009 u4 attribute_length = cfs->get_u4_fast();
2010 check_property(
2011 valid_cp_range(attribute_name_index, cp->length()) &&
2012 cp->tag_at(attribute_name_index).is_utf8(),
2013 "Attribute name has bad constant pool index %u in class file %s",
2014 attribute_name_index, CHECK);
2015 symbolOop tag = cp->symbol_at(attribute_name_index);
2016 if (tag == vmSymbols::tag_source_file()) {
2017 // Check for SourceFile tag
2018 if (_need_verify) {
2019 guarantee_property(attribute_length == 2, "Wrong SourceFile attribute length in class file %s", CHECK);
2020 }
2021 if (parsed_sourcefile_attribute) {
2022 classfile_parse_error("Multiple SourceFile attributes in class file %s", CHECK);
2023 } else {
2024 parsed_sourcefile_attribute = true;
2025 }
2026 parse_classfile_sourcefile_attribute(cp, k, CHECK);
2027 } else if (tag == vmSymbols::tag_source_debug_extension()) {
2028 // Check for SourceDebugExtension tag
2029 parse_classfile_source_debug_extension_attribute(cp, k, (int)attribute_length, CHECK);
2030 } else if (tag == vmSymbols::tag_inner_classes()) {
2031 // Check for InnerClasses tag
2032 if (parsed_innerclasses_attribute) {
2033 classfile_parse_error("Multiple InnerClasses attributes in class file %s", CHECK);
2034 } else {
2035 parsed_innerclasses_attribute = true;
2036 }
2037 u2 num_of_classes = parse_classfile_inner_classes_attribute(cp, k, CHECK);
2038 if (_need_verify && _major_version >= JAVA_1_5_VERSION) {
2039 guarantee_property(attribute_length == sizeof(num_of_classes) + 4 * sizeof(u2) * num_of_classes,
2040 "Wrong InnerClasses attribute length in class file %s", CHECK);
2041 }
2042 } else if (tag == vmSymbols::tag_synthetic()) {
2043 // Check for Synthetic tag
2044 // Shouldn't we check that the synthetic flags wasn't already set? - not required in spec
2045 if (attribute_length != 0) {
2046 classfile_parse_error(
2047 "Invalid Synthetic classfile attribute length %u in class file %s",
2048 attribute_length, CHECK);
2049 }
2050 parse_classfile_synthetic_attribute(cp, k, CHECK);
2051 } else if (tag == vmSymbols::tag_deprecated()) {
2052 // Check for Deprecatd tag - 4276120
2053 if (attribute_length != 0) {
2054 classfile_parse_error(
2055 "Invalid Deprecated classfile attribute length %u in class file %s",
2056 attribute_length, CHECK);
2057 }
2058 } else if (_major_version >= JAVA_1_5_VERSION) {
2059 if (tag == vmSymbols::tag_signature()) {
2060 if (attribute_length != 2) {
2061 classfile_parse_error(
2062 "Wrong Signature attribute length %u in class file %s",
2063 attribute_length, CHECK);
2064 }
2065 parse_classfile_signature_attribute(cp, k, CHECK);
2066 } else if (tag == vmSymbols::tag_runtime_visible_annotations()) {
2067 runtime_visible_annotations_length = attribute_length;
2068 runtime_visible_annotations = cfs->get_u1_buffer();
2069 assert(runtime_visible_annotations != NULL, "null visible annotations");
2070 cfs->skip_u1(runtime_visible_annotations_length, CHECK);
2071 } else if (PreserveAllAnnotations && tag == vmSymbols::tag_runtime_invisible_annotations()) {
2072 runtime_invisible_annotations_length = attribute_length;
2073 runtime_invisible_annotations = cfs->get_u1_buffer();
2074 assert(runtime_invisible_annotations != NULL, "null invisible annotations");
2075 cfs->skip_u1(runtime_invisible_annotations_length, CHECK);
2076 } else if (tag == vmSymbols::tag_enclosing_method()) {
2077 if (parsed_enclosingmethod_attribute) {
2078 classfile_parse_error("Multiple EnclosingMethod attributes in class file %s", CHECK);
2079 } else {
2080 parsed_enclosingmethod_attribute = true;
2081 }
2082 cfs->guarantee_more(4, CHECK); // class_index, method_index
2083 u2 class_index = cfs->get_u2_fast();
2084 u2 method_index = cfs->get_u2_fast();
2085 if (class_index == 0) {
2086 classfile_parse_error("Invalid class index in EnclosingMethod attribute in class file %s", CHECK);
2087 }
2088 // Validate the constant pool indices and types
2089 if (!cp->is_within_bounds(class_index) ||
2090 !cp->tag_at(class_index).is_klass_reference()) {
2091 classfile_parse_error("Invalid or out-of-bounds class index in EnclosingMethod attribute in class file %s", CHECK);
2092 }
2093 if (method_index != 0 &&
2094 (!cp->is_within_bounds(method_index) ||
2095 !cp->tag_at(method_index).is_name_and_type())) {
2096 classfile_parse_error("Invalid or out-of-bounds method index in EnclosingMethod attribute in class file %s", CHECK);
2097 }
2098 k->set_enclosing_method_indices(class_index, method_index);
2099 } else {
2100 // Unknown attribute
2101 cfs->skip_u1(attribute_length, CHECK);
2102 }
2103 } else {
2104 // Unknown attribute
2105 cfs->skip_u1(attribute_length, CHECK);
2106 }
2107 }
2108 typeArrayHandle annotations = assemble_annotations(runtime_visible_annotations,
2109 runtime_visible_annotations_length,
2110 runtime_invisible_annotations,
2111 runtime_invisible_annotations_length,
2112 CHECK);
2113 k->set_class_annotations(annotations());
2114 }
2115
2116
2117 typeArrayHandle ClassFileParser::assemble_annotations(u1* runtime_visible_annotations,
2118 int runtime_visible_annotations_length,
2119 u1* runtime_invisible_annotations,
2120 int runtime_invisible_annotations_length, TRAPS) {
2121 typeArrayHandle annotations;
2122 if (runtime_visible_annotations != NULL ||
2123 runtime_invisible_annotations != NULL) {
2124 typeArrayOop anno = oopFactory::new_permanent_byteArray(runtime_visible_annotations_length +
2125 runtime_invisible_annotations_length, CHECK_(annotations));
2126 annotations = typeArrayHandle(THREAD, anno);
2127 if (runtime_visible_annotations != NULL) {
2128 memcpy(annotations->byte_at_addr(0), runtime_visible_annotations, runtime_visible_annotations_length);
2129 }
2130 if (runtime_invisible_annotations != NULL) {
2131 memcpy(annotations->byte_at_addr(runtime_visible_annotations_length), runtime_invisible_annotations, runtime_invisible_annotations_length);
2132 }
2133 }
2344 (*next_nonstatic_oop_offset_ptr) += (extra * heapOopSize);
2345 }
2346
2347
2348 instanceKlassHandle ClassFileParser::parseClassFile(symbolHandle name,
2349 Handle class_loader,
2350 Handle protection_domain,
2351 symbolHandle& parsed_name,
2352 TRAPS) {
2353 // So that JVMTI can cache class file in the state before retransformable agents
2354 // have modified it
2355 unsigned char *cached_class_file_bytes = NULL;
2356 jint cached_class_file_length;
2357
2358 ClassFileStream* cfs = stream();
2359 // Timing
2360 PerfTraceTime vmtimer(ClassLoader::perf_accumulated_time());
2361
2362 _has_finalizer = _has_empty_finalizer = _has_vanilla_constructor = false;
2363
2364 if (JvmtiExport::should_post_class_file_load_hook()) {
2365 unsigned char* ptr = cfs->buffer();
2366 unsigned char* end_ptr = cfs->buffer() + cfs->length();
2367
2368 JvmtiExport::post_class_file_load_hook(name, class_loader, protection_domain,
2369 &ptr, &end_ptr,
2370 &cached_class_file_bytes,
2371 &cached_class_file_length);
2372
2373 if (ptr != cfs->buffer()) {
2374 // JVMTI agent has modified class file data.
2375 // Set new class file stream using JVMTI agent modified
2376 // class file data.
2377 cfs = new ClassFileStream(ptr, end_ptr - ptr, cfs->source());
2378 set_stream(cfs);
2379 }
2380 }
2381
2382
2383 instanceKlassHandle nullHandle;
2538 bool has_final_method = false;
2539 AccessFlags promoted_flags;
2540 promoted_flags.set_flags(0);
2541 // These need to be oop pointers because they are allocated lazily
2542 // inside parse_methods inside a nested HandleMark
2543 objArrayOop methods_annotations_oop = NULL;
2544 objArrayOop methods_parameter_annotations_oop = NULL;
2545 objArrayOop methods_default_annotations_oop = NULL;
2546 objArrayHandle methods = parse_methods(cp, access_flags.is_interface(),
2547 &promoted_flags,
2548 &has_final_method,
2549 &methods_annotations_oop,
2550 &methods_parameter_annotations_oop,
2551 &methods_default_annotations_oop,
2552 CHECK_(nullHandle));
2553
2554 objArrayHandle methods_annotations(THREAD, methods_annotations_oop);
2555 objArrayHandle methods_parameter_annotations(THREAD, methods_parameter_annotations_oop);
2556 objArrayHandle methods_default_annotations(THREAD, methods_default_annotations_oop);
2557
2558 // We check super class after class file is parsed and format is checked
2559 if (super_class_index > 0) {
2560 symbolHandle sk (THREAD, cp->klass_name_at(super_class_index));
2561 if (access_flags.is_interface()) {
2562 // Before attempting to resolve the superclass, check for class format
2563 // errors not checked yet.
2564 guarantee_property(sk() == vmSymbols::java_lang_Object(),
2565 "Interfaces must have java.lang.Object as superclass in class file %s",
2566 CHECK_(nullHandle));
2567 }
2568 klassOop k = SystemDictionary::resolve_super_or_fail(class_name,
2569 sk,
2570 class_loader,
2571 protection_domain,
2572 true,
2573 CHECK_(nullHandle));
2574 KlassHandle kh (THREAD, k);
2575 super_klass = instanceKlassHandle(THREAD, kh());
2576 if (super_klass->is_interface()) {
2577 ResourceMark rm(THREAD);
3017 this_klass->set_methods_default_annotations(methods_default_annotations());
3018
3019 this_klass->set_minor_version(minor_version);
3020 this_klass->set_major_version(major_version);
3021
3022 if (cached_class_file_bytes != NULL) {
3023 // JVMTI: we have an instanceKlass now, tell it about the cached bytes
3024 this_klass->set_cached_class_file(cached_class_file_bytes,
3025 cached_class_file_length);
3026 }
3027
3028 // Miranda methods
3029 if ((num_miranda_methods > 0) ||
3030 // if this class introduced new miranda methods or
3031 (super_klass.not_null() && (super_klass->has_miranda_methods()))
3032 // super class exists and this class inherited miranda methods
3033 ) {
3034 this_klass->set_has_miranda_methods(); // then set a flag
3035 }
3036
3037 // Additional attributes
3038 parse_classfile_attributes(cp, this_klass, CHECK_(nullHandle));
3039
3040 // Make sure this is the end of class file stream
3041 guarantee_property(cfs->at_eos(), "Extra bytes at the end of class file %s", CHECK_(nullHandle));
3042
3043 // Initialize static fields
3044 this_klass->do_local_static_fields(&initialize_static_field, CHECK_(nullHandle));
3045
3046 // VerifyOops believes that once this has been set, the object is completely loaded.
3047 // Compute transitive closure of interfaces this class implements
3048 this_klass->set_transitive_interfaces(transitive_interfaces());
3049
3050 // Fill in information needed to compute superclasses.
3051 this_klass->initialize_supers(super_klass(), CHECK_(nullHandle));
3052
3053 // Initialize itable offset tables
3054 klassItable::setup_itable_offset_table(this_klass);
3055
3056 // Do final class setup
3057 fill_oop_maps(this_klass, nonstatic_oop_map_count, nonstatic_oop_offsets, nonstatic_oop_length);
3058
3059 set_precomputed_flags(this_klass);
3060
3061 // reinitialize modifiers, using the InnerClasses attribute
3062 int computed_modifiers = this_klass->compute_modifier_flags(CHECK_(nullHandle));
|
192 classfile_parse_error(
193 "Unknown constant tag %u in class file %s", tag, CHECK);
194 break;
195 }
196 }
197
198 // Allocate the remaining symbols
199 if (names_count > 0) {
200 oopFactory::new_symbols(cp, names_count, names, lengths, indices, hashValues, CHECK);
201 }
202
203 // Copy _current pointer of local copy back to stream().
204 #ifdef ASSERT
205 assert(cfs0->current() == old_current, "non-exclusive use of stream()");
206 #endif
207 cfs0->set_current(cfs1.current());
208 }
209
210 bool inline valid_cp_range(int index, int length) { return (index > 0 && index < length); }
211
212 inline symbolOop check_symbol_at(constantPoolHandle cp, int index) {
213 if (valid_cp_range(index, cp->length()) && cp->tag_at(index).is_utf8())
214 return cp->symbol_at(index);
215 else
216 return NULL;
217 }
218
219 constantPoolHandle ClassFileParser::parse_constant_pool(TRAPS) {
220 ClassFileStream* cfs = stream();
221 constantPoolHandle nullHandle;
222
223 cfs->guarantee_more(3, CHECK_(nullHandle)); // length, first cp tag
224 u2 length = cfs->get_u2_fast();
225 guarantee_property(
226 length >= 1, "Illegal constant pool size %u in class file %s",
227 length, CHECK_(nullHandle));
228 constantPoolOop constant_pool =
229 oopFactory::new_constantPool(length, CHECK_(nullHandle));
230 constantPoolHandle cp (THREAD, constant_pool);
231
232 cp->set_partially_loaded(); // Enables heap verify to work on partial constantPoolOops
233
234 // parsing constant pool entries
235 parse_constant_pool_entries(cp, length, CHECK_(nullHandle));
236
237 int index = 1; // declared outside of loops for portability
238
1186 u2 len = *checked_exceptions_length;
1187 cfs->guarantee_more(2 * len, CHECK_NULL);
1188 for (int i = 0; i < len; i++) {
1189 checked_exception = cfs->get_u2_fast();
1190 check_property(
1191 valid_cp_range(checked_exception, cp->length()) &&
1192 cp->tag_at(checked_exception).is_klass_reference(),
1193 "Exception name has bad type at constant pool %u in class file %s",
1194 checked_exception, CHECK_NULL);
1195 }
1196 }
1197 // check exceptions attribute length
1198 if (_need_verify) {
1199 guarantee_property(method_attribute_length == (sizeof(*checked_exceptions_length) +
1200 sizeof(u2) * size),
1201 "Exceptions attribute has wrong length in class file %s", CHECK_NULL);
1202 }
1203 return checked_exceptions_start;
1204 }
1205
1206 // Skip an annotation. Return >=limit if there is any problem.
1207 int ClassFileParser::skip_annotation(u1* buffer, int limit, int index) {
1208 // annotation := atype:u2 do(nmem:u2) {member:u2 value}
1209 // value := switch (tag:u1) { ... }
1210 index += 2; // skip atype
1211 if ((index += 2) >= limit) return limit; // read nmem
1212 int nmem = Bytes::get_Java_u2(buffer+index-2);
1213 while (--nmem >= 0 && index < limit) {
1214 index += 2; // skip member
1215 index = skip_annotation_value(buffer, limit, index);
1216 }
1217 return index;
1218 }
1219
1220 // Skip an annotation value. Return >=limit if there is any problem.
1221 int ClassFileParser::skip_annotation_value(u1* buffer, int limit, int index) {
1222 // value := switch (tag:u1) {
1223 // case B, C, I, S, Z, D, F, J, c: con:u2;
1224 // case e: e_class:u2 e_name:u2;
1225 // case s: s_con:u2;
1226 // case [: do(nval:u2) {value};
1227 // case @: annotation;
1228 // case s: s_con:u2;
1229 // }
1230 if ((index += 1) >= limit) return limit; // read tag
1231 u1 tag = buffer[index-1];
1232 switch (tag) {
1233 case 'B': case 'C': case 'I': case 'S': case 'Z':
1234 case 'D': case 'F': case 'J': case 'c': case 's':
1235 index += 2; // skip con or s_con
1236 break;
1237 case 'e':
1238 index += 4; // skip e_class, e_name
1239 break;
1240 case '[':
1241 {
1242 if ((index += 2) >= limit) return limit; // read nval
1243 int nval = Bytes::get_Java_u2(buffer+index-2);
1244 while (--nval >= 0 && index < limit) {
1245 index = skip_annotation_value(buffer, limit, index);
1246 }
1247 }
1248 break;
1249 case '@':
1250 index = skip_annotation(buffer, limit, index);
1251 break;
1252 default:
1253 assert(false, "annotation tag");
1254 return limit; // bad tag byte
1255 }
1256 return index;
1257 }
1258
1259 // Sift through annotations, looking for those significant to the VM:
1260 void ClassFileParser::parse_class_annotations(u1* buffer, int limit,
1261 constantPoolHandle cp,
1262 symbolHandle* retention_policy,
1263 TRAPS) {
1264 // annotations := do(nann:u2) {annotation}
1265 int index = 0;
1266 if ((index += 2) >= limit) return; // read nann
1267 int nann = Bytes::get_Java_u2(buffer+index-2);
1268 enum { // initial annotation layout
1269 atype_off = 0, // utf8 such as 'Ljava/lang/annotation/Retention;'
1270 count_off = 2, // u2 such as 1 (one value)
1271 member_off = 4, // utf8 such as 'value'
1272 tag_off = 6, // u1 such as 'c' (type) or 'e' (enum)
1273 e_tag_val = 'e',
1274 e_type_off = 7, // utf8 such as 'Ljava/lang/annotation/RetentionPolicy;'
1275 e_con_off = 9, // utf8 payload, such as 'SOURCE', 'CLASS', 'RUNTIME'
1276 e_size = 11, // end of 'e' annotation
1277 c_tag_val = 'c',
1278 c_con_off = 7, // utf8 payload, such as 'I' or 'Ljava/lang/String;'
1279 c_size = 9, // end of 'c' annotation
1280 min_size = 6 // smallest possible size (zero members)
1281 };
1282 while (--nann >= 0 && index + min_size <= limit) {
1283 int index0 = index;
1284 index = skip_annotation(buffer, limit, index);
1285 u1* abase = buffer + index0;
1286 int atype = Bytes::get_Java_u2(abase + atype_off);
1287 int count = Bytes::get_Java_u2(abase + count_off);
1288 symbolOop aname = check_symbol_at(cp, atype);
1289 if (aname == NULL) break; // invalid annotation name
1290 symbolOop member = NULL;
1291 if (count >= 1) {
1292 int member_index = Bytes::get_Java_u2(abase + member_off);
1293 member = check_symbol_at(cp, member_index);
1294 if (member == NULL) break; // invalid member name
1295 }
1296
1297 // The parsing of @Retention is for example only.
1298 #define Retention_signature classloader_signature // just for illustration
1299 #define RetentionPolicy_signature thread_signature
1300 if (aname == vmSymbols::Retention_signature()) {
1301 symbolOop payload = NULL;
1302 if (count == 1
1303 && e_size == (index0 - index) // match size
1304 && e_tag_val == *(abase + tag_off)
1305 && (check_symbol_at(cp, Bytes::get_Java_u2(abase + e_type_off))
1306 == vmSymbols::RetentionPolicy_signature())
1307 && member == vmSymbols::value_name()) {
1308 payload = check_symbol_at(cp, Bytes::get_Java_u2(abase + e_con_off));
1309 }
1310 check_property(payload != NULL,
1311 "Invalid @Retention annotation at offset %u in class file %s",
1312 index0, CHECK);
1313 (*retention_policy) = payload; // return the payload
1314 }
1315 }
1316 #undef Retention_signature
1317 #undef RetentionPolicy_signature
1318 }
1319
1320
1321 #define MAX_ARGS_SIZE 255
1322 #define MAX_CODE_SIZE 65535
1323 #define INITIAL_MAX_LVT_NUMBER 256
1324
1325 // Note: the parse_method below is big and clunky because all parsing of the code and exceptions
1326 // attribute is inlined. This is cumbersome to avoid since we inline most of the parts in the
1327 // methodOop to save footprint, so we only know the size of the resulting methodOop when the
1328 // entire method attribute is parsed.
1329 //
1330 // The promoted_flags parameter is used to pass relevant access_flags
1331 // from the method back up to the containing klass. These flag values
1332 // are added to klass's access_flags.
1333
1334 methodHandle ClassFileParser::parse_method(constantPoolHandle cp, bool is_interface,
1335 AccessFlags *promoted_flags,
1336 typeArrayHandle* method_annotations,
1337 typeArrayHandle* method_parameter_annotations,
1338 typeArrayHandle* method_default_annotations,
1339 TRAPS) {
1340 ClassFileStream* cfs = stream();
1341 methodHandle nullHandle;
1342 ResourceMark rm(THREAD);
1343 // Parse fixed parts
1344 cfs->guarantee_more(8, CHECK_(nullHandle)); // access_flags, name_index, descriptor_index, attributes_count
1345
1346 int flags = cfs->get_u2_fast();
1966 methods_default_annotations());
1967
1968 // If JVMTI original method ordering is enabled construct int array remembering the original ordering
1969 if (JvmtiExport::can_maintain_original_method_order()) {
1970 typeArrayOop new_ordering = oopFactory::new_permanent_intArray(length, CHECK_(nullHandle));
1971 typeArrayHandle method_ordering(THREAD, new_ordering);
1972 for (int index = 0; index < length; index++) {
1973 methodOop m = methodOop(methods->obj_at(index));
1974 int old_index = m->vtable_index();
1975 assert(old_index >= 0 && old_index < length, "invalid method index");
1976 method_ordering->int_at_put(index, old_index);
1977 m->set_vtable_index(methodOopDesc::invalid_vtable_index);
1978 }
1979 return method_ordering;
1980 } else {
1981 return typeArrayHandle(THREAD, Universe::the_empty_int_array());
1982 }
1983 }
1984
1985
1986 void ClassFileParser::parse_classfile_sourcefile_attribute(constantPoolHandle cp, symbolHandle* sourcefile_ret, TRAPS) {
1987 ClassFileStream* cfs = stream();
1988 cfs->guarantee_more(2, CHECK); // sourcefile_index
1989 u2 sourcefile_index = cfs->get_u2_fast();
1990 check_property(
1991 valid_cp_range(sourcefile_index, cp->length()) &&
1992 cp->tag_at(sourcefile_index).is_utf8(),
1993 "Invalid SourceFile attribute at constant pool index %u in class file %s",
1994 sourcefile_index, CHECK);
1995 (*sourcefile_ret) = cp->symbol_at(sourcefile_index);
1996 }
1997
1998
1999
2000 void ClassFileParser::parse_classfile_source_debug_extension_attribute(constantPoolHandle cp,
2001 int length,
2002 symbolHandle* sde_symbol_ret,
2003 TRAPS) {
2004 ClassFileStream* cfs = stream();
2005 u1* sde_buffer = cfs->get_u1_buffer();
2006 assert(sde_buffer != NULL, "null sde buffer");
2007
2008 // Don't bother storing it if there is no way to retrieve it
2009 if (JvmtiExport::can_get_source_debug_extension()) {
2010 // Optimistically assume that only 1 byte UTF format is used
2011 // (common case)
2012 symbolOop sde_symbol = oopFactory::new_symbol((char*)sde_buffer,
2013 length, CHECK);
2014 (*sde_symbol_ret) = symbolHandle(THREAD, sde_symbol);
2015 }
2016 // Got utf8 string, set stream position forward
2017 cfs->skip_u1(length, CHECK);
2018 }
2019
2020
2021 // Inner classes can be static, private or protected (classic VM does this)
2022 #define RECOGNIZED_INNER_CLASS_MODIFIERS (JVM_RECOGNIZED_CLASS_MODIFIERS | JVM_ACC_PRIVATE | JVM_ACC_PROTECTED | JVM_ACC_STATIC)
2023
2024 // Return number of classes in the inner classes attribute table
2025 u2 ClassFileParser::parse_classfile_inner_classes_attribute(constantPoolHandle cp, typeArrayHandle* inner_classes_ret, TRAPS) {
2026 ClassFileStream* cfs = stream();
2027 cfs->guarantee_more(2, CHECK_0); // length
2028 u2 length = cfs->get_u2_fast();
2029
2030 // 4-tuples of shorts [inner_class_info_index, outer_class_info_index, inner_name_index, inner_class_access_flags]
2031 typeArrayOop ic = oopFactory::new_permanent_shortArray(length*4, CHECK_0);
2032 typeArrayHandle inner_classes(THREAD, ic);
2033 int index = 0;
2034 int cp_size = cp->length();
2035 cfs->guarantee_more(8 * length, CHECK_0); // 4-tuples of u2
2036 for (int n = 0; n < length; n++) {
2037 // Inner class index
2038 u2 inner_class_info_index = cfs->get_u2_fast();
2039 check_property(
2040 inner_class_info_index == 0 ||
2041 (valid_cp_range(inner_class_info_index, cp_size) &&
2042 cp->tag_at(inner_class_info_index).is_klass_reference()),
2043 "inner_class_info_index %u has bad constant type in class file %s",
2044 inner_class_info_index, CHECK_0);
2045 // Outer class index
2075 inner_classes->short_at_put(index++, outer_class_info_index);
2076 inner_classes->short_at_put(index++, inner_name_index);
2077 inner_classes->short_at_put(index++, inner_access_flags.as_short());
2078 }
2079
2080 // 4347400: make sure there's no duplicate entry in the classes array
2081 if (_need_verify && _major_version >= JAVA_1_5_VERSION) {
2082 for(int i = 0; i < inner_classes->length(); i += 4) {
2083 for(int j = i + 4; j < inner_classes->length(); j += 4) {
2084 guarantee_property((inner_classes->ushort_at(i) != inner_classes->ushort_at(j) ||
2085 inner_classes->ushort_at(i+1) != inner_classes->ushort_at(j+1) ||
2086 inner_classes->ushort_at(i+2) != inner_classes->ushort_at(j+2) ||
2087 inner_classes->ushort_at(i+3) != inner_classes->ushort_at(j+3)),
2088 "Duplicate entry in InnerClasses in class file %s",
2089 CHECK_0);
2090 }
2091 }
2092 }
2093
2094 // Update instanceKlass with inner class info.
2095 (*inner_classes_ret) = inner_classes;
2096 return length;
2097 }
2098
2099 void ClassFileParser::parse_classfile_synthetic_attribute(constantPoolHandle cp, bool* synthetic_flag_ret, TRAPS) {
2100 (*synthetic_flag_ret) = true;
2101 }
2102
2103 void ClassFileParser::parse_classfile_signature_attribute(constantPoolHandle cp, symbolHandle* signature_ret, TRAPS) {
2104 ClassFileStream* cfs = stream();
2105 u2 signature_index = cfs->get_u2(CHECK);
2106 check_property(
2107 valid_cp_range(signature_index, cp->length()) &&
2108 cp->tag_at(signature_index).is_utf8(),
2109 "Invalid constant pool index %u in Signature attribute in class file %s",
2110 signature_index, CHECK);
2111 (*signature_ret) = cp->symbol_at(signature_index);
2112 }
2113
2114 void ClassFileParser::parse_classfile_attributes(constantPoolHandle cp, TRAPS) {
2115 ClassFileStream* cfs = stream();
2116 // Set inner classes attribute to default sentinel
2117 _inner_classes = typeArrayHandle(THREAD, Universe::the_empty_short_array());
2118 cfs->guarantee_more(2, CHECK); // attributes_count
2119 u2 attributes_count = cfs->get_u2_fast();
2120 bool parsed_sourcefile_attribute = false;
2121 bool parsed_innerclasses_attribute = false;
2122 bool parsed_enclosingmethod_attribute = false;
2123 u1* runtime_visible_annotations = NULL;
2124 int runtime_visible_annotations_length = 0;
2125 u1* runtime_invisible_annotations = NULL;
2126 int runtime_invisible_annotations_length = 0;
2127 // Iterate over attributes
2128 while (attributes_count--) {
2129 cfs->guarantee_more(6, CHECK); // attribute_name_index, attribute_length
2130 u2 attribute_name_index = cfs->get_u2_fast();
2131 u4 attribute_length = cfs->get_u4_fast();
2132 check_property(
2133 valid_cp_range(attribute_name_index, cp->length()) &&
2134 cp->tag_at(attribute_name_index).is_utf8(),
2135 "Attribute name has bad constant pool index %u in class file %s",
2136 attribute_name_index, CHECK);
2137 symbolOop tag = cp->symbol_at(attribute_name_index);
2138 if (tag == vmSymbols::tag_source_file()) {
2139 // Check for SourceFile tag
2140 if (_need_verify) {
2141 guarantee_property(attribute_length == 2, "Wrong SourceFile attribute length in class file %s", CHECK);
2142 }
2143 if (parsed_sourcefile_attribute) {
2144 classfile_parse_error("Multiple SourceFile attributes in class file %s", CHECK);
2145 } else {
2146 parsed_sourcefile_attribute = true;
2147 }
2148 parse_classfile_sourcefile_attribute(cp, &_sourcefile, CHECK);
2149 } else if (tag == vmSymbols::tag_source_debug_extension()) {
2150 // Check for SourceDebugExtension tag
2151 parse_classfile_source_debug_extension_attribute(cp, (int)attribute_length, &_sde_symbol, CHECK);
2152 } else if (tag == vmSymbols::tag_inner_classes()) {
2153 // Check for InnerClasses tag
2154 if (parsed_innerclasses_attribute) {
2155 classfile_parse_error("Multiple InnerClasses attributes in class file %s", CHECK);
2156 } else {
2157 parsed_innerclasses_attribute = true;
2158 }
2159 u2 num_of_classes = parse_classfile_inner_classes_attribute(cp, &_inner_classes, CHECK);
2160 if (_need_verify && _major_version >= JAVA_1_5_VERSION) {
2161 guarantee_property(attribute_length == sizeof(num_of_classes) + 4 * sizeof(u2) * num_of_classes,
2162 "Wrong InnerClasses attribute length in class file %s", CHECK);
2163 }
2164 } else if (tag == vmSymbols::tag_synthetic()) {
2165 // Check for Synthetic tag
2166 // Shouldn't we check that the synthetic flags wasn't already set? - not required in spec
2167 if (attribute_length != 0) {
2168 classfile_parse_error(
2169 "Invalid Synthetic classfile attribute length %u in class file %s",
2170 attribute_length, CHECK);
2171 }
2172 parse_classfile_synthetic_attribute(cp, &_synthetic_flag, CHECK);
2173 } else if (tag == vmSymbols::tag_deprecated()) {
2174 // Check for Deprecatd tag - 4276120
2175 if (attribute_length != 0) {
2176 classfile_parse_error(
2177 "Invalid Deprecated classfile attribute length %u in class file %s",
2178 attribute_length, CHECK);
2179 }
2180 } else if (_major_version >= JAVA_1_5_VERSION) {
2181 if (tag == vmSymbols::tag_signature()) {
2182 if (attribute_length != 2) {
2183 classfile_parse_error(
2184 "Wrong Signature attribute length %u in class file %s",
2185 attribute_length, CHECK);
2186 }
2187 parse_classfile_signature_attribute(cp, &_generic_signature, CHECK);
2188 } else if (tag == vmSymbols::tag_runtime_visible_annotations()) {
2189 runtime_visible_annotations_length = attribute_length;
2190 runtime_visible_annotations = cfs->get_u1_buffer();
2191 assert(runtime_visible_annotations != NULL, "null visible annotations");
2192 parse_class_annotations(runtime_visible_annotations,
2193 runtime_visible_annotations_length,
2194 cp,
2195 &_retention_policy,
2196 CHECK);
2197 cfs->skip_u1(runtime_visible_annotations_length, CHECK);
2198 } else if (PreserveAllAnnotations && tag == vmSymbols::tag_runtime_invisible_annotations()) {
2199 runtime_invisible_annotations_length = attribute_length;
2200 runtime_invisible_annotations = cfs->get_u1_buffer();
2201 assert(runtime_invisible_annotations != NULL, "null invisible annotations");
2202 cfs->skip_u1(runtime_invisible_annotations_length, CHECK);
2203 } else if (tag == vmSymbols::tag_enclosing_method()) {
2204 if (parsed_enclosingmethod_attribute) {
2205 classfile_parse_error("Multiple EnclosingMethod attributes in class file %s", CHECK);
2206 } else {
2207 parsed_enclosingmethod_attribute = true;
2208 }
2209 cfs->guarantee_more(4, CHECK); // class_index, method_index
2210 u2 class_index = cfs->get_u2_fast();
2211 u2 method_index = cfs->get_u2_fast();
2212 if (class_index == 0) {
2213 classfile_parse_error("Invalid class index in EnclosingMethod attribute in class file %s", CHECK);
2214 }
2215 // Validate the constant pool indices and types
2216 if (!cp->is_within_bounds(class_index) ||
2217 !cp->tag_at(class_index).is_klass_reference()) {
2218 classfile_parse_error("Invalid or out-of-bounds class index in EnclosingMethod attribute in class file %s", CHECK);
2219 }
2220 if (method_index != 0 &&
2221 (!cp->is_within_bounds(method_index) ||
2222 !cp->tag_at(method_index).is_name_and_type())) {
2223 classfile_parse_error("Invalid or out-of-bounds method index in EnclosingMethod attribute in class file %s", CHECK);
2224 }
2225 _em_class_index = class_index;
2226 _em_method_index = method_index;
2227 } else {
2228 // Unknown attribute
2229 cfs->skip_u1(attribute_length, CHECK);
2230 }
2231 } else {
2232 // Unknown attribute
2233 cfs->skip_u1(attribute_length, CHECK);
2234 }
2235 }
2236 typeArrayHandle annotations = assemble_annotations(runtime_visible_annotations,
2237 runtime_visible_annotations_length,
2238 runtime_invisible_annotations,
2239 runtime_invisible_annotations_length,
2240 CHECK);
2241 _annotations = annotations;
2242 }
2243
2244
2245 typeArrayHandle ClassFileParser::assemble_annotations(u1* runtime_visible_annotations,
2246 int runtime_visible_annotations_length,
2247 u1* runtime_invisible_annotations,
2248 int runtime_invisible_annotations_length, TRAPS) {
2249 typeArrayHandle annotations;
2250 if (runtime_visible_annotations != NULL ||
2251 runtime_invisible_annotations != NULL) {
2252 typeArrayOop anno = oopFactory::new_permanent_byteArray(runtime_visible_annotations_length +
2253 runtime_invisible_annotations_length, CHECK_(annotations));
2254 annotations = typeArrayHandle(THREAD, anno);
2255 if (runtime_visible_annotations != NULL) {
2256 memcpy(annotations->byte_at_addr(0), runtime_visible_annotations, runtime_visible_annotations_length);
2257 }
2258 if (runtime_invisible_annotations != NULL) {
2259 memcpy(annotations->byte_at_addr(runtime_visible_annotations_length), runtime_invisible_annotations, runtime_invisible_annotations_length);
2260 }
2261 }
2472 (*next_nonstatic_oop_offset_ptr) += (extra * heapOopSize);
2473 }
2474
2475
2476 instanceKlassHandle ClassFileParser::parseClassFile(symbolHandle name,
2477 Handle class_loader,
2478 Handle protection_domain,
2479 symbolHandle& parsed_name,
2480 TRAPS) {
2481 // So that JVMTI can cache class file in the state before retransformable agents
2482 // have modified it
2483 unsigned char *cached_class_file_bytes = NULL;
2484 jint cached_class_file_length;
2485
2486 ClassFileStream* cfs = stream();
2487 // Timing
2488 PerfTraceTime vmtimer(ClassLoader::perf_accumulated_time());
2489
2490 _has_finalizer = _has_empty_finalizer = _has_vanilla_constructor = false;
2491
2492 _em_class_index = _em_method_index = 0;
2493 _synthetic_flag = false;
2494
2495 if (JvmtiExport::should_post_class_file_load_hook()) {
2496 unsigned char* ptr = cfs->buffer();
2497 unsigned char* end_ptr = cfs->buffer() + cfs->length();
2498
2499 JvmtiExport::post_class_file_load_hook(name, class_loader, protection_domain,
2500 &ptr, &end_ptr,
2501 &cached_class_file_bytes,
2502 &cached_class_file_length);
2503
2504 if (ptr != cfs->buffer()) {
2505 // JVMTI agent has modified class file data.
2506 // Set new class file stream using JVMTI agent modified
2507 // class file data.
2508 cfs = new ClassFileStream(ptr, end_ptr - ptr, cfs->source());
2509 set_stream(cfs);
2510 }
2511 }
2512
2513
2514 instanceKlassHandle nullHandle;
2669 bool has_final_method = false;
2670 AccessFlags promoted_flags;
2671 promoted_flags.set_flags(0);
2672 // These need to be oop pointers because they are allocated lazily
2673 // inside parse_methods inside a nested HandleMark
2674 objArrayOop methods_annotations_oop = NULL;
2675 objArrayOop methods_parameter_annotations_oop = NULL;
2676 objArrayOop methods_default_annotations_oop = NULL;
2677 objArrayHandle methods = parse_methods(cp, access_flags.is_interface(),
2678 &promoted_flags,
2679 &has_final_method,
2680 &methods_annotations_oop,
2681 &methods_parameter_annotations_oop,
2682 &methods_default_annotations_oop,
2683 CHECK_(nullHandle));
2684
2685 objArrayHandle methods_annotations(THREAD, methods_annotations_oop);
2686 objArrayHandle methods_parameter_annotations(THREAD, methods_parameter_annotations_oop);
2687 objArrayHandle methods_default_annotations(THREAD, methods_default_annotations_oop);
2688
2689 // Additional attributes
2690 parse_classfile_attributes(cp, CHECK_(nullHandle));
2691
2692 // Make sure this is the end of class file stream
2693 guarantee_property(cfs->at_eos(), "Extra bytes at the end of class file %s", CHECK_(nullHandle));
2694
2695 // We check super class after class file is parsed and format is checked
2696 if (super_class_index > 0) {
2697 symbolHandle sk (THREAD, cp->klass_name_at(super_class_index));
2698 if (access_flags.is_interface()) {
2699 // Before attempting to resolve the superclass, check for class format
2700 // errors not checked yet.
2701 guarantee_property(sk() == vmSymbols::java_lang_Object(),
2702 "Interfaces must have java.lang.Object as superclass in class file %s",
2703 CHECK_(nullHandle));
2704 }
2705 klassOop k = SystemDictionary::resolve_super_or_fail(class_name,
2706 sk,
2707 class_loader,
2708 protection_domain,
2709 true,
2710 CHECK_(nullHandle));
2711 KlassHandle kh (THREAD, k);
2712 super_klass = instanceKlassHandle(THREAD, kh());
2713 if (super_klass->is_interface()) {
2714 ResourceMark rm(THREAD);
3154 this_klass->set_methods_default_annotations(methods_default_annotations());
3155
3156 this_klass->set_minor_version(minor_version);
3157 this_klass->set_major_version(major_version);
3158
3159 if (cached_class_file_bytes != NULL) {
3160 // JVMTI: we have an instanceKlass now, tell it about the cached bytes
3161 this_klass->set_cached_class_file(cached_class_file_bytes,
3162 cached_class_file_length);
3163 }
3164
3165 // Miranda methods
3166 if ((num_miranda_methods > 0) ||
3167 // if this class introduced new miranda methods or
3168 (super_klass.not_null() && (super_klass->has_miranda_methods()))
3169 // super class exists and this class inherited miranda methods
3170 ) {
3171 this_klass->set_has_miranda_methods(); // then set a flag
3172 }
3173
3174 // Fill in field values from parse_classfile_attributes:
3175 this_klass->set_inner_classes(_inner_classes());
3176 this_klass->set_enclosing_method_indices(_em_class_index, _em_method_index);
3177 this_klass->set_source_file_name(_sourcefile());
3178 this_klass->set_source_debug_extension(_sde_symbol());
3179 this_klass->set_generic_signature(_generic_signature());
3180 if (_synthetic_flag) this_klass->set_is_synthetic();
3181 this_klass->set_class_annotations(_annotations());
3182
3183 // Initialize static fields
3184 this_klass->do_local_static_fields(&initialize_static_field, CHECK_(nullHandle));
3185
3186 // VerifyOops believes that once this has been set, the object is completely loaded.
3187 // Compute transitive closure of interfaces this class implements
3188 this_klass->set_transitive_interfaces(transitive_interfaces());
3189
3190 // Fill in information needed to compute superclasses.
3191 this_klass->initialize_supers(super_klass(), CHECK_(nullHandle));
3192
3193 // Initialize itable offset tables
3194 klassItable::setup_itable_offset_table(this_klass);
3195
3196 // Do final class setup
3197 fill_oop_maps(this_klass, nonstatic_oop_map_count, nonstatic_oop_offsets, nonstatic_oop_length);
3198
3199 set_precomputed_flags(this_klass);
3200
3201 // reinitialize modifiers, using the InnerClasses attribute
3202 int computed_modifiers = this_klass->compute_modifier_flags(CHECK_(nullHandle));
|