syncope-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From René Mulder <>
Subject serializable inner classes good or bad?
Date Fri, 04 May 2012 14:48:15 GMT
Hi All,

I've been going through the Sonar violations and found that we have 226 major violations of
the following type:

Bad practice - Serializable inner class

findbugs : SE_INNER_CLASS
This Serializable class is an inner class. Any attempt to serialize it will also serialize
the associated outer instance. The outer instance is serializable, so this won't fail, but
it might serialize a lot more data than intended. If possible, making the inner class a static
inner class (also known as a nested class) should solve the problem.

As I see it, the way to solve this is to extract these classes and inject the fields that
they currently use of the parent classes. The thing is, are these classes really ever serialized
without their parent class being serialized as well? So is this indeed bad practice? And do
we ever reuse these inner classes? It seems to me that they are very specific to the parent
class. So basicly: should i solve this and how?


  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message