Why don't you use use an upper bound in your generic parametrization for E
?
As in:
private <E extends Serializable> void writeEvent(ObjectOutputStream out,E obj) {
// etc.
}
The confusion here would be that Serializable
is an interface and cannot be "extended" by classes (but it can be extended by other interfaces as Thomas remarks), but the upper bound is still valid.
Of course this implies that your E
s will need to implement Serializable
, or implement an interface that extends Serializable
.