From a9233dcb006ca6834021e227825749672ebb7643 Mon Sep 17 00:00:00 2001 From: Codrut Stancu Date: Wed, 7 Aug 2019 20:52:08 -0700 Subject: [PATCH] Simplify condition and narrow checkstyle exception. (cherry picked from commit f65597546c7fd42d1bc9cc0e8850a70755ffaae6) --- .../oracle/svm/core/jdk/JavaLangReflectSubstitutions.java | 5 +---- .../src/com/oracle/svm/test/ArraySetTest.java | 3 ++- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/JavaLangReflectSubstitutions.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/JavaLangReflectSubstitutions.java index 36a8ff527793..027760aa2040 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/JavaLangReflectSubstitutions.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/JavaLangReflectSubstitutions.java @@ -364,10 +364,7 @@ private static void set(Object array, int index, Object value) { return; } } else if (array instanceof Object[]) { - if (value == null) { - ((Object[]) array)[index] = null; - return; - } else if (array.getClass().getComponentType().isAssignableFrom(value.getClass())) { + if (value == null || array.getClass().getComponentType().isAssignableFrom(value.getClass())) { ((Object[]) array)[index] = value; return; } diff --git a/substratevm/src/com.oracle.svm.test/src/com/oracle/svm/test/ArraySetTest.java b/substratevm/src/com.oracle.svm.test/src/com/oracle/svm/test/ArraySetTest.java index dc24e1976743..2d57909ed8a6 100644 --- a/substratevm/src/com.oracle.svm.test/src/com/oracle/svm/test/ArraySetTest.java +++ b/substratevm/src/com.oracle.svm.test/src/com/oracle/svm/test/ArraySetTest.java @@ -24,7 +24,8 @@ */ package com.oracle.svm.test; -// Checkstyle: off +// Checkstyle: allow reflection + import java.lang.reflect.Array; import org.junit.Assert;