@@ -965,12 +965,12 @@ class AnnotationCollector : public ResourceObj{
965965 // Set the annotation name:
966966 void set_annotation (ID id) {
967967 assert ((int )id >= 0 && (int )id < (int )_annotation_LIMIT, " oob" );
968- _annotations_present |= nth_bit ((int )id);
968+ _annotations_present |= ( int ) nth_bit ((int )id);
969969 }
970970
971971 void remove_annotation (ID id) {
972972 assert ((int )id >= 0 && (int )id < (int )_annotation_LIMIT, " oob" );
973- _annotations_present &= ~nth_bit ((int )id);
973+ _annotations_present &= ( int ) ~nth_bit ((int )id);
974974 }
975975
976976 // Report if the annotation is present.
@@ -1737,8 +1737,8 @@ const ClassFileParser::unsafe_u2* ClassFileParser::parse_localvariable_table(con
17371737 TRAPS) {
17381738 const char * const tbl_name = (isLVTT) ? " LocalVariableTypeTable" : " LocalVariableTable" ;
17391739 *localvariable_table_length = cfs->get_u2 (CHECK_NULL);
1740- const unsigned int size =
1741- (*localvariable_table_length) * sizeof (Classfile_LVT_Element) / sizeof (u2);
1740+ const unsigned int size = checked_cast< unsigned >(
1741+ (*localvariable_table_length) * sizeof (Classfile_LVT_Element) / sizeof (u2)) ;
17421742
17431743 const ConstantPool* const cp = _cp;
17441744
@@ -2349,23 +2349,23 @@ Method* ClassFileParser::parse_method(const ClassFileStream* const cfs,
23492349
23502350 calculated_attribute_length =
23512351 sizeof (max_stack) + sizeof (max_locals) + sizeof (code_length);
2352- calculated_attribute_length +=
2352+ calculated_attribute_length += checked_cast< unsigned int >(
23532353 code_length +
23542354 sizeof (exception_table_length) +
23552355 sizeof (code_attributes_count) +
23562356 exception_table_length *
23572357 ( sizeof (u2) + // start_pc
23582358 sizeof (u2) + // end_pc
23592359 sizeof (u2) + // handler_pc
2360- sizeof (u2) ); // catch_type_index
2360+ sizeof (u2) )); // catch_type_index
23612361
23622362 while (code_attributes_count--) {
23632363 cfs->guarantee_more (6 , CHECK_NULL); // code_attribute_name_index, code_attribute_length
23642364 const u2 code_attribute_name_index = cfs->get_u2_fast ();
23652365 const u4 code_attribute_length = cfs->get_u4_fast ();
23662366 calculated_attribute_length += code_attribute_length +
2367- sizeof (code_attribute_name_index) +
2368- sizeof (code_attribute_length);
2367+ ( unsigned ) sizeof (code_attribute_name_index) +
2368+ ( unsigned ) sizeof (code_attribute_length);
23692369 check_property (valid_symbol_at (code_attribute_name_index),
23702370 " Invalid code attribute name index %u in class file %s" ,
23712371 code_attribute_name_index,
@@ -2479,7 +2479,7 @@ Method* ClassFileParser::parse_method(const ClassFileStream* const cfs,
24792479 }
24802480 method_parameters_seen = true ;
24812481 method_parameters_length = cfs->get_u1_fast ();
2482- const u2 real_length = (method_parameters_length * 4u ) + 1u ;
2482+ const u4 real_length = (method_parameters_length * 4u ) + 1u ;
24832483 if (method_attribute_length != real_length) {
24842484 classfile_parse_error (
24852485 " Invalid MethodParameters method attribute length %u in class file" ,
@@ -3202,7 +3202,7 @@ u2 ClassFileParser::parse_classfile_permitted_subclasses_attribute(const ClassFi
32023202// u2 attributes_count;
32033203// attribute_info_attributes[attributes_count];
32043204// }
3205- u2 ClassFileParser::parse_classfile_record_attribute (const ClassFileStream* const cfs,
3205+ u4 ClassFileParser::parse_classfile_record_attribute (const ClassFileStream* const cfs,
32063206 const ConstantPool* cp,
32073207 const u1* const record_attribute_start,
32083208 TRAPS) {
@@ -3404,7 +3404,7 @@ void ClassFileParser::parse_classfile_bootstrap_methods_attribute(const ClassFil
34043404 // The attribute contains a counted array of counted tuples of shorts,
34053405 // represending bootstrap specifiers:
34063406 // length*{bootstrap_method_index, argument_count*{argument_index}}
3407- const int operand_count = (attribute_byte_length - sizeof (u2)) / sizeof (u2);
3407+ const unsigned int operand_count = (attribute_byte_length - ( unsigned ) sizeof (u2)) / ( unsigned ) sizeof (u2);
34083408 // operand_count = number of shorts in attr, except for leading length
34093409
34103410 // The attribute is copied into a short[] array.
@@ -4812,7 +4812,7 @@ const char* ClassFileParser::skip_over_field_signature(const char* signature,
48124812 const char * c = (const char *) memchr (signature, JVM_SIGNATURE_ENDCLASS, length - 1 );
48134813 // Format check signature
48144814 if (c != nullptr ) {
4815- int newlen = c - (char *) signature;
4815+ int newlen = pointer_delta_as_int (c, (char *) signature) ;
48164816 bool legal = verify_unqualified_name (signature, newlen, LegalClass);
48174817 if (!legal) {
48184818 classfile_parse_error (" Class name is empty or contains illegal character "
@@ -5022,7 +5022,7 @@ int ClassFileParser::verify_legal_method_signature(const Symbol* name,
50225022 if (p[0 ] == ' J' || p[0 ] == ' D' ) {
50235023 args_size++;
50245024 }
5025- length -= nextp - p ;
5025+ length -= pointer_delta_as_int ( nextp, p) ;
50265026 p = nextp;
50275027 nextp = skip_over_field_signature (p, false , length, CHECK_0);
50285028 }
@@ -5241,7 +5241,7 @@ void ClassFileParser::fill_instance_klass(InstanceKlass* ik,
52415241 // size is equal to the number of methods in the class. If
52425242 // that changes, then InstanceKlass::idnum_can_increment()
52435243 // has to be changed accordingly.
5244- ik->set_initial_method_idnum (ik->methods ()->length ());
5244+ ik->set_initial_method_idnum (checked_cast<u2>( ik->methods ()->length () ));
52455245
52465246 ik->set_this_class_index (_this_class_index);
52475247
0 commit comments