src/share/vm/classfile/classFileParser.cpp

Print this page




2150       }
2151     } else if (method_attribute_name == vmSymbols::tag_exceptions()) {
2152       // Parse Exceptions attribute
2153       if (parsed_checked_exceptions_attribute) {
2154         classfile_parse_error("Multiple Exceptions attributes in class file %s", CHECK_(nullHandle));
2155       }
2156       parsed_checked_exceptions_attribute = true;
2157       checked_exceptions_start =
2158             parse_checked_exceptions(&checked_exceptions_length,
2159                                      method_attribute_length,
2160                                      cp, CHECK_(nullHandle));
2161     } else if (method_attribute_name == vmSymbols::tag_method_parameters()) {
2162       method_parameters_length = cfs->get_u1_fast();
2163       // Track the actual size (note: this is written for clarity; a
2164       // decent compiler will CSE and constant-fold this into a single
2165       // expression)
2166       u2 actual_size = 1;
2167       method_parameters_data = cfs->get_u1_buffer();
2168       actual_size += 2 * method_parameters_length;
2169       cfs->skip_u2_fast(method_parameters_length);
2170       actual_size += 4 * method_parameters_length;
2171       cfs->skip_u4_fast(method_parameters_length);
2172       // Enforce attribute length
2173       if (method_attribute_length != actual_size) {
2174         classfile_parse_error(
2175           "Invalid MethodParameters method attribute length %u in class file %s",
2176           method_attribute_length, CHECK_(nullHandle));
2177       }
2178       // ignore this attribute if it cannot be reflected
2179       if (!SystemDictionary::Parameter_klass_loaded())
2180         method_parameters_length = 0;
2181     } else if (method_attribute_name == vmSymbols::tag_synthetic()) {
2182       if (method_attribute_length != 0) {
2183         classfile_parse_error(
2184           "Invalid Synthetic method attribute length %u in class file %s",
2185           method_attribute_length, CHECK_(nullHandle));
2186       }
2187       // Should we check that there hasn't already been a synthetic attribute?
2188       access_flags.set_is_synthetic();
2189     } else if (method_attribute_name == vmSymbols::tag_deprecated()) { // 4276120
2190       if (method_attribute_length != 0) {
2191         classfile_parse_error(


2302   m->set_code(code_start);
2303 
2304   // Copy line number table
2305   if (linenumber_table != NULL) {
2306     memcpy(m->compressed_linenumber_table(),
2307            linenumber_table->buffer(), linenumber_table_length);
2308   }
2309 
2310   // Copy exception table
2311   if (exception_table_length > 0) {
2312     int size =
2313       exception_table_length * sizeof(ExceptionTableElement) / sizeof(u2);
2314     copy_u2_with_conversion((u2*) m->exception_table_start(),
2315                              exception_table_start, size);
2316   }
2317 
2318   // Copy method parameters
2319   if (method_parameters_length > 0) {
2320     MethodParametersElement* elem = m->constMethod()->method_parameters_start();
2321     for(int i = 0; i < method_parameters_length; i++) {
2322       elem[i].name_cp_index =
2323         Bytes::get_Java_u2(method_parameters_data);

2324       method_parameters_data += 2;
2325       u4 flags = Bytes::get_Java_u4(method_parameters_data);
2326       // This caused an alignment fault on Sparc, if flags was a u4
2327       elem[i].flags_lo = extract_low_short_from_int(flags);
2328       elem[i].flags_hi = extract_high_short_from_int(flags);
2329       method_parameters_data += 4;
2330     }
2331   }
2332 
2333   // Copy checked exceptions
2334   if (checked_exceptions_length > 0) {
2335     int size = checked_exceptions_length * sizeof(CheckedExceptionElement) / sizeof(u2);
2336     copy_u2_with_conversion((u2*) m->checked_exceptions_start(), checked_exceptions_start, size);
2337   }
2338 
2339   /* Copy class file LVT's/LVTT's into the HotSpot internal LVT.
2340    *
2341    * Rules for LVT's and LVTT's are:
2342    *   - There can be any number of LVT's and LVTT's.
2343    *   - If there are n LVT's, it is the same as if there was just
2344    *     one LVT containing all the entries from the n LVT's.
2345    *   - There may be no more than one LVT entry per local variable.
2346    *     Two LVT entries are 'equal' if these fields are the same:
2347    *        start_pc, length, name, slot
2348    *   - There may be no more than one LVTT entry per each LVT entry.
2349    *     Each LVTT entry has to match some LVT entry.




2150       }
2151     } else if (method_attribute_name == vmSymbols::tag_exceptions()) {
2152       // Parse Exceptions attribute
2153       if (parsed_checked_exceptions_attribute) {
2154         classfile_parse_error("Multiple Exceptions attributes in class file %s", CHECK_(nullHandle));
2155       }
2156       parsed_checked_exceptions_attribute = true;
2157       checked_exceptions_start =
2158             parse_checked_exceptions(&checked_exceptions_length,
2159                                      method_attribute_length,
2160                                      cp, CHECK_(nullHandle));
2161     } else if (method_attribute_name == vmSymbols::tag_method_parameters()) {
2162       method_parameters_length = cfs->get_u1_fast();
2163       // Track the actual size (note: this is written for clarity; a
2164       // decent compiler will CSE and constant-fold this into a single
2165       // expression)
2166       u2 actual_size = 1;
2167       method_parameters_data = cfs->get_u1_buffer();
2168       actual_size += 2 * method_parameters_length;
2169       cfs->skip_u2_fast(method_parameters_length);
2170       actual_size += 2 * method_parameters_length;
2171       cfs->skip_u2_fast(method_parameters_length);
2172       // Enforce attribute length
2173       if (method_attribute_length != actual_size) {
2174         classfile_parse_error(
2175           "Invalid MethodParameters method attribute length %u in class file %s",
2176           method_attribute_length, CHECK_(nullHandle));
2177       }
2178       // ignore this attribute if it cannot be reflected
2179       if (!SystemDictionary::Parameter_klass_loaded())
2180         method_parameters_length = 0;
2181     } else if (method_attribute_name == vmSymbols::tag_synthetic()) {
2182       if (method_attribute_length != 0) {
2183         classfile_parse_error(
2184           "Invalid Synthetic method attribute length %u in class file %s",
2185           method_attribute_length, CHECK_(nullHandle));
2186       }
2187       // Should we check that there hasn't already been a synthetic attribute?
2188       access_flags.set_is_synthetic();
2189     } else if (method_attribute_name == vmSymbols::tag_deprecated()) { // 4276120
2190       if (method_attribute_length != 0) {
2191         classfile_parse_error(


2302   m->set_code(code_start);
2303 
2304   // Copy line number table
2305   if (linenumber_table != NULL) {
2306     memcpy(m->compressed_linenumber_table(),
2307            linenumber_table->buffer(), linenumber_table_length);
2308   }
2309 
2310   // Copy exception table
2311   if (exception_table_length > 0) {
2312     int size =
2313       exception_table_length * sizeof(ExceptionTableElement) / sizeof(u2);
2314     copy_u2_with_conversion((u2*) m->exception_table_start(),
2315                              exception_table_start, size);
2316   }
2317 
2318   // Copy method parameters
2319   if (method_parameters_length > 0) {
2320     MethodParametersElement* elem = m->constMethod()->method_parameters_start();
2321     for(int i = 0; i < method_parameters_length; i++) {
2322       elem[i].name_cp_index = Bytes::get_Java_u2(method_parameters_data);
2323       method_parameters_data += 2;
2324       elem[i].flags = Bytes::get_Java_u2(method_parameters_data);
2325       method_parameters_data += 2;





2326     }
2327   }
2328 
2329   // Copy checked exceptions
2330   if (checked_exceptions_length > 0) {
2331     int size = checked_exceptions_length * sizeof(CheckedExceptionElement) / sizeof(u2);
2332     copy_u2_with_conversion((u2*) m->checked_exceptions_start(), checked_exceptions_start, size);
2333   }
2334 
2335   /* Copy class file LVT's/LVTT's into the HotSpot internal LVT.
2336    *
2337    * Rules for LVT's and LVTT's are:
2338    *   - There can be any number of LVT's and LVTT's.
2339    *   - If there are n LVT's, it is the same as if there was just
2340    *     one LVT containing all the entries from the n LVT's.
2341    *   - There may be no more than one LVT entry per local variable.
2342    *     Two LVT entries are 'equal' if these fields are the same:
2343    *        start_pc, length, name, slot
2344    *   - There may be no more than one LVTT entry per each LVT entry.
2345    *     Each LVTT entry has to match some LVT entry.