class A implements Serializable{
}
class B extends A{
//this also inherits the marker
}
So is there is a way to unimplement/unmark the marker within class B?
Example: If there are two classes extending A named B and C. But out of them only C wants to be serializable and not B.
It isn’t just that Java is missing support for this: such a feature would completely break down its OOP foundations. Type polymorphism means that one can apply Liskov’s substitution principle on subtypes: your “feature” would render it inapplicable.
Every subtype is bound tightly by the contract of the type it extends: at each place one refers to the supertype, an instance of subtype must be able to occur. Therefore if the supertype is serialiable, we cannot allow any subtype not to be.
Answering from a different perspective, if you need functionality from the serializable type
Ain a non-serializable typeB, then base your design on composition instead of inheritance: letBinclude an appropriate instance ofA.