C H A P T E R  5

Transient Objects

Applets sometimes require objects that contain temporary (transient) data that need not be persistent across CAD sessions. The Java Card platform does not support the Java programming language keyword transient. However, Java Card technology provides methods to create transient arrays with primitive components or references to Object.



Note - In this section, the term field is used to refer to the component of an array object also.



The term "transient object" is a misnomer. It can be incorrectly interpreted to mean that the object itself is transient. However, only the contents of the fields of the object (except for the length field) have a transient nature. As with any other object in the Java programming language, transient objects within the Java Card platform exist as long as they are referenced from:

A transient object within the Java Card platform has the following required behavior:

This behavior makes transient objects ideal for small amounts of temporary applet data that is frequently modified, but that need not be preserved across CAD or select sessions.


5.1 Events That Clear Transient Objects

Persistent objects are used for maintaining states that shall be preserved across card resets. When a transient object is created, one of two events is specified that causes its fields to be cleared. CLEAR_ON_RESET transient objects are used for maintaining states that shall be preserved across applet selections, but not across card resets. CLEAR_ON_DESELECT transient objects are used for maintaining states that must be preserved while an applet is selected, but not across applet selections or card resets.

Details of the two clear events are as follows:



Note - It is not necessary to clear the fields of transient objects before power is removed from a card. However, it is necessary to guarantee that the previous contents of such fields cannot be recovered once power is lost.



The currently selected applet is explicitly deselected (its deselect method is called) only when a SELECT FILE command or MANAGE CHANNEL CLOSE command is processed. The currently selected applet is deselected and then the fields of all CLEAR_ON_DESELECT transient objects owned by the applet are cleared if no other applets from the same package are active on the card, regardless of whether the SELECT FILE command: