java.lang.Object.class is 37 bytes in serialized form. That's about twice as long as the String "java.lang.Object" and it is also binary crackers in your datastore (which means it might be harder to review manually if there are data issues).
Here's a program that will let you test serialization in both compressed and uncompressed form (compressed tends to only "win" for relatively larger things):
=================================
package ya;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.io.OutputStream;
import java.util.zip.GZIPOutputStream;
public class YA110809 {
public static void main(String[] args) {
try {
Class c = Object.class;
byte[] b = serializeObjectToBytes(c, false);
System.out.println("uncompressed = " + b.length);
b = serializeObjectToBytes(c, true);
System.out.println("compressed = " + b.length);
} catch (Throwable th) {
th.printStackTrace();
}
}
static byte[] serializeObjectToBytes(Object anObject, boolean aCompress)
throws IOException {
ByteArrayOutputStream bos = new ByteArrayOutputStream(4096);
ObjectOutputStream oos;
OutputStream os;
if (aCompress) {
os = new GZIPOutputStream(bos);
} else {
os = bos;
}
oos = new ObjectOutputStream(os);
oos.writeObject(anObject);
oos.flush();
oos.close();
if (aCompress) {
os.flush();
os.close();
}
return bos.toByteArray();
}
}
=================================