This question is twofold, but hopefully shouldn't be unreasonably long to answer, despite its own length. Feel free to answer only part of it, though, and sorry for making it so exhaustive!
- Which objects are persisted? Which objects are transient?
- When is an object persisted?
For the first part, the question applies to:
- Objects that are stored in an
Applet
- Objects that are transitively stored in an
Applet
- Objects that are only stored in stack variables (not referenced, even transitively, from any
Applet
) - Objects that are stored in an array built with
makeTransientObjectArray
- Objects that are transitively stored in an array build with
makeTransientObjectArray
(eg. stored in a member variable of an object stored in amakeTransientObjectArray
)
For the second part, it applies depending on the answer of the first question. For instance:
- I assume objects that are directly stored in a transient object array are not persisted. In this case and assuming objects on the stack are persisted, when does the object stored there become not-persisted? Is it persisted at the
new Object
and un-persisted when being put into the transient object array? - If an object has references from both a transient object array and an applet, and the applet reference is erased, is the object un-persisted?
Thank you in advance!
I have looked into the JCRE specification v2.2.2 (the version I'm using), but there are points that are unclear in it (hence the exhaustiveness of this question, as I feel this is more appropriate for a Q/A-style forum):
- Page 2-2 mentions that the JCRE makes an object persistent when it's transitively stored in an
Applet
. However, Glossary-7 states that objects are persistent by default. The difference may seem non-observable, but affects the need to garbage-collect or not when a card power cycle is needed anyway. - Page 5-1 states that the fields of a transient object must never be stored in persistent memory. But it doesn't state whether this is also true for objects transitively in a transient object array, eg. objects stored in fields of objects in a transient object array.
- Page 5-1, same statements, may conflict with page 2-2, when an object has a reference to it stored both in a transient object array and in an
Applet
.
These three questions are respectively equivalent to:
- part 1 bullet points 3 and 5 (and, depending on the answer, part 2 bullet point 1)
- part 1 bullet point 5
- part 2 bullet point 2