FileDocCategorySizeDatePackage
JumpInit.javaAPI DocphoneME MR2 API (J2ME)3537Wed May 02 18:00:04 BST 2007com.sun.midp.jump

JumpInit

public class JumpInit extends Object
Initialize the JUMP executive environment for using midp code.

Fields Summary
Constructors Summary
Methods Summary
public static voidinit()


	// First, load the midp natives.   
        try {
            String n = System.getProperty("sun.midp.library.name", "midp");
            // DEBUG: System.err.println("Loading DLL \"" + n + "\" ...");
            System.loadLibrary(n);
        } catch (UnsatisfiedLinkError err) {}

	/** 
         * Path to MIDP working directory. 
         * Default is the property "sun.midp.home.path", the fallback is user.dir.
        */
        String userdir = System.getProperty("user.dir", ".");
        String home = System.getProperty("sun.midp.home.path", userdir);
        String profile = System.getProperty("microedition.profiles");
	if (profile == null) 
            System.setProperty("microedition.profiles", "MIDP-2.1");

        if (!initMidpNativeStates(home)) {
           throw new RuntimeException("MIDP native initialization failed");
        }

	/** 
	 * Making the runtime believe that this is a trusted midlet suite.
	 * This is needed because in midp's code, security check is often done
	 * by checking the executing midlet suite's security token.
	 * See com.sun.midp.jump.installer.TrustedMIDletSuiteInfo for more
	 * information.
	 **/
	
        final MIDletStateHandler handler = MIDletStateHandler.getMidletStateHandler();
        MIDletSuite suite = handler.getMIDletSuite();
        if (suite == null) {
           AccessController.doPrivileged(new PrivilegedAction() {
              public Object run() {
      
                try {
                    Class clazz = MIDletStateHandler.class;
                    Field midletSuiteField = clazz.getDeclaredField("midletSuite");

                    midletSuiteField.setAccessible(true);
      
                    midletSuiteField.set(handler, new TrustedMIDletSuiteInfo());

                } catch (Exception e) { e.printStackTrace(); }
                    return null;
               }
            });
        }
     
static native booleaninitMidpNativeStates(java.lang.String home)
Performs native subsystem initialization.

param
home path to the MIDP working directory.