shitala099 / microemu

Automatically exported from code.google.com/p/microemu
0 stars 0 forks source link

When saving for web, System.getProperty() returns null on keys that must always be defined #45

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?

1. Do some J2ME code like:
// check for supported MIDP version
String supportedMidpProfile = System.getProperty("microedition.profiles");
if (supportedMidpProfile.indexOf("MIDP-2.") == -1) {
  // if MIDP 2.0 is not supported, then the application will not run
  utilObj.log("MIDP 2.0 not supported by the device.\n" +
                      applicationName + " will not run correctly !");
  Thread.sleep(3000);
}
(or download from e.g. http://dictionarymid.sourceforge.net/dict.html)

2. Run in microemulator (web start). Runs OK

3. Save for web

4. Run as applet.
java.lang.NullPointerException applears in when calling 
supportedMidpProfile.indexOf("MIDP-2.")

What is the expected output? What do you see instead?
According to 
http://developers.sun.com/mobility/midp/questions/properties/index.html
there are some properties that developers can trust are always defined. 
Microemu returns null in all cases when running as an applet.

What version of the product are you using? On what operating system?
Irrelevant

Please provide any additional information below.
See 
http://code.google.com/p/microemu/source/browse/trunk/microemulator/microem
u-injected/src/main/java/org/microemu/Injected.java

Please change 
        public static String getProperty(String key) {
                try {
                        return System.getProperty(key);
                } catch (SecurityException e) {
                        return null;
                }
        }

to something like

        public static String getProperty(String key) {
                String value;
                try {
                        value = System.getProperty(key);
                } catch (SecurityException e) {
                        value = null;
                }
                if (value != null) return value;
                if ("microedition.encoding".equals(key)) return 
"ISO8859_1";
                if ("microedition.configuration".equals(key)) return "CLDC-
1.0";
                if ("microedition.profiles".equals(key)) return "MIDP-2.0";
                ... (etc)
                return null;
        }

Thanks,
Jacob

Original issue reported on code.google.com by jacob.nordfalk on 29 Apr 2010 at 4:41

GoogleCodeExporter commented 8 years ago
In Applet the different class is executed (the same name though)
microemu-javase/src/main/java/org/microemu/Injected.java

Method bode is different:
    public static String getProperty(String key) {
        return MIDletSystemProperties.getProperty(key);
    }

In MIDletSystemProperties I have added though the requested properties.

Original comment by bar...@gmail.com on 6 May 2010 at 10:43