inside setInputFormatClass, we're doing:
But inside setOutputFormatClass, we're doing toString for class, instead of getName().
Difference is that, for Class A.class, toString is "class A.class", getName is "A.class". So Class.forName(cls.getName()) succeeds, but Class.forName(cls.toString()) is not valid.
So if you get a partition, set outputformat, and make an alter call, then get the partition again and make a getOutputFormatClass call on that object, it throws a ClassNotFoundException on https://github.com/apache/hive/blob/master/ql/src/java/org/apache/hadoop/hive/ql/metadata/Partition.java#L316, because it's basically calling Class.forName("class a.b.c.ClassName.class") which is wrong!