Site Tools

Sidebar

Smart Card Solution

User Manual

JavaCard API Samples

Java Card Specification

Knowledge Sharing

javacard:jcre:6.1.2.2_context_switching_in_the_vm

6.1.2.2 Context Switching in the VM

If access is allowed, the VM determines if a context switch is required. A context switch occurs when certain well-defined conditions, as described in Section 6.2.8, Class and Object Access Behavior, are met during the execution of invoke-type bytecodes. For example, a context switch may be caused by an attempt to access a shareable object that belongs to an applet instance that resides in a different package. The result of a context switch is a new currently active context.

During a context switch, the previous context and object owner information is pushed on an internal VM stack, a new context becomes the currently active context, and the invoked method executes in this new context. Upon exit from that method the VM performs a restoring context switch. The original context (of the caller of the method) is popped from the stack and is restored as the currently active context. Context switches can be nested. The maximum depth depends on the amount of VM stack space available.

Most method invocations in Java Card technology do not cause a context switch. For example, a context switch is unnecessary when an attempt is made to access an object that belongs to an applet instance that resides in the same package. Context switches only occur during invocation of and return from certain methods, as well as during exception exits from those methods (see Section 6.2.8, Class and Object Access Behavior).

Further details of contexts and context switching are provided in later sections of this chapter.

javacard/jcre/6.1.2.2_context_switching_in_the_vm.txt · Last modified: 2017/05/13 04:07 (external edit)