code: public static Class<?> getCommonType(Class<?> common, Class<?> compare) {
          if ( null == common )
              return compare;
          if ( null == compare || common.isAssignableFrom(compare) )
              return common;
  
          // pick the largest number type based on NUMBER_ORDER definitions
          if ( NUMBER_ORDER.containsKey(common)
                  && NUMBER_ORDER.containsKey(compare) )
              if ( NUMBER_ORDER.get(common) >= NUMBER_ORDER.get(compare) )
                  return common;
              else
                  return compare;
  
          // find a common super class
          Class<?> supr = common;
          while ( null != (supr = supr.getSuperclass()) && Object.class != supr )
              if ( supr.isAssignableFrom(compare) )
                  return supr;
  
          // common type can only be Object
          return Object.class;
      }
docs: Find the common type between two classes.
  @param common most likely common class
  @param compare class compared with
  @return the class representing the most common type.