Dims
Dims

Reputation: 163

J2ME obfuscated app stacktrace

I'm debugging J2ME (written in eclipse) code on nokia N95 (wasn't written by me) trying to find error and printing out stacktrace gave me this:

  03:08:479 TSKR. Error:
  java.lang.NullPointerException:   0
 - java.lang.String.<init>(), bci=6
  - v.b(), bci=9
 - v.e(), bci=805
 - v.e(), bci=3

Could anyone please help me to understand that? Which line , where to look for and is there a way to understand it or at least get some valuable and usefull information. Thank you

UPDATE

Sorry.. Here's the function that throws error:

public void     bluetoothFileProcessBytes(){//--------tracing out of memory error
    try{

    partCurrentLoop++;          
    fileCurrentLoop++;

    debug("Loop " + fileCurrentLoop + " of " + fileTotalLoops);

    bluetoothUpdateBytes(fileDataString.length());  
    guiUpdateProgressBar(true, partCurrentLoop, partTotalLoops);

    // LOOP Step 2: If there is no byte[] created for storing the bytes, create it. 

    if (fileBytesIsEmpty) {

        if (partCurrentNumber == partTotalNumber)
        {
            fileBytes = new byte[fileSize % (loopsPerHttpComm * BYTES_PER_LOOP)];
        }
        else    fileBytes = new byte[loopsPerHttpComm * BYTES_PER_LOOP];                    


    }   
    fileBytesIsEmpty = false;


    //LOOP Step 3: fill in the byte array with data from StringBuffer


    for (int i = 0; i < fileDataString.length(); i++) 
    {
         j = i + (partCurrentLoop - 1) * BYTES_PER_LOOP;
         c = fileDataString.charAt(i);              
         fileBytes[j] = (byte) c;   
    }
    c=0;
    j=0;
    i=0;

    //LOOP Step 4: Send the email if the byte array is full with a new HttpComm Thread

    if ((fileCurrentLoop % loopsPerHttpComm == 0
            || fileCurrentLoop == fileTotalLoops) && checkHttpCommStatus()) {


        // update partName and httpCommStatus
        String partName = fileName + " .part " + partCurrentNumber;             

        httpCommStatus = HTTP_RUNNING;

        if (fileCurrentLoop == fileTotalLoops) {        // FILE_END                 
            debug("New HttpComm Thread: FILE END"); 

            httpCommUpdateBytes(fileBytes.length);//<===================remove
            httpCommSucceeded();//<====================================remove



    /*new Thread(new HttpFileEnd(this, fileBytes, toAddress, fromAddress, fromName, digidownMAC,    partName, fileName, fileSize, digidownSoftwareVersion, partCurrentNumber, //<===============uncomment
                    partTotalNumber, DigidownApp.textObject.getActiveLanguage())).start();*/


        } else {                                    // FILE_PART


            //debug("Step 5");//<--------------------------------------------------------------------------------<-remove
        debug("New HttpComm Thread: FILE PART: " + partName);
        debug(">>>>>SEEEENDIIIING!<<<<<<<<");//<===========remove
        httpCommUpdateBytes(fileBytes.length);//<================remove
        httpCommSucceeded();//<==============================remove

/*new Thread(new HttpFilePart(this, fileBytes, toAddress, fromAddress, fromName,//<===============uncomment
                    digidownMAC, partName, fileSize, digidownSoftwareVersion,
                    partCurrentNumber, DigidownApp.textObject.getActiveLanguage())).start();*/  


    // Updating the new partTotalLoops
    if (partCurrentNumber == partTotalNumber){
partTotalLoops = fileTotalLoops - (loopsPerHttpComm * (partCurrentNumber - 1));             
            } else partTotalLoops = loopsPerHttpComm;


            partCurrentNumber++;
            partCurrentLoop = 0;
        }
        fileBytesIsEmpty = true;
        }

    // Leave the loop if failed 
    if (!errorHandlerActivated) {

        if (fileCurrentLoop < fileTotalLoops)
        {

        try{
        bluetoothIOStream.getFileBytes();//-throws null pointer exception !
        }catch(RuntimeException  ea){debug("Wammaaa!!! " + ea.toString());
                      ea.printStackTrace();}

        }
        else if(fileCurrentLoop == fileTotalLoops && checkHttpCommStatus())
                    {   bluetoothIOStream.getFileEnd(); }
    }
    }



    catch(RuntimeException e1)
    {
    Alert alert = new Alert("Fckn error!", e1.toString(), null, null);
    alert.setTimeout(Alert.FOREVER);
    debug("Error:");
    System.err.println();
    e1.printStackTrace();
    //throw e1;

    }
}

..and the stack trace of unobfuscated app; this time it was null pointer exception after // Leave the loop if failed:

