static int subclassDistance(Class a, Class b) { int n = 0; while (a != b) { a = a.getSuperclass(); if (a == null) ret Int.MAX_VALUE; ++n; } ret n; }