An applet instance is deselected either upon receipt of a MANAGE CHANNEL CLOSE command, or as a result of a SELECT FILE command that selects a different (or the same) applet instance on the specified logical channel.
In either case, when an applet instance is deselected the following procedure shall be followed by the Java Card RE:
If the applet instance to be deselected is active on more than one logical channel, or another applet instance from the same package is also active, the Java Card RE sets the currently selected applet instance to be the applet instance being deselected, and calls its
MultiSelectable.deselect(appInstStillActive) method, where the
appInstStillActive parameter is set to
true if the same applet instance is still active on another logical channel. A context switch occurs into the applet instance's context at this point, see
Section 6.1.2, Contexts and Context Switching.
Otherwise, the Java Card RE sets the currently selected applet instance to be the applet instance being deselected, and calls its Applet.deselect method. Upon return or uncaught exception, the Java Card RE clears the fields of all CLEAR_ON_DESELECT transient objects in the context of deselected applet instance.
Note - Note that the deselection is always successful even if the applet instance throws an exception from within the deselect method.