• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

how makeChild classes as Non Serializable if parent class is Serializable in java ?

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
how makeChild classes as Non Serializable if parent class is Serializable in java ?

class parent implements Serializable.

and i have

class child extends parent .

But I want class child to be Non Serializable.
 
Saloon Keeper
Posts: 15484
363
  • Likes 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Don't extend the parent class.
 
Marshal
Posts: 79151
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A subclass "IS-A" superclass. If the superclass "IS-A" Serializable, then the subclass "IS-A" Serializable too. If it's not Serializable, then it isn't a subclass of it.
 
Sheriff
Posts: 22781
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
However, even if the sub class is Serializable (capital S, instance of the interface) it doesn't need to be serializable (lowercase s, can actually be serialized). If an instance has any non-transient fields that are not serializable then the instance is not serializable - trying to serialize it will lead to an IOException.
 
Campbell Ritchie
Marshal
Posts: 79151
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
We have all designed classes like that, Rob. I remember one just like that throwing NullPointerExceptions when I deserialised it just before handing in my second degree assignment
There were all sorts of NotSerializableExceptions scattered round the .ser file when I opened it.
 
Campbell Ritchie
Marshal
Posts: 79151
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

A few minutes ago, I wrote:We have all designed classes like that, Rob. . . .

Maybe "designed" was slightly overoptimistic vocabulary
 
Rob Spoor
Sheriff
Posts: 22781
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Was this a case of bad testing, or bad time management?

That said, a project group I worked with in university had created a networked game for a class. We had had a small communication problem before where the last-joined client wasn't in sync with the rest. We thought we'd solved that, until we had the demo. And guess which of the clients was the last to join? Of course, the one connected to the beamer...

An ex-colleague of mine at least had the brilliance (the only brilliance he's ever shown) to show all errors (and there were quite a lot of them) on the secondary screen instead of the displayed screen during his demo.
 
Campbell Ritchie
Marshal
Posts: 79151
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Rob Spoor wrote:Was this a case of bad testing, or bad time management? . . .

Or both?
 
Campbell Ritchie
Marshal
Posts: 79151
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Rob Spoor wrote:. . . to show all errors . . . on the secondary screen . . .

Yes, yes, yes
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic