lundi 11 mai 2020

getting java.lang.ClassCastException: [Ljava.lang.Integer; cannot be cast to [I

Try to get a method return type int array and getting casting error for(String s:oldOfferList) { LOGGER.log(Level.FINE, "Method name"+s);

        Method getNameMethod = old_offer2.getClass().getMethod(s);
        if(getNameMethod.getName().equals("getLevelId"))
        {
             @SuppressWarnings("unchecked")
              int[] oldLevelids =  (int[]) getNameMethod.invoke(old_offer2);
             @SuppressWarnings("unchecked")
              int[] newMethodsval =  (int[]) getNameMethod.invoke(current_offer2);
              if( !Arrays.equals(oldLevelids, newMethodsval)){
              LOGGER.log(Level.FINE," oldLevelids not equals to newMethodsval : "  
                       ); 
              DiffPropValuesEntity dpv=new DiffPropValuesEntity(getNameMethod.getName().toString(),Arrays.toString(oldLevelids).replaceAll("\\s+", ""),Arrays.toString(newMethodsval).replaceAll("\\s+", ""));
                listDiffPropValuesEntity.add(dpv);
              }else {
                  LOGGER.log(Level.FINE," oldLevelids  equals to newMethodsval : "  );

              }
         continue;
        }




Aucun commentaire:

Enregistrer un commentaire