FileDocCategorySizeDatePackage
JVM.javaAPI DocphoneME MR2 API (J2ME)11654Wed May 02 17:59:54 BST 2007com.sun.cldchi.jvm

JVM

public class JVM extends Object

Fields Summary
public static final int
REMOVE_CLASSES_FROM_JAR
If this flag is defined and the romization is successful, class files are removed from the JAR file(s) after the romization process. This parameter is ignored for source romization.
public static final int
STATUS_CANCELLED
Returned by getAppImageProgress() to indicate that the last image creation process has was cancelled before it was completed.
public static final int
STATUS_FAILED
Returned by getAppImageProgress() to indicate that the last image creation process has failed before it was completed.
public static final int
STATUS_VIRGIN
Returned by getAppImageProgress() to indicate that no image creation process has ever been started since the VM was bootstraped.
public static final int
STATUS_START
Any value returned by getAppImageProgress() that.s greater or equal to STATUS_START, but lower than STATUS_SUCCEEDED, means that the image creation is still taking place.
public static final int
STATUS_SUCCEEDED
Returned by getAppImageProgress() to indicate that the last image creation process has succeeded.
public static final int
STATUS_VERIFY_NOTHING
Returned by verifyJar() to indicate no classes verification has ever been started since VM didn't find any classes in JAR.
public static final int
STATUS_VERIFY_SUCCEEDED
Returned by verifyJar() to indicate all JAR classes were successfully verified.
public static final int
STATUS_VERIFY_FAILED
Returned by verifyJar() to indicate JAR classes verification failed by some reason.
Constructors Summary
Methods Summary
public static native voidcancelImageCreation()
If an image creation process is underway, cancel it. This will force createAppImage() to delete all temporary files, as well as the output image file, and return immediately. A future call to getAppImageProgress() will return STATUS_CANCELLED. If an image creation process is not underway, this method has no effect.

private static voidcreateAppImage(char[] jarFile, char[] binFile, int flags)
Creates an application image file. It loads the Java classes from the jarFile into the heap, verify the class contents, and write the classes to an Application Image file as specified by binFile. This function is typically executed by the Application Management Software (AMS) immediately after a JAR file is downloaded to the device.

This function must be called with a clean VM state -- i.e., if a Java application is executing, you must exit the Java application before running the Converter.

In MVM mode, this method should not be called only from within a clean Isolate.

Interaction with classpath and shared libraries: In the context of the VM (or current Isolate), the classpath may be specified to additional shared libraries. These shared libraries are loaded first, before jarFile is loaded. All shared libraries specified on the classpath must be binary image files and must be be JAR files. Note that if the image creation process was cancelled, no exception is thrown. A subsequent call to getAppImageProgress() will return STATUS_CANCELLED.

param
jarFile specifies the JAR file to be converted.
param
binFile specifies the name of the app image file to be written into
exception
Error if another instance of the converter is already running.
exception
OutOfMemoryError if the VM ran out of memory during the image creation process.


                                                                                                                                                                                                                                                                              
          
                                           
        startAppImage(jarFile, binFile, flags);
        for (;;) {
            if (!createAppImage0()) {
                break;
            }
        }
    
public static voidcreateAppImage(java.lang.String jarFile, java.lang.String binFile, int flags)

        createAppImage(jarFile.toCharArray(), binFile.toCharArray(),
                       flags);
    
private static native booleancreateAppImage0()
Returns true if the image creation process has completed or been concelled.

private static native voidcreateSysImage()
This method is used by the source romizer to create ROMImage.cpp.

exception
Error if the romization process fails for any reason.

public static native intgetAppImageProgress()

public static native voidloadLibrary(java.lang.String libName)
This method is used to load binary library into the VM. It allows to call native function implementations from this library.

param
libName name of the library WITHOUT EXTENSION. It was made to make java code platform-independent.
exception
Error if the VM fails to load the library with this name.

private static native voidstartAppImage(char[] jarFile, char[] binFile, int flags)

public static voidunchecked_byte_arraycopy(byte[] src, int srcOffset, byte[] dst, int dstOffset, int length)
Copy an array from the specified source array, beginning at the specified position, to the specified position of the destination array.

Impose the following restrictions on the input arguments:

  • dst is not null.
  • src is not null.
  • The srcOffset argument is not negative.
  • The dstOffset argument is not negative.
  • The length argument is not negative.
  • srcOffset+length is not greater than src.length, the length of the source array.
  • dstOffset+length is not greater than dst.length, the length of the destination array.
  • any actual component of the source array from position srcOffset through srcOffset+length-1 can be converted to the component type of the destination array

The caller is responsible that these restrictions are not violated. If any of the restrictions above is violated, the behavior is undefined.

param
src the source array.
param
srcOffset start position in the source array.
param
dst the destination array.
param
dstOffset start position in the destination data.
param
length the number of array elements to be copied.

      System.arraycopy(src, srcOffset, dst, dstOffset, length);
    
public static voidunchecked_char_arraycopy(char[] src, int srcOffset, char[] dst, int dstOffset, int length)

      System.arraycopy(src, srcOffset, dst, dstOffset, length);
    
public static voidunchecked_int_arraycopy(int[] src, int srcOffset, int[] dst, int dstOffset, int length)

      System.arraycopy(src, srcOffset, dst, dstOffset, length);
    
public static voidunchecked_long_arraycopy(long[] src, int srcOffset, long[] dst, int dstOffset, int length)

      System.arraycopy(src, srcOffset, dst, dstOffset, length);
    
public static voidunchecked_obj_arraycopy(java.lang.Object[] src, int srcOffset, java.lang.Object[] dst, int dstOffset, int length)

      System.arraycopy(src, srcOffset, dst, dstOffset, length);
    
public static intverifyJar(java.lang.String jar, int chunkSize)
Verifies all classes of the given JAR package within the current VM instance. The JAR path should be included into classpath(s) of the VM.

param
jar specifies the JAR file to be verified.
param
chunkSize amount of bytecode to be verified with a single native call, however not less than one class will be verified with a single call.
return
status of the JAR classes verification, it can be one of the following values STATUS_VERIFY_NOTHING, STATUS_VERIFY_SUCCEEDED or STATUS_VERIFY_FAILED


        int nextChunkID = 0;
        int status = STATUS_VERIFY_NOTHING;
        try {
            do {
                nextChunkID = verifyNextChunk(jar, nextChunkID, chunkSize);
                Thread.yield();
            } while (nextChunkID > 0);
            // OK, just all files verified
            if (nextChunkID == 0) {
                status = STATUS_VERIFY_SUCCEEDED;
            }
        } catch (Throwable t) {
            //do we need it?
            t.printStackTrace();
            status = STATUS_VERIFY_FAILED;
        }

        return status;
    
private static native intverifyNextChunk(java.lang.String jar, int nextChunkID, int chunkSize)