@@ -3279,90 +3279,94 @@ void ClassFileParser::parse_classfile_bootstrap_methods_attribute(const ClassFil
3279
3279
3280
3280
cfs->guarantee_more (attribute_byte_length, CHECK);
3281
3281
3282
- const int attribute_entry_count = cfs->get_u2_fast ();
3282
+ const u2 num_bootstrap_methods = cfs->get_u2_fast ();
3283
3283
3284
- guarantee_property (_max_bootstrap_specifier_index < attribute_entry_count ,
3284
+ guarantee_property (_max_bootstrap_specifier_index < num_bootstrap_methods ,
3285
3285
" Short length on BootstrapMethods in class file %s" ,
3286
3286
CHECK);
3287
3287
3288
3288
// The attribute contains a counted array of counted tuples of shorts,
3289
- // represending bootstrap specifiers:
3289
+ // representing bootstrap specifiers:
3290
3290
// 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 , " " );
3293
3293
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);
3295
3295
Array<u2>* const entries = // u2 data holding all the BSM attribute entries
3296
3296
MetadataFactory::new_array<u2>(_loader_data, attribute_tail_length / sizeof (u2), CHECK);
3297
3297
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.
3300
3300
cp->set_bsm_attribute_offsets (offsets);
3301
3301
cp->set_bsm_attribute_entries (entries);
3302
3302
3303
3303
int next_entry = 0 ;
3304
3304
const int cp_size = cp->length ();
3305
3305
3306
- for (int n = 0 ; n < attribute_entry_count ; n++) {
3306
+ for (int n = 0 ; n < num_bootstrap_methods ; n++) {
3307
3307
// Store a 32-bit offset into the array of BSM entry offsets.
3308
3308
offsets->at_put (n, next_entry);
3309
3309
3310
3310
// Read a bootstrap method attribute entry.
3311
3311
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 ();
3314
3314
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 (),
3317
3317
" bootstrap_method_index %u has bad constant type in class file %s" ,
3318
- bootstrap_method_index ,
3318
+ bootstrap_method_ref ,
3319
3319
CHECK);
3320
3320
3321
- guarantee_property ((next_entry + 2 + argument_count ) <= entries->length (),
3321
+ guarantee_property ((next_entry + 2 + num_bootstrap_arguments ) <= entries->length (),
3322
3322
" Invalid BootstrapMethods num_bootstrap_methods or num_bootstrap_arguments value in class file %s" ,
3323
3323
CHECK);
3324
3324
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++;
3327
3329
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++) {
3330
3332
const u2 argument_index = cfs->get_u2_fast ();
3331
3333
guarantee_property (
3332
3334
valid_cp_range (argument_index, cp_size) &&
3333
3335
cp->tag_at (argument_index).is_loadable_constant (),
3334
3336
" argument_index %u has bad constant type in class file %s" ,
3335
3337
argument_index,
3336
3338
CHECK);
3337
- entries->at_put (next_entry++, argument_index);
3339
+ entries->at_put (next_entry, argument_index);
3340
+ next_entry++;
3338
3341
}
3339
3342
}
3340
3343
guarantee_property (current_start + attribute_byte_length == cfs->current (),
3341
3344
" Bad length on BootstrapMethods in class file %s" ,
3342
3345
CHECK);
3343
3346
assert (next_entry == entries->length (), " " );
3344
3347
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 );
3348
3351
assert (bsme->bootstrap_method_index () == entries->at (0 ), " " );
3349
3352
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 );
3351
3354
assert (nexti == 2 + bsme->argument_count (), " " );
3352
- if (attribute_entry_count > 1 ) {
3355
+ if (num_bootstrap_methods > 1 ) {
3353
3356
bsme = cp->bsm_attribute_entry (1 );
3354
3357
assert (bsme->bootstrap_method_index () == entries->at (nexti+0 ), " " );
3355
3358
assert (bsme->argument_count () == entries->at (nexti+1 ), " " );
3356
3359
}
3357
3360
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 );
3359
3362
assert (bsme->bootstrap_method_index () == entries->at (lasti+0 ), " " );
3360
3363
assert (bsme->argument_count () == entries->at (lasti+1 ), " " );
3361
3364
int lastu2 = entries->at (entries->length () - 1 );
3362
3365
int lastac = bsme->argument_count ();
3363
3366
int expect_lastu2 = (lastac == 0 ) ? 0 : bsme->argument_index (lastac-1 );
3364
3367
assert (lastu2 == expect_lastu2, " " );
3365
3368
}
3369
+ #endif
3366
3370
}
3367
3371
3368
3372
void ClassFileParser::parse_classfile_attributes (const ClassFileStream* const cfs,
0 commit comments