@@ -64,15 +64,15 @@ void JvmtiClassFileReconstituter::write_field_infos() {
64
64
// Compute the real number of Java fields
65
65
int java_fields = ik ()->java_fields_count ();
66
66
67
- write_u2 (java_fields);
67
+ write_u2 (checked_cast<u2>( java_fields) );
68
68
for (JavaFieldStream fs (ik ()); !fs.done (); fs.next ()) {
69
69
AccessFlags access_flags = fs.access_flags ();
70
- int name_index = fs.name_index ();
71
- int signature_index = fs.signature_index ();
72
- int initial_value_index = fs.initval_index ();
70
+ u2 name_index = fs.name_index ();
71
+ u2 signature_index = fs.signature_index ();
72
+ u2 initial_value_index = fs.initval_index ();
73
73
guarantee (name_index != 0 && signature_index != 0 , " bad constant pool index for field" );
74
74
// int offset = ik()->field_offset( index );
75
- int generic_signature_index = fs.generic_signature_index ();
75
+ u2 generic_signature_index = fs.generic_signature_index ();
76
76
AnnotationArray* anno = fields_anno == nullptr ? nullptr : fields_anno->at (fs.index ());
77
77
AnnotationArray* type_anno = fields_type_anno == nullptr ? nullptr : fields_type_anno->at (fs.index ());
78
78
@@ -84,10 +84,10 @@ void JvmtiClassFileReconstituter::write_field_infos() {
84
84
// JVMSpec| attribute_info attributes[attributes_count];
85
85
// JVMSpec| }
86
86
87
- write_u2 (access_flags.as_int () & JVM_RECOGNIZED_FIELD_MODIFIERS);
87
+ write_u2 (access_flags.get_flags () & JVM_RECOGNIZED_FIELD_MODIFIERS);
88
88
write_u2 (name_index);
89
89
write_u2 (signature_index);
90
- int attr_count = 0 ;
90
+ u2 attr_count = 0 ;
91
91
if (initial_value_index != 0 ) {
92
92
++attr_count;
93
93
}
@@ -147,11 +147,11 @@ void JvmtiClassFileReconstituter::write_code_attribute(const methodHandle& metho
147
147
ConstMethod* const_method = method->constMethod ();
148
148
u2 line_num_cnt = 0 ;
149
149
int stackmap_len = 0 ;
150
- int local_variable_table_length = 0 ;
151
- int local_variable_type_table_length = 0 ;
150
+ u2 local_variable_table_length = 0 ;
151
+ u2 local_variable_type_table_length = 0 ;
152
152
153
153
// compute number and length of attributes
154
- int attr_count = 0 ;
154
+ u2 attr_count = 0 ;
155
155
int attr_size = 0 ;
156
156
if (const_method->has_linenumber_table ()) {
157
157
line_num_cnt = line_number_table_entries (method);
@@ -229,7 +229,7 @@ void JvmtiClassFileReconstituter::write_code_attribute(const methodHandle& metho
229
229
}
230
230
231
231
ExceptionTable exception_table (method ());
232
- int exception_table_length = exception_table.length ();
232
+ u2 exception_table_length = exception_table.length ();
233
233
int code_size = const_method->code_size ();
234
234
int size =
235
235
2 +2 +4 + // max_stack, max_locals, code_length
@@ -276,7 +276,7 @@ void JvmtiClassFileReconstituter::write_code_attribute(const methodHandle& metho
276
276
// JVMSpec| }
277
277
void JvmtiClassFileReconstituter::write_exceptions_attribute (ConstMethod* const_method) {
278
278
CheckedExceptionElement* checked_exceptions = const_method->checked_exceptions_start ();
279
- int checked_exceptions_length = const_method->checked_exceptions_length ();
279
+ u2 checked_exceptions_length = const_method->checked_exceptions_length ();
280
280
int size =
281
281
2 + // number_of_exceptions
282
282
2 * checked_exceptions_length; // exception_index_table
@@ -307,7 +307,7 @@ void JvmtiClassFileReconstituter::write_method_parameter_attribute(const ConstMe
307
307
308
308
write_attribute_name_index (" MethodParameters" );
309
309
write_u4 (size);
310
- write_u1 (length);
310
+ write_u1 ((u1) length);
311
311
for (int index = 0 ; index < length; index ++) {
312
312
write_u2 (parameters[index ].name_cp_index );
313
313
write_u2 (parameters[index ].flags );
@@ -361,7 +361,7 @@ void JvmtiClassFileReconstituter::write_signature_attribute(u2 generic_signature
361
361
// Compute the number of entries in the InnerClasses attribute
362
362
u2 JvmtiClassFileReconstituter::inner_classes_attribute_length () {
363
363
InnerClassesIterator iter (ik ());
364
- return iter.length ();
364
+ return checked_cast<u2>( iter.length () );
365
365
}
366
366
367
367
// Write an annotation attribute. The VM stores them in raw form, so all we need
@@ -394,17 +394,17 @@ void JvmtiClassFileReconstituter::write_bootstrapmethod_attribute() {
394
394
int num_bootstrap_methods = ConstantPool::operand_array_length (operands);
395
395
396
396
// calculate length of attribute
397
- int length = sizeof (u2); // num_bootstrap_methods
397
+ u4 length = sizeof (u2); // num_bootstrap_methods
398
398
for (int n = 0 ; n < num_bootstrap_methods; n++) {
399
399
u2 num_bootstrap_arguments = cpool ()->operand_argument_count_at (n);
400
400
length += sizeof (u2); // bootstrap_method_ref
401
401
length += sizeof (u2); // num_bootstrap_arguments
402
- length += sizeof (u2) * num_bootstrap_arguments; // bootstrap_arguments[num_bootstrap_arguments]
402
+ length += (u4) sizeof (u2) * num_bootstrap_arguments; // bootstrap_arguments[num_bootstrap_arguments]
403
403
}
404
404
write_u4 (length);
405
405
406
406
// write attribute
407
- write_u2 (num_bootstrap_methods);
407
+ write_u2 (checked_cast<u2>( num_bootstrap_methods) );
408
408
for (int n = 0 ; n < num_bootstrap_methods; n++) {
409
409
u2 bootstrap_method_ref = cpool ()->operand_bootstrap_method_ref_index_at (n);
410
410
u2 num_bootstrap_arguments = cpool ()->operand_argument_count_at (n);
@@ -424,7 +424,7 @@ void JvmtiClassFileReconstituter::write_bootstrapmethod_attribute() {
424
424
// }
425
425
void JvmtiClassFileReconstituter::write_nest_host_attribute () {
426
426
int length = sizeof (u2);
427
- int host_class_index = ik ()->nest_host_index ();
427
+ u2 host_class_index = ik ()->nest_host_index ();
428
428
429
429
write_attribute_name_index (" NestHost" );
430
430
write_u4 (length);
@@ -444,7 +444,7 @@ void JvmtiClassFileReconstituter::write_nest_members_attribute() {
444
444
445
445
write_attribute_name_index (" NestMembers" );
446
446
write_u4 (length);
447
- write_u2 (number_of_classes);
447
+ write_u2 (checked_cast<u2>( number_of_classes) );
448
448
for (int i = 0 ; i < number_of_classes; i++) {
449
449
u2 class_cp_index = nest_members->at (i);
450
450
write_u2 (class_cp_index);
@@ -464,7 +464,7 @@ void JvmtiClassFileReconstituter::write_permitted_subclasses_attribute() {
464
464
465
465
write_attribute_name_index (" PermittedSubclasses" );
466
466
write_u4 (length);
467
- write_u2 (number_of_classes);
467
+ write_u2 (checked_cast<u2>( number_of_classes) );
468
468
for (int i = 0 ; i < number_of_classes; i++) {
469
469
u2 class_cp_index = permitted_subclasses->at (i);
470
470
write_u2 (class_cp_index);
@@ -488,7 +488,7 @@ void JvmtiClassFileReconstituter::write_record_attribute() {
488
488
int number_of_components = components->length ();
489
489
490
490
// Each component has a u2 for name, descr, attribute count
491
- int length = sizeof (u2) + (sizeof (u2) * 3 * number_of_components);
491
+ u4 length = checked_cast<u4>( sizeof (u2) + (sizeof (u2) * 3 * number_of_components) );
492
492
for (int x = 0 ; x < number_of_components; x++) {
493
493
RecordComponent* component = components->at (x);
494
494
if (component->generic_signature_index () != 0 ) {
@@ -505,7 +505,7 @@ void JvmtiClassFileReconstituter::write_record_attribute() {
505
505
506
506
write_attribute_name_index (" Record" );
507
507
write_u4 (length);
508
- write_u2 (number_of_components);
508
+ write_u2 (checked_cast<u2>( number_of_components) );
509
509
for (int i = 0 ; i < number_of_components; i++) {
510
510
RecordComponent* component = components->at (i);
511
511
write_u2 (component->name_index ());
@@ -538,7 +538,7 @@ void JvmtiClassFileReconstituter::write_inner_classes_attribute(int length) {
538
538
InnerClassesIterator iter (ik ());
539
539
guarantee (iter.length () != 0 && iter.length () == length,
540
540
" caller must check" );
541
- u2 entry_count = length / InstanceKlass::inner_class_next_offset;
541
+ u2 entry_count = checked_cast<u2>( length / InstanceKlass::inner_class_next_offset) ;
542
542
u4 size = 2 + entry_count * (2 +2 +2 +2 );
543
543
544
544
write_attribute_name_index (" InnerClasses" );
@@ -592,8 +592,8 @@ void JvmtiClassFileReconstituter::write_line_number_table_attribute(const method
592
592
593
593
CompressedLineNumberReadStream stream (method->compressed_linenumber_table ());
594
594
while (stream.read_pair ()) {
595
- write_u2 (stream.bci ());
596
- write_u2 (stream.line ());
595
+ write_u2 (checked_cast<u2>( stream.bci () ));
596
+ write_u2 (checked_cast<u2>( stream.line () ));
597
597
}
598
598
}
599
599
@@ -736,7 +736,7 @@ void JvmtiClassFileReconstituter::write_method_info(const methodHandle& method)
736
736
++attr_count; // has RuntimeVisibleTypeAnnotations attribute
737
737
}
738
738
739
- write_u2 (attr_count);
739
+ write_u2 (checked_cast<u2>( attr_count) );
740
740
if (const_method->code_size () > 0 ) {
741
741
write_code_attribute (method);
742
742
}
@@ -776,7 +776,7 @@ void JvmtiClassFileReconstituter::write_class_attributes() {
776
776
AnnotationArray* anno = ik ()->class_annotations ();
777
777
AnnotationArray* type_anno = ik ()->class_type_annotations ();
778
778
779
- int attr_count = 0 ;
779
+ u2 attr_count = 0 ;
780
780
if (generic_signature != nullptr ) {
781
781
++attr_count;
782
782
}
@@ -867,7 +867,7 @@ void JvmtiClassFileReconstituter::write_method_infos() {
867
867
}
868
868
}
869
869
870
- write_u2 (num_methods - num_overpass);
870
+ write_u2 (checked_cast<u2>( num_methods - num_overpass) );
871
871
if (JvmtiExport::can_maintain_original_method_order ()) {
872
872
int index ;
873
873
int original_index;
@@ -911,7 +911,7 @@ void JvmtiClassFileReconstituter::write_class_file_format() {
911
911
912
912
// JVMSpec| u2 constant_pool_count;
913
913
// JVMSpec| cp_info constant_pool[constant_pool_count-1];
914
- write_u2 (cpool ()->length ());
914
+ write_u2 (checked_cast<u2>( cpool ()->length () ));
915
915
copy_cpool_bytes (writeable_address (cpool_size ()));
916
916
917
917
// JVMSpec| u2 access_flags;
@@ -928,7 +928,7 @@ void JvmtiClassFileReconstituter::write_class_file_format() {
928
928
// JVMSpec| u2 interfaces[interfaces_count];
929
929
Array<InstanceKlass*>* interfaces = ik ()->local_interfaces ();
930
930
int num_interfaces = interfaces->length ();
931
- write_u2 (num_interfaces);
931
+ write_u2 (checked_cast<u2>( num_interfaces) );
932
932
for (int index = 0 ; index < num_interfaces; index ++) {
933
933
HandleMark hm (thread ());
934
934
InstanceKlass* iik = interfaces->at (index );
0 commit comments