(Class midletClass, MIDletAccess previousMidletAccess)
| 86 | } |
| 87 | |
| 88 | private MIDlet loadMidlet(Class midletClass, MIDletAccess previousMidletAccess) { |
| 89 | try { |
| 90 | if (previousMidletAccess != null) { |
| 91 | previousMidletAccess.destroyApp(true); |
| 92 | } |
| 93 | } catch (Throwable e) { |
| 94 | logger.error("Unable to destroy MIDlet", e); |
| 95 | } |
| 96 | |
| 97 | MIDletContext context = new MIDletContext(); |
| 98 | MIDletBridge.setThreadMIDletContext(context); |
| 99 | MIDletBridge.getRecordStoreManager().init(MIDletBridge.getMicroEmulator()); |
| 100 | try { |
| 101 | MIDlet m; |
| 102 | |
| 103 | final String errorTitle = "Error starting MIDlet"; |
| 104 | |
| 105 | try { |
| 106 | Object object = midletClass.newInstance(); |
| 107 | m = (MIDlet) object; |
| 108 | } catch (Throwable e) { |
| 109 | logger.error("Unable to create MIDlet", e); |
| 110 | MIDletBridge.destroyMIDletContext(context); |
| 111 | return null; |
| 112 | } |
| 113 | |
| 114 | try { |
| 115 | if (context.getMIDlet() != m) { |
| 116 | throw new Error("MIDlet Context corrupted"); |
| 117 | } |
| 118 | |
| 119 | return m; |
| 120 | } catch (Throwable e) { |
| 121 | logger.debug("Unable to start MIDlet", e); |
| 122 | MIDletBridge.destroyMIDletContext(context); |
| 123 | return null; |
| 124 | } |
| 125 | |
| 126 | } finally { |
| 127 | MIDletBridge.setThreadMIDletContext(null); |
| 128 | } |
| 129 | |
| 130 | } |
| 131 | |
| 132 | public boolean platformRequest(final String URL) { |
| 133 | return emulatorContext.platformRequest(URL); |
no test coverage detected