C H A P T E R  4

Adherence to the Java Language Specification

The general goal for a virtual machine conforming to the Java Card platform is to be as compliant with the Java Language Specification as is feasible within the strict memory limits of Java Card platform target devices. This chapter summarizes the differences between a virtual machine conforming to Java Card platform and the Java virtual machine of the Java SE platform. Except for the differences indicated herein, a virtual machine conforming to the Java Card platform MUST be compatible with The Java Language Specification, Third Edition, by James Gosling, Bill Joy, and Guy L. Steele (Addison-Wesley, 2005), ISBN 0-321-24678-0.



Note - For the remainder of this specification, the Java Language Specification will be referred to as JLS. Sections within the Java Language Specification will be referred to using the § symbol. For example, (JLS §4.2.4).



4.1 No Floating Point Support

The main language-level difference between the full Java Language Specification and this Virtual Machine Specification, Java Card Platform, v3.0.1, Connected Edition is that a JVM implementation supporting the Java Card platform does not have floating point support. Floating point support was removed because the majority of Java Card platform target devices do not have hardware floating point support and the cost of supporting floating point in software was considered too high.

This means that a JVM implementation supporting the Java Card platform shall not allow the use of floating point literals (JLS §3.10.2), floating point types and values (JLS §4.2.3) and floating point operations (JLS §4.2.4). For further information, refer to Section 5.1, No Floating Point Support in this Virtual Machine Specification, Java Card Platform, v3.0.1, Connected Edition.


4.2 No Finalization of Class Instances

Java Card platform libraries do not include the methodObject.finalize(). Therefore, a virtual machine conforming to Java Card platform does not support finalization of class instances (JLS §12.6). No application built to conform to the Java Card platform shall require that finalization is available.


4.3 Exception and Error Handling Limitations

A virtual machine conforming to the Java Card platform MUST generally support exception handling as defined in JLS Chapter 11, with the exception that asynchronous exceptions (JLS §11.3.2) are not supported.

In contrast, the set of error classes included in the Java Card platform libraries is limited, and consequently the error handling capabilities of the Java Card platform are considerably more limited. This is because of the following two reasons:

Application programmers cannot be expected to worry about device-specific error handling mechanisms and conventions.

Implementing the error handling capabilities fully according to the Java Language Specification is rather expensive, and mandating the presence and handling of all the error classes would impose an overhead on the virtual machine implementation.

A virtual machine conforming to the Java Card platform MUST support the set of Error classes defined in Section 6.2, Classes Derived from Java SE Platform. When encountering any other error, the implementation MUST behave in one of the following ways:

If the virtual machine conforming to the Java Card platform implements additional error checks that are part of the Java Language Specification but that are not required by the Virtual Machine Specification, Java Card Platform, v3.0.1, Connected Edition, the implementation MUST throw the nearest Java Card platform-supported superclass of the Error class representing the error condition that is defined by the Java Language Specification.