Skip to content

Commit 551e656

Browse files
committed
8374113: Taughtological if check in Reflection::array_set
Reviewed-by: fparain, liach
1 parent e6c3ebe commit 551e656

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

src/hotspot/share/runtime/reflection.cpp

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -270,17 +270,16 @@ void Reflection::array_set(jvalue* value, arrayOop a, int index, BasicType value
270270
if (!a->is_within_bounds(index)) {
271271
THROW(vmSymbols::java_lang_ArrayIndexOutOfBoundsException());
272272
}
273-
if (a->is_objArray()) {
274-
if (value_type == T_OBJECT) {
275-
oop obj = cast_to_oop(value->l);
276-
if (obj != nullptr) {
277-
Klass* element_klass = ObjArrayKlass::cast(a->klass())->element_klass();
278-
if (!obj->is_a(element_klass)) {
279-
THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(), "array element type mismatch");
280-
}
273+
if (value_type == T_OBJECT) {
274+
assert(a->is_objArray(), "just checking");
275+
oop obj = cast_to_oop(value->l);
276+
if (obj != nullptr) {
277+
Klass* element_klass = ObjArrayKlass::cast(a->klass())->element_klass();
278+
if (!obj->is_a(element_klass)) {
279+
THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(), "array element type mismatch");
281280
}
282-
objArrayOop(a)->obj_at_put(index, obj);
283281
}
282+
objArrayOop(a)->obj_at_put(index, obj);
284283
} else {
285284
assert(a->is_typeArray(), "just checking");
286285
BasicType array_type = TypeArrayKlass::cast(a->klass())->element_type();

0 commit comments

Comments
 (0)