There is an anecdotal evidence that replacing direct class checks with Class.isInstance helps when "obj" has subclasses, and "obj.getClass() != tclass" could not be optimized. fullCheck() does Class.isInstance anyway, so it seems functionally correct to use it in the "quick" checks.
public final int get(T obj) {
if (obj == null || obj.getClass() != tclass || cclass != null) fullCheck(obj);
return U.getIntVolatile(obj, offset);
}
private void fullCheck(T obj) {
if (!tclass.isInstance(obj))
throw new ClassCastException();
if (cclass != null)
ensureProtectedAccess(obj);
}
This should be checked after JDK-8140483 lands. C1 and C2 may disagree which pattern is faster.