6 Programming for the Large Address Space

This chapter describes two ways in which you can take advantage of large memory storage in smart cards: By using library packages properly and by separating your data properly.

While the extended CAP files allow multiple packages in a single CAP file and method component of size greater than 64 K, the compact CAP files are still limited to a single package and have a 64 K limit on the method component. Therefore, you must take special considerations when using the compact CAP files to take advantage of the large memory storage in smart cards.

This chapter contains the following sections:

Overview of Programming for the Large Address Space

The default address space automatically built in the simulator is the large address space. Allowing your applications to take advantage of the large address capabilities of the Classic Edition simulator using compact CAP files requires careful planning and programming. Some size limitations still exist within the simulator. The way that you structure large applications and applications that manage large amounts of data determines how the large address space can be exploited.

Programming Large Applications and Libraries

With the introduction of Extended CAP files (see Programming Large Java Card Applications with Multiple Packages) since Java Card, Version 3.1, Java Card facilitates the development of large applications for its platform.

However, there might be scenarios where developers want to continue using the Compact CAP file format. For example, to target Java Card products that do not support Extended CAP files. When using the compact CAP file format, the most important limitation on a package is the 64 KB limitation on the maximum component size. This is especially true for the Method component. If the size of an application’s Method component exceeds 64 KB, then the Java Card Converter doesn’t process the package and returns an error.

You can overcome the component size limitation by dividing the application into separate application and library components. The Java Card platform has the ability to support library packages. Library packages contain code, which can be linked and reused by several applications. By dividing the functionality of a given application into application and library packages, you can increase the size of the components. It is important to note that there are important differences between library packages and applet packages:

Therefore, you must not place sensitive or exclusive-use code in a library package. It must be placed in an applet package, instead.

Handling a Package as a Separate Code Space

Several applications and API functionality can be installed in the smart card simultaneously by handling each package as a separate code space. This technique lets you exceed the 64KB limit, and provides full Java Card API functionality and support for complex applications requiring larger amounts of code.

Storing Large Amounts of Data

Today’s applications are required to securely store ever-growing amounts of information about the cardholder or network identity. This information includes certificates, images, security keys, and biometric and biographical information.

This information sometimes requires large amounts of storage. Before version 2.2.2, versions of the Java Card Platform Simulator had to save downloaded applications or user data in valuable persistent memory space. Sometimes, the amount of memory space required was insufficient for some applications. However, the memory access schemes introduced with version 2.2.2 allow applications to store large amounts of information, while still conforming to the Java Card specification.

The Java Card specification does not impose any requirements on object location or total object heap space used on the card. It specifies only that each object must be accessible by using a 16-bit reference. It also imposes some limitations on the amount of information an individual object is capable of storing, by using the number of fields or the count of array elements. Because of this loose association, it is possible for any given implementation to control how an object’s information is stored, and how much data these objects can collectively hold.

The Java Card Platform Simulator, enables you to use all of the available persistent memory space to store object information. By allowing you to separate data storage into distinct array and object types, this simulator enables you to store the large amounts of data demanded by today’s applications.