02:57:382 TSKR. Loop 972 of 1349
02:57:383 BIOS. Rec 978
02:57:588 TSKR. Loop 973 of 1349
02:57:590 BIOS. Rec 979
02:57:815 TSKR. Wammaaa!!! java.lang.NullPointerException:   0
java.lang.NullPointerException:   0
 - java.lang.String.<init>(), bci=6
 - net.digidown.m.digidown.bluetooth.BluetoothIOStream.readLineAsString(), bci=9
 - net.digidown.m.digidown.bluetooth.BluetoothIOStream.getVariable(), bci=844
 - net.digidown.m.digidown.bluetooth.BluetoothIOStream.getFileBytes(), bci=3
 - net.digidown.m.digidown.TaskRunner.bluetoothFileProcessBytes(), bci=430
 - net.digidown.m.digidown.bluetooth.BluetoothIOStream.getVariable(), bci=857
 - net.digidown.m.digidown.bluetooth.BluetoothIOStream.getFileBytes(), bci=3
 - net.digidown.m.digidown.TaskRunner.bluetoothFileProcessBytes(), bci=430
 - net.digidown.m.digidown.bluetooth.BluetoothIOStream.getVariable(), bci=857
 - net.digidown.m.digidown.bluetooth.BluetoothIOStream.getFileBytes(), bci=3
 - net.digidown.m.digidown.TaskRunner.bluetoothFileProcessBytes(), bci=430
 - net.digidown.m.digidown.bluetooth.BluetoothIOStream.getVariable(), bci=857
 - net.digidown.m.digidown.bluetooth.BluetoothIOStream.getFileBytes(), bci=3
 - net.digidown.m.digidown.TaskRunner.bluetoothFileProcessBytes(), bci=430
 - net.digidown.m.digidown.bluetooth.BluetoothIOStream.getVariable(), bci=857

Goes like that for a while and then..:

 - net.digidown.m.digidown.TaskRunner.bluetoothDoCommand_file(), bci=227
 - net.digidown.m.digidown.bluetooth.BluetoothIOStream.getVariable(), bci=829
 - net.digidown.m.digidown.bluetooth.BluetoothIOStream.getFileSettings(), bci=9
 - net.digidown.m.digidown.TaskRunner.bluetoothTask(), bci=90
 - net.digidown.m.digidown.bluetooth.BluetoothIOStream.getVariable(), bci=513
 - net.digidown.m.digidown.bluetooth.BluetoothIOStream.getTask(), bci=2
 - net.digidown.m.digidown.TaskRunner.bluetoothTask(), bci=172
 - net.digidown.m.digidown.bluetooth.BluetoothIOStream.getVariable(), bci=513
 - net.digidown.m.digidown.bluetooth.BluetoothIOStream.getTask(), bci=2
 - net.digidown.m.digidown.TaskRunner.bluetoothConnected(), bci=89
 - net.digidown.m.digidown.bluetooth.BluetoothIOStream.getVariable(), bci=444
 - net.digidown.m.digidown.bluetooth.BluetoothIOStream.getVariable(), bci=426
 - net.digidown.m.digidown.bluetooth.BluetoothIOStream.run(), bci=366
 - java.lang.Thread.run(), bci=11
03:01:211 TSKR. Finished Task
03:01:212 BIOS. Rec 6
03:01:356 BIOS. task = >
03:01:357 TSKR. :: Got Task: (0x3e)
03:01:358 TSKR.  
03:01:359 TSKR. ERROR HANDLER: 116 - Bluetooth communication error
03:01:389 BIOS. Initiated
03:01:389 BIOS. About to read
03:01:394 BIOS. Phone(InitiateDigidownError) received: '0x3e 0xea Data CK'
03:01:397 BIOS. About to writeLine 'error' 
03:01:468 BIOS. quitStatus = QUIT_STATUS

Upvotes: 2

Views: 243

Answers (2)

Saeed
Saeed

Reputation: 166

Your problem may be solve in two ways:

  1. Run your application without obfuscation. So the output shows exact method names.
  2. Put System.out.println('method_name::sample_tag') in your method and lines that the problem may be from them. Then in the output you can trace your execution and you can find the point that the problem occurs.

Upvotes: 1

michael aubert
michael aubert

Reputation: 6826

Your problem seems to be obfuscation.

The build process of your eclipse application probably uses a tool like proguard to increase the performance and decrease the size of the application .jar file that will be deployed in the field.

One of the thing obfuscation does is rewrite class and method names into much smaller names, hence the completely unintelligible last 3 lines of your stack trace.

You need to produce an unobfuscated .jar file to use when you want to debug your application.
(at least until you find an issue that only happens on the obfuscated version of your application. it happens)

Eclipse should allow you to turn obfuscation off (or reduce it to its lowest level) by modifying your project properties. Failing that, manually and temporarily hacking the ant .xml files used to build your .jar file will do the trick.

Obfuscation parameters should include the name of your MIDlet class so that its startApp() method is not renamed.

Upvotes: 2

Related Questions