Java Card Technology Ch04: Java Card Object - PowerPoint PPT Presentation

1 / 15
About This Presentation
Title:

Java Card Technology Ch04: Java Card Object

Description:

A persistent object is created by the new operator. ... In fact, the term transient object means that the contents of the fields of the ... – PowerPoint PPT presentation

Number of Views:181
Avg rating:3.0/5.0
Slides: 16
Provided by: smi792
Category:
Tags: card | ch04 | fact | java | object | technology

less

Transcript and Presenter's Notes

Title: Java Card Technology Ch04: Java Card Object


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(B
    UFFER_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 isnt 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
Write a Comment
User Comments (0)
About PowerShow.com