nonethespinosa / microemu

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

removeCommand(null) on a Displayable gives incorrectly a NullPointerException #44

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Open Web start from
http://snapshot.microemu.org/microemu-webstart/index.html
2. Download a dictionary from
http://dictionarymid.sourceforge.net/dict.html and put it on a web page
(Ive done that at: http://javabog.dk/filer/DictionaryForMIDs-crash )
3. Open the emulator's log window
4. Drag the JAD file to the emulator and start it

What is the expected output? What do you see instead?
I see a NullPointerException, caused by invoking removeCommand(null) on a
Displayable (unfortunately I can't copy text from the log window in
microemu...)

What version of the product are you using? On what operating system?
I tried all microemu versions.

Please provide any additional information below.
The javadoc specifies that removeCommand(null) should be possible.

removeCommand

public void removeCommand(Command cmd)

    Removes a command from the Displayable. If the command is not in the
Displayable (tested by comparing the object references), the method has no
effect. If the Displayable is actually visible on the display, and this
call affects the set of visible commands, the implementation should update
the display as soon as it is feasible to do so. If cmd is null, this method
does nothing.

    Parameters:
        cmd - the command to be removed

(I copied from
http://www.j2medev.com/api/midp/javax/microedition/lcdui/Displayable.html#remove
Command%28javax.microedition.lcdui.Command%29)

Original issue reported on code.google.com by jacob.nordfalk on 28 Apr 2010 at 10:12

GoogleCodeExporter commented 9 years ago

Here is the code:

        public void removeCommand(Command cmd)
        {
                ui.removeCommandUI(cmd.ui);
        }

Please change this to

        public void removeCommand(Command cmd)
        {
                if (cmd != null) ui.removeCommandUI(cmd.ui);
        }

The class is in

http://microemu.googlecode.com/svn›
trunk›
microemulator›
microemu-midp›
src›
main›
java›
javax›
microedition›
lcdui›
Displayable.java

Thanks,
Jacob

Original comment by jacob.nordfalk on 28 Apr 2010 at 10:17

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
I also found this problem.

Could you fix it ?

Original comment by Guillaum...@gmail.com on 29 Apr 2010 at 8:49

GoogleCodeExporter commented 9 years ago
Fixed in trunk

Original comment by bar...@gmail.com on 29 Apr 2010 at 10:36

GoogleCodeExporter commented 9 years ago
Thanks.
When would this be available for the public?
Would the http://snapshot.microemu.org/ version be dependable upon?

Original comment by jacob.nordfalk on 30 Apr 2010 at 11:24

GoogleCodeExporter commented 9 years ago
http://snapshot.microemu.org/ is available the day after the fix, so in that 
case it
is available now.

Original comment by bar...@gmail.com on 30 Apr 2010 at 11:35