Directory

Encyclopedia

NodeWorks
                              ENCYCLOPEDIA

Link Checker

Home
Encyclopedia : M : MI : MID :

MIDlet Preverify

 

MIDlet Preverify


A MIDlet is a Java program for embedded devices, more specifically the J2ME virtual machine. Generally, these are games and applications that run on a cell phone.

Introduction


Since class verification in J2SE takes up 50k and the lack of space in MIDP devices, the class verification has been broken up to a part that is completed by the developer and apart completed by the Mobile JVM itself. The developer directed class verfication stage is called MIDlet preverifiication or preverfification. Preverification occurs after the class is compiled.

What Tasks Preverification Completes


Generally, the preverification task annotates the class files with notes that the small incomplete class verifier in the Mobile JVM reads and uses to do a fast class verification to enable the Mobile JVM to then run the resulting bytecodes. The resulting bytecodes are valid bytecodes because the annotations are using attributes of the bytecode to make the notes for the Mobile JVM to read in doing its final incomplete class verification().

JVM Class File Verification


According to the, The Java Virtual Machine Specification() ISBN 0201432943, class file verififcation is completed in 4 passes beofre full startup of the JVM occurs in runing bytecode of an application.

Pass 1

  • Correct magic number in the first four bytes
  • Byte code attributes must be the proper length
  • The class file cannot be truncatd or have exta bytes at end
  • Constant pool must not contain any superficial data

    Pass 2

  • Ensures that final classes are not subclassed and that the final methods are not overridden
  • Checks that every class except object has direct superclass
  • Ensures that the constant pool meets documented static constraints
  • Checks that all field references and method references in the constant pool have valid names, valid classes, and a valid type descriptor.

    Pass 3


    During linking the verfier checks the code array of the code attribute by performing a data flow analysis to ensure these items are true:
  • That the operand stack is always the same size and contains the same types of values
  • No local variable is accessed unless it is known to contain a value of an appropriate type
  • Methods are invoked with the appropriate arguments
  • Fields are assigned only using values of appropriate types
  • All opcodes have appropriate type arguments on the operand stack and in the local variable array

    Pass 4


    This is the pass where class loading occurs to finalize the class verification process.

    Preverification Steps

  • The preverification places a StackMap Attribute, which is a sub attribute of the Code attribute, which describe variable types used and operand stack items
  • inlines all subroutines and removes jumps()

    Conclusion


    Preverification preverifies the compiled classes by inserting annotations in the StackMap portion of the Code attribute describing variable types used and operand stack items. This and inlining all subroutines and removing jumps reduces the first 3 passes of the J2SE verification process to soemthing more manageable with the mobile device memory sizes in completing the last 4th pass on the mobile device within the mobile jvm.

    References

  • (http://www.jguru.com/faq/view.jsp?EID=201507)


  • NodeWorks boosts web surfing!
    Page Returned in 0.045 seconds - HTML Compressed 67.5%

    This article is from Wikipedia. All text is available
    under the terms of the GNU Free Documentation License.
     GNU Free Documentation License
    © 2008 Chamas Enterprises Inc.