Skip to content

Commit beec734

Browse files
committed
8309692: Fix -Wconversion warnings in javaClasses
Reviewed-by: fparain, matsaave
1 parent 7d82479 commit beec734

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

src/hotspot/share/classfile/javaClasses.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -817,16 +817,16 @@ static void initialize_static_primitive_field(fieldDescriptor* fd, Handle mirror
817817
BasicType t = fd->field_type();
818818
switch (t) {
819819
case T_BYTE:
820-
mirror()->byte_field_put(fd->offset(), fd->int_initial_value());
820+
mirror()->byte_field_put(fd->offset(), checked_cast<jbyte>(fd->int_initial_value()));
821821
break;
822822
case T_BOOLEAN:
823-
mirror()->bool_field_put(fd->offset(), fd->int_initial_value());
823+
mirror()->bool_field_put(fd->offset(), checked_cast<jboolean>(fd->int_initial_value()));
824824
break;
825825
case T_CHAR:
826-
mirror()->char_field_put(fd->offset(), fd->int_initial_value());
826+
mirror()->char_field_put(fd->offset(), checked_cast<jchar>(fd->int_initial_value()));
827827
break;
828828
case T_SHORT:
829-
mirror()->short_field_put(fd->offset(), fd->int_initial_value());
829+
mirror()->short_field_put(fd->offset(), checked_cast<jshort>(fd->int_initial_value()));
830830
break;
831831
case T_INT:
832832
mirror()->int_field_put(fd->offset(), fd->int_initial_value());

src/hotspot/share/classfile/javaClasses.inline.hpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -325,15 +325,15 @@ inline bool java_lang_Module::is_instance(oop obj) {
325325
inline int Backtrace::merge_bci_and_version(int bci, int version) {
326326
// only store u2 for version, checking for overflow.
327327
if (version > USHRT_MAX || version < 0) version = USHRT_MAX;
328-
assert((jushort)bci == bci, "bci should be short");
329-
return build_int_from_shorts(version, bci);
328+
assert((u2)bci == bci, "bci should be short");
329+
return build_int_from_shorts((u2)version, (u2)bci);
330330
}
331331

332332
inline int Backtrace::merge_mid_and_cpref(int mid, int cpref) {
333333
// only store u2 for mid and cpref, checking for overflow.
334-
assert((jushort)mid == mid, "mid should be short");
335-
assert((jushort)cpref == cpref, "cpref should be short");
336-
return build_int_from_shorts(cpref, mid);
334+
assert((u2)mid == mid, "mid should be short");
335+
assert((u2)cpref == cpref, "cpref should be short");
336+
return build_int_from_shorts((u2)cpref, (u2)mid);
337337
}
338338

339339
inline int Backtrace::bci_at(unsigned int merged) {

src/hotspot/share/runtime/globals.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1274,7 +1274,7 @@ const int ObjectAlignmentInBytes = 8;
12741274
"(0.0 means off)") \
12751275
range(0.0, (double)max_intx) \
12761276
\
1277-
product(intx, MaxJavaStackTraceDepth, 1024, \
1277+
product(int, MaxJavaStackTraceDepth, 1024, \
12781278
"The maximum number of lines in the stack trace for Java " \
12791279
"exceptions (0 means all)") \
12801280
range(0, max_jint/2) \

0 commit comments

Comments
 (0)