• 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

what happens when a serializable object in java contains other non serializable objects

 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Can any one be so kind to help me knowing " what happens when a serializable object in java contains other non serializable objects " during serialization.

Also, there are some objects in java API that cannot be serialized like ResourceBundle, servletContext, java.util. Enumeration. If such objects exist in a serilizable user defined class, how can we make this compeltely serializable and how can we serialize the non serializable java API objects.

Many thanks.

Warm Regards,
Prasanna Lakshmi Tallapaka
 
Bartender
Posts: 2700
IntelliJ IDE Opera
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Prasanna Lakshmi Tallapaka wrote:Can any one be so kind to help me knowing " what happens when a serializable object in java contains other non serializable objects " during serialization.

Why don't you try it for yourself? You'll learn more than if someone answers your question.

Prasanna Lakshmi Tallapaka wrote:Also, there are some objects in java API that cannot be serialized like ResourceBundle, servletContext, java.util. Enumeration. If such objects exist in a serilizable user defined class, how can we make this compeltely serializable and how can we serialize the non serializable java API objects.

You can mark them as transient. This is a nice article about serialization. Remember that serialization is no longer on the exam.
 
Ranch Hand
Posts: 1051
Eclipse IDE Firefox Browser
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
for your first question..
You will get not serializable exception..please have a try atleast once..

second question is already given above...
Marking transient will solve your problem...
 
He baked a muffin that stole my car! And this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic