1 / 15

Java Card Technology Ch04: Java Card Object

Java Card Technology Ch04: Java Card Object. Instructors: Fu-Chiung Cheng ( 鄭福炯 ) Associate Professor Computer Science & Engineering Tatung University. Objects in the Java Card. JCRE and applets create objects to represent, store and manipulate data Object in in the Java Card:

Download Presentation

Java Card Technology Ch04: Java Card Object

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Java Card TechnologyCh04: Java Card Object Instructors: Fu-Chiung Cheng (鄭福炯) Associate Professor Computer Science & Engineering Tatung University

  2. Objects in the Java Card • JCRE and applets create objects to represent, store and manipulate data • Object in in the Java Card: • All the objects on the Java Card platform are instances of classes or array types, which have the same root class java.lang.Object. • Fields in a new object or components in a new array are set to their default values (zero, null, or false) unless they are initialized to some other values in the constructor.

  3. Java Card Memory Model • Three kinds of memory: ROM, RAM, and EEPROM. • ROM: • read only memory where program and data were burned. • The least expensive • RAM and EEPROM can be read and written. • RAM is used for temporary storage; EEPROM is used for longer-lived data.

  4. Persistent Objects (Ⅰ) • A persistent object is created by the new operator. • A persistent object holds states and values across CAD sessions. • Any update to single field in a persistent object is atomic. • A persistent object can be referenced by a field in a transient object. • A field in a persistent object can reference a transient object.

  5. Persistent Objects (Ⅱ) • If a persistent object is not referenced by other objects, it becomes unreachable or can be garbage collected.

  6. Transient Object • The term transient object is somewhat of misnomer. • It can be incorrectly interpreted to mean that the object itself is temporary: when the power is removed, the transient object is destroyed • In fact, the term transient object means that the contents of the fields of the object have a temporary nature • As with persistent objects, the space allocated for transient objects is reserved and cannot be reclaimed unless a garbage collector is implemented.

  7. Transient Object • An applet should create a transient object only once during its lifetime and should save the object reference in a persistent field (see Figure 4.1 on page 51) • The next time the card is powered on, the applet use the same object reference to access the transient object (variable)

  8. Transient objects • In Java Card 2.1, only arrays with primitive types or arrays with references to Object can be declared transient • The primitive type in Java Card platform are byte, short, int and boolean • Transient object == transient array

  9. Properties of transient objects(Ⅰ) • A transient object is created by invoking the Java Card APIs. • A transient object does not hold states and values across CAD sessions. The fields of a transient object are cleared to their default value (zero,false, or null) at the occurrence of certain events. • Any update to a single field in a transient object is not atomic.

  10. Properties of Transient Objects (Ⅱ) • A transient object can be referenced by a field in persistent objects. • A field in a transient object can reference a persistent object. • If a transient object is not referenced by other objects, it becomes unreachable or can be garbage collected. • Writes to the fields of a transient object do not have a performance penalty, because RAM has a much faster write cycle time than EEPROM

  11. Transient Object Types • CLEAR_ON_RESET Transient objects are used for maintaining data that need to be preserved across applet selections but not across card resets. • Card master session key • CLEAR_ON_DESELECT transient objects are used for maintaining data that must be preserved as long as an applet is selected but not across applet selections or card resets. • Applet-owned session key

  12. Creating Transient Objects • In Java Card technology, transient objects are created by using one of the factory methods in the JCSystem class. • Table 4.1 on page 53 • public static boolean[] makeTransientBooleanArray(short length, byte event) • makeTransientByteArray • makeTransientShortArray • makeTransientObjectArray

  13. Creating Transient Objects • Length specifies the requested transient array length • Event indicates which kind of event clear the object (CLEAR_ON_RESET and CLEAR_ON_DESELECT) • Example: • byte[] buffer = JCSystem.makeTransientByteArray(BUFFER_LENGTH, JCSystem.CLEAR_ON_DESELECT)

  14. Querying Transient Objects • An applet may need to access an object that is created by different applet. • JCSystem class provides a convenient query method for an applet to determine whether an object being accessed is transient • public static byte isTransient(Object theObject) • The method isTansient returns a constant (either CLEAR_ON_RESET or CLEAR_ON_DESELECT) or the constant JCSystem.NOT_A_TRANSIENT_OBJECT to indicate that the object is null or is a persistent object.

  15. A Few Words about Objects Creation and Deletion • If there isn’t sufficient nonvolatile space available when an applet tries to create a persistent object using the new operator, the JCRE will throw a SystemException with the reason code JCSystem.NO_RESOURCE. • When an applet calls one of the make-transient-object and there is insuffient RAM space available, JCRE throws a SystemException with the reason code JCSystem.NO_TRANSIENT_SPACE

More Related