Java tutorial
//package com.java2s; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; public class Main { private static final Map<Class<?>, Boolean> _customEquals = new ConcurrentHashMap<Class<?>, Boolean>(); public static boolean hasCustomEquals(Class c) { Class origClass = c; if (_customEquals.containsKey(c)) { return _customEquals.get(c); } while (!Object.class.equals(c)) { try { c.getDeclaredMethod("equals", Object.class); _customEquals.put(origClass, true); return true; } catch (Exception ignored) { } c = c.getSuperclass(); } _customEquals.put(origClass, false); return false; } }