void () { Abc a = (Abc) Proxy.newProxyInstance( Abc.class.getClassLoader(), new Class<?>[]{Abc.class}, (proxy, method, args) -> { if (method.equals(Object.class.getDeclaredMethod("equals", Object.class))) { return (Boolean) (proxy == args[0]); } else if (method.equals(Object.class.getDeclaredMethod("hashCode"))) { return (Integer) System.identityHashCode(proxy); } else if (method.equals(Object.class.getDeclaredMethod("toString"))) { return Abc.class.getSimpleName(); } else { return null; } }); System.out.println(a.equals(a)); System.out.println(a.hashCode()); System.out.println(a); }