@@ -3279,90 +3279,94 @@ void ClassFileParser::parse_classfile_bootstrap_methods_attribute(const ClassFil
32793279
32803280 cfs->guarantee_more (attribute_byte_length, CHECK);
32813281
3282- const int attribute_entry_count = cfs->get_u2_fast ();
3282+ const u2 num_bootstrap_methods = cfs->get_u2_fast ();
32833283
3284- guarantee_property (_max_bootstrap_specifier_index < attribute_entry_count ,
3284+ guarantee_property (_max_bootstrap_specifier_index < num_bootstrap_methods ,
32853285 " Short length on BootstrapMethods in class file %s" ,
32863286 CHECK);
32873287
32883288 // The attribute contains a counted array of counted tuples of shorts,
3289- // represending bootstrap specifiers:
3289+ // representing bootstrap specifiers:
32903290 // length*{bootstrap_method_index, argument_count, argument_count*{argument_index}}
3291- const unsigned int attribute_tail_length = attribute_byte_length - ( unsigned ) sizeof (u2);
3292-
3291+ const u4 attribute_tail_length = attribute_byte_length - static_cast <u4>( sizeof (u2) );
3292+ assert (attribute_tail_length % sizeof (u2) == 0 , " " );
32933293 Array<u4>* const offsets =
3294- MetadataFactory::new_array<u4>(_loader_data, attribute_entry_count , CHECK);
3294+ MetadataFactory::new_array<u4>(_loader_data, num_bootstrap_methods , CHECK);
32953295 Array<u2>* const entries = // u2 data holding all the BSM attribute entries
32963296 MetadataFactory::new_array<u2>(_loader_data, attribute_tail_length / sizeof (u2), CHECK);
32973297
3298- // Eagerly assign arrays so they will be deallocated with the constant
3299- // pool if there is an error.
3298+ // Eagerly assign arrays so they will be deallocated with
3299+ // the constant pool if there is an error.
33003300 cp->set_bsm_attribute_offsets (offsets);
33013301 cp->set_bsm_attribute_entries (entries);
33023302
33033303 int next_entry = 0 ;
33043304 const int cp_size = cp->length ();
33053305
3306- for (int n = 0 ; n < attribute_entry_count ; n++) {
3306+ for (int n = 0 ; n < num_bootstrap_methods ; n++) {
33073307 // Store a 32-bit offset into the array of BSM entry offsets.
33083308 offsets->at_put (n, next_entry);
33093309
33103310 // Read a bootstrap method attribute entry.
33113311 cfs->guarantee_more (sizeof (u2) * 2 , CHECK); // bsm, argc
3312- const u2 bootstrap_method_index = cfs->get_u2_fast ();
3313- const u2 argument_count = cfs->get_u2_fast ();
3312+ const u2 bootstrap_method_ref = cfs->get_u2_fast ();
3313+ const u2 num_bootstrap_arguments = cfs->get_u2_fast ();
33143314 guarantee_property (
3315- valid_cp_range (bootstrap_method_index , cp_size) &&
3316- cp->tag_at (bootstrap_method_index ).is_method_handle (),
3315+ valid_cp_range (bootstrap_method_ref , cp_size) &&
3316+ cp->tag_at (bootstrap_method_ref ).is_method_handle (),
33173317 " bootstrap_method_index %u has bad constant type in class file %s" ,
3318- bootstrap_method_index ,
3318+ bootstrap_method_ref ,
33193319 CHECK);
33203320
3321- guarantee_property ((next_entry + 2 + argument_count ) <= entries->length (),
3321+ guarantee_property ((next_entry + 2 + num_bootstrap_arguments ) <= entries->length (),
33223322 " Invalid BootstrapMethods num_bootstrap_methods or num_bootstrap_arguments value in class file %s" ,
33233323 CHECK);
33243324
3325- entries->at_put (next_entry++, bootstrap_method_index);
3326- entries->at_put (next_entry++, argument_count);
3325+ entries->at_put (next_entry, bootstrap_method_ref);
3326+ next_entry++;
3327+ entries->at_put (next_entry, num_bootstrap_arguments);
3328+ next_entry++;
33273329
3328- cfs->guarantee_more (sizeof (u2) * argument_count , CHECK); // argv[argc]
3329- for (int j = 0 ; j < argument_count ; j++) {
3330+ cfs->guarantee_more (sizeof (u2) * num_bootstrap_arguments , CHECK); // argv[argc]
3331+ for (u2 j = 0 ; j < num_bootstrap_arguments ; j++) {
33303332 const u2 argument_index = cfs->get_u2_fast ();
33313333 guarantee_property (
33323334 valid_cp_range (argument_index, cp_size) &&
33333335 cp->tag_at (argument_index).is_loadable_constant (),
33343336 " argument_index %u has bad constant type in class file %s" ,
33353337 argument_index,
33363338 CHECK);
3337- entries->at_put (next_entry++, argument_index);
3339+ entries->at_put (next_entry, argument_index);
3340+ next_entry++;
33383341 }
33393342 }
33403343 guarantee_property (current_start + attribute_byte_length == cfs->current (),
33413344 " Bad length on BootstrapMethods in class file %s" ,
33423345 CHECK);
33433346 assert (next_entry == entries->length (), " " );
33443347
3345- // check access methods, for extra luck
3346- if (attribute_entry_count > 0 ) {
3347- auto bsme = cp->bsm_attribute_entry (0 );
3348+ # ifdef ASSERT
3349+ if (num_bootstrap_methods > 0 ) {
3350+ BSMAttributeEntry* bsme = cp->bsm_attribute_entry (0 );
33483351 assert (bsme->bootstrap_method_index () == entries->at (0 ), " " );
33493352 assert (bsme->argument_count () == entries->at (1 ), " " );
3350- int nexti = (attribute_entry_count == 1 ) ? entries->length () : offsets->at (1 );
3353+ int nexti = (num_bootstrap_methods == 1 ) ? entries->length () : offsets->at (1 );
33513354 assert (nexti == 2 + bsme->argument_count (), " " );
3352- if (attribute_entry_count > 1 ) {
3355+ if (num_bootstrap_methods > 1 ) {
33533356 bsme = cp->bsm_attribute_entry (1 );
33543357 assert (bsme->bootstrap_method_index () == entries->at (nexti+0 ), " " );
33553358 assert (bsme->argument_count () == entries->at (nexti+1 ), " " );
33563359 }
33573360 int lasti = offsets->at (offsets->length () - 1 );
3358- bsme = cp->bsm_attribute_entry (attribute_entry_count - 1 );
3361+ bsme = cp->bsm_attribute_entry (num_bootstrap_methods - 1 );
33593362 assert (bsme->bootstrap_method_index () == entries->at (lasti+0 ), " " );
33603363 assert (bsme->argument_count () == entries->at (lasti+1 ), " " );
33613364 int lastu2 = entries->at (entries->length () - 1 );
33623365 int lastac = bsme->argument_count ();
33633366 int expect_lastu2 = (lastac == 0 ) ? 0 : bsme->argument_index (lastac-1 );
33643367 assert (lastu2 == expect_lastu2, " " );
33653368 }
3369+ #endif
33663370}
33673371
33683372void ClassFileParser::parse_classfile_attributes (const ClassFileStream* const cfs,
0 commit comments