import java.lang.reflect.Array; public class Main { public static void main(String... args) { Object o = new int[2]; Array.setShort(o, 0, (short) 2); // widening, succeeds Array.setLong(o, 1, 2L); // narrowing, fails } }