I was being taught that Marker interface in Java is an empty interface and is used to signal to compiler or JVM that the objects of the class implementing this interface must be treated in a special way, like serializing, cloning, etc.
But lately I have learned that it actually has nothing to do with the compiler or the JVM. For example, in case of
writeObject(Serializable)so that there is a compile-time type checking - This lets you avoid polluting your code with the name of the marker interface when a "plain
Object" is needed. For example, if you make a class that needs to be serializable, and has object members, you would be forced to either do casting or make your objects
Serializableat compile time. This is inconvenient, because the interface is devoid of any functionality.