static GridOptimizedClassDescriptor classDescriptor(Class<?> cls, @Nullable Object obj) throws IOException {
if (obj != null) {
if (obj instanceof GridOptimizedMarshallable) {
GridOptimizedMarshallable m = (GridOptimizedMarshallable)obj;
Object clsId = m.ggClassId();
if (clsId != null && !(clsId instanceof GridOptimizedClassDescriptor))
throw new IOException("Method '" + obj.getClass().getName() + ".ggClassId() must return " +
"the value of the field '" + CLS_ID_FIELD_NAME + "'.");