Cannot cast java.lang.Long to java.lang.Integer

if (type.equals(Integer.class)) {
     Integer result =  new Integer( Math.toIntExact((Long) o)); // o 是 Long类型的实例
 }