0 Replies Latest reply on Sep 15, 2009 2:20 PM by shivkumar.ms

    how to Modify j2me class file without preverification


      Hi All,
      I am using Javassist to modify a MIDlet class. I was successfully able to change the midlet class file and view the changes in Bytecode Viewer.

      But when i try to run the application with WTK emulator it gives me an error as follows:

      Error verifying method com/test/TestApp commandAction(Ljavax/microedition/lcdui/Command;Ljavax/microedition/lcdui/Displayable;)V
      Approximate bytecode offset 9: Inconsistent or missing stackmap at target
      Method............: 10233084 'com/sun/midp/midlet/MIDletState.createMIDlet (static)'

      I tried calling the following methods at the end to see if it fixes the problem but it didnt
      1) methods.getMethodInfo().rebuildStackMap(classPool) on all the methods of the midlet class
      2) CtClass.rebuildClassFile() but didnt help.

      If I run preverification on jar with the modified class files in it and then run the application in the simulator, i am able to run it. I am guessing that the preverification tool rebuilt the stackmap and hence i could run the midlet in the simulator.

      My question is there any way to modify j2me class files without having to run preverification ?