J2ME - Inconsistent or missing stackmap at target

M

Marcel Malitz

Hi all.
Short and simple code with a strange mistake in it or not. I hope you
can help me.
I am writing something ;) in J2ME. It?s a canvas class which will be
used in a midlet.
At the end of this message you can see the error message.
There is something with the keyReleased methode. Without the methode
it?s running fine.
I know you will only see a huhu in console and not in display, but it
should run without an error.
Thanks for your help.

Regards,
Marcel

public class DigiPairCanvas extends Canvas {

private Graphics graphics;

public DigiPairCanvas(Display display) {
}

public void keyReleased(int keyCode) {
if (keyCode == KEY_NUM0) System.out.println("huhu");
}

protected void paint(Graphics graphics) {
}
}

Error message:
Execution completed successfully
74842 bytecodes executed
8 thread switches
370 classes in the system (including system classes)
687 dynamic objects allocated (30360 bytes)
5 garbage collections (15460 bytes collected)
Total heap size 524288 bytes (currently 505292 bytes free)
Error verifying method a keyReleased(I)V
Approximate bytecode offset 3: Inconsistent or missing stackmap at
target
ALERT: Error verifying class a
 
D

Darryl L. Pierce,,,

Marcel Malitz wrote:
<snip>

You can't hold onto the Graphics context; bad mojo there. You should be
passing it around as needed from the paint() method.
public void keyReleased(int keyCode) {
if (keyCode == KEY_NUM0) System.out.println("huhu");
}

keyCode is a raw keycode value.KEY_NUM0 is a *game action*. You have to take
the keyCode value passed to the method and convert it into a game action
like this:

if(keyCode > 0 && getGameAction(keyCode) == KEY_NUM0)
{
System.out.println("huhu");
}

This should eliminate your error.
 
M

Marcel Malitz

Thanks for your help.
Your code looks nice but I found the problem. My code runs, yeah. :)
I created the wrong package.

Regards,
Marcel
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
473,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top