===== 4.2 Multiselectable Applets ===== Applets having the capability of being selected on multiple logical channels at the same time, or accepting other applets belonging to the same package being selected simultaneously, are referred to as multiselectable applets. Note - All applets within a package shall be multiselectable or none shall be. An applet's context is active when either an instance of the applet is already active, or when another applet instance from the same package is active. For more information about contexts see [[6.1.2_Contexts and Context Switching| Section 6.1.2, Contexts and Context Switching]]. An attempt to select an applet instance when the applet's context is active, is referred to as a multiselection attempt. If successful, multiselection occurs, and the applet instance becomes multiselected. Multiselectable applets shall implement the **javacard.framework.MultiSelectable** interface. In case of multiselection, the applet instance is informed by invoking its methods **MultiSelectable.select** and **MultiSelectable.deselect** during selection and deselection respectively. When an applet instance not currently active is the first one selected in its package, its **Applet.select** method is called. Subsequent multiselections to this applet instance or selection of other applet instances in the same package shall result in a call to **MultiSelectable.select** method. This method is defined in the **MultiSelectable** interface. Its only purpose is to inform the applet instance that it will be multiselected. The applet instance may accept or reject a multiselection attempt. If a multiselection attempt is made on an applet which does not implement the **MultiSelectable** interface, the selection shall be rejected by the Java Card RE. When a multiselected applet instance is deselected from one of the logical channels, the method **MultiSelectable.deselect** is called. Only when the multiselected applet instance is the last active applet instance in the applet's context, is its regular method **Applet.deselect** called. The following list describes the two cases of multiselection: 1. When two distinct applet instances from within the same package are multiselected, each applet instance shares the same **CLEAR_ON_DESELECT** memory transient segment. The applet instances share objects within the context firewall as well as their transient data. The Java Card RE shall not reset this **CLEAR_ON_DESELECT** transient objects until all applet instances within the package are deselected, see [[4._Logical_Channels_and_Applet_Selection| FIGURE 4-2]]. FIGURE 4-2 Different Applet Instances in Same Package {{figures:JCRESpec04selection-6.jpg|}} 2. When the same applet instance is multiselected on two different logical channels simultaneously, it shares the **CLEAR_ON_DESELECT** memory segment space across logical channels. The Java Card RE shall not reset the **CLEAR_ON_DESELECT** transient objects until all applet instances within the package are deselected, see [[4._Logical_Channels_and_Applet_Selection| FIGURE 4-3]]. FIGURE 4-3 Same Applet Instance Selected on Multiple Logical Channels {{figures:JCRESpec04selection-7.jpg|}} In both cases of multiselection, the applets must implement the **MultiSelectable** interface. If the applets do not support this feature, the selection must be rejected by the Java Card RE.