Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8534033
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T10:06:06+00:00 2026-06-11T10:06:06+00:00

Lets say I have an array arr of objects of type A in memory,

  • 0

Lets say I have an array arr of objects of type A in memory, each of which has a reference field pointing to the same object B.

Illustration:

A_1  A_2  A_3 ... A_N
 |    |    |       |
 |    |    V       |
 \--->\--> B <-----/

Note that the reference field in every object of type A points to the same object of type B.

Now, I serialize the array arr containing objects of type A to an ObjectOutputStream. I then deserialize the bytes obtained in this way.

I get a new array arr1.

1) Does the array arr1 have objects of type A such that they all point to the same object of type B? (I don’t mean the same object before serialization, but a unique newly created object of type B)

2) In other words, does calling serialize/deserialize in Java retain the same object graph as it was before serialization? (i.e. is the newly deserialized object graph isomorphic to the old one)

3) Where is this documented? (i.e. please provide a citation)

4) The same questions 1-3, but applied to the Kryo serialization framework for Java.

Thank you.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T10:06:08+00:00Added an answer on June 11, 2026 at 10:06 am

    http://docs.oracle.com/javase/6/docs/api/java/io/ObjectOutputStream.html

    The default serialization mechanism for an object writes the class of
    the object, the class signature, and the values of all non-transient
    and non-static fields. References to other objects (except in
    transient or static fields) cause those objects to be written also.
    Multiple references to a single object are encoded using a reference
    sharing mechanism so that graphs of objects can be restored to the
    same shape as when the original was written.

    As for my understanding of the specification, you get shared object references if the object instances to be shared go throught the same ObjectOutputStream.

    So when you serialize the class containing the arr array, each object written gets an ID, and for each reference that passes through the stream, only that ID is written. The deserialized graph in that case remain homogeneous with the original graph.

    I am sorry but I cannot help with krio library own serialization mechanism, I would be very happy to learn from someone who used it as well.

    EDIT about kryo:

    Some documentation I found:

    • By default, each appearance of an object in the graph after the first is stored as an integer ordinal. This allows multiple references to the same object and cyclic graphs to be serialized. This has a small amount of overhead and can be disabled to save space if it is not needed: kryo.setReferences(false);

    • This (github) is the contract of the reference resolver; two implementation are given: ArrayList-based for small objects graphs, Map-based for larger ones

    • This is implementation of the default object array (de)serializer

    • Classes need to be registered for (de)serialization; each registered class can be coupled with a serializer (among which, the default Java serialization mechanism)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Lets say I have an array of Match objects, each belonging to a round
Lets say I have an array with a structure like this: $arr= Array( array(
Lets say I have an array like int arr[10][10]; Now i want to initialize
Lets say I have an array of chars which I have inputted from in
I have an array already existing. Lets say it has 3 items. $user =
Lets say i have an array of arrays, of which i dont know the
Ok, lets say I have an array of objects in C# .Net like so:
Lets say I have an array of javascript objects, and I am trying to
I have an array and lets say I have 5 objects in it. The
Lets say I have an array, 'foo', with two columns. Column 0 has values

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.