InterruptedException bringing up NullPointerException in printStacktrace j2me

1.1k views Asked by At

I'm dealing with a midlet in j2me, and I have this thread class (say called chan) which only does the following:

public class Chan extends Thread {

    public void run(){
        try {
            Thread.sleep(5000);
        } catch (InterruptedException ex) {
          System.err.println("Chan thread woke up " + ex.toString());
                    ex.printStackTrace();
           System.err.println("Stacktrace end");
        }
    }
}

And i'm trying a chan.interrupt(); from the main midlet code which only does the following:

public void startApp() {

    Chan ch = new Chan();
    ch.start();

    try {
        Thread.sleep(1000);
    } catch (InterruptedException ex) {
        System.err.println("error interrupting: "+ ex.toString());
        ex.printStackTrace();
    }
    ch.interrupt();
}

What I'm receiving is this:

Chan thread woke up java.lang.InterruptedException  
java.lang.InterruptedException  
java.lang.NullPointerException
    at org.netbeans.mobility.antext.StackTraceTranslator.getLineNumber(StackTraceTranslator.java:219)
    at org.netbeans.mobility.antext.StackTraceTranslator.translate(StackTraceTranslator.java:121)
    at org.netbeans.mobility.antext.RunTask$StackTraceTranslatorHandler$1.flush(RunTask.java:780)
    at org.netbeans.mobility.antext.RunTask$StackTraceTranslatorHandler$1.run(RunTask.java:826)
    at java.lang.Thread.run(Thread.java:722)`

the line mentioned is within the run method of Thread:

public void run() {
    if (target != null) {
        target.run(); <-- 722nd line 
    }
}

Everything seems to be operating fine in the program other than the weird stacktrace. If I just delete the printStacktrace in Chan thread, no such nullpointerException is printed.

So I don't understand what this nullpointerexception is trying to tell me, nor why the stacktrace for the interruptedexception is 1 line and the rest of the trace is missing.

The emulator is Oracle Java(TM) Platform Micro Edition SDK 3.0.5 and I'm working on Netbeans

1

There are 1 answers

1
Joe Daley On BEST ANSWER

This is a bug in Netbeans:

http://netbeans.org/bugzilla/show_bug.cgi?id=170792

It has been resolved, so try upgrading to the latest version of Netbeans.