![]() ![]() ![]() ![]() |
Applets sometimes require objects that contain temporary (transient) data that need not be persistent across CAD sessions. Java Card platform does not support the Java-language keyword transient
. However, Java Card technology provides methods to create transient arrays with primitive components or references to Object
.
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:
false
, or null
) at the occurrence of certain events (see Section 5.1 "Events That Clear Transient Objects”). abortTransaction
will never cause a field in a transient object to be restored to a previous value.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.
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:
CLEAR_ON_RESET
—the object’s fields (except for the length field) are cleared when the card is reset. When a card is powered on, this also causes a card reset.CLEAR_ON_DESELECT
—the object’s fields (except for the length field) are cleared whenever the applet is deselected and no other applets from the same package are active on the card. Because a card reset implicitly deselects the currently selected applet, the fields of CLEAR_ON_DESELECT
objects are also cleared by the same events specified for CLEAR_ON_RESET
.
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:
![]() ![]() ![]() ![]() |
Runtime Environment Specification for the Java Card Platform Specification, 2.2.1 |
Copyright © 2003 Sun Microsystems, Inc. All rights reserved.