@Override
    public com.esotericsoftware.kryo.kryo5.Registration getRegistration(Class type) {
      // If PartitionExpressionForMetastore performs deserialization at remote HMS,
      // the first class encountered during deserialization must be an ExprNodeDesc,
      // throw exception to avoid potential security problem if it is not.
      if (isExprNodeFirst && classCounter == 0) {
        if (!ExprNodeDesc.class.isAssignableFrom(type)) {
          throw new UnsupportedOperationException(
              "The object to be deserialized must be an ExprNodeDesc, but encountered: " + type);
        }
      }
      classCounter++;
      return super.getRegistration(type);
    }
Provides general-purpose hooks for specific types, as well as a global hook.
ql/src/java/org/apache/hadoop/hive/ql/exec/SerializationUtilities.java