Menu

MidletPascal Beta1: Bug report

salavata
2010-01-13
2013-04-25
  • salavata

    salavata - 2010-01-13

    I did not find where can I send bug reports, so I write here:

    I have an application which worked well being compiled by MidletPascal 2.2.
    When I compiled it by MidletPascal 3 beta and tried to execute it, the following error occured:

    Running with storage root C:\Documents and Settings\1\j2mewtk\2.5.2\appdb\DefaultColorPhone
    Running with locale: Russian_Russia.1251
    Running in the identified_third_party security domain
    Method…………: 10233084 'com/sun/midp/midlet/MIDletState.createMIDlet (static)'
    Stack Chunk…….: 22700ac
    Frame Pointer…..: 2270104
    Current IP……..: 1033a48b = 1033a46e + offset 29
    Previous Frame….: 22700cc
    Previous IP…….: 103ce331 (offset 22)
    Frame size……..: 7 (1 arguments, 6 local variables)
    Argument…….: 2270910
    Local……….: 0
    Local……….: 23ee174
    Local……….: 2280120
    Local……….: 23ee188
    Local……….: 10274b20
    Local……….: 23ee154
    Operand……..: 246f814

    Method…………: 10295954 'com/sun/midp/midlet/Selector.run (virtual)'
    Stack Chunk…….: 22700ac
    Frame Pointer…..: 22700cc
    Current IP……..: 103ce331 = 103ce31b + offset 22
    Previous Frame….: 0
    Previous IP…….: 1
    Frame size……..: 6 (1 arguments, 5 local variables)
    Argument…….: 2270b18
    Local……….: 22801fc
    Local……….: 2270910
    Local……….: 0
    Local……….: 0
    Local……….: 0
    Operand……..: 22801fc

    VM status:
    Instruction pointer.: 1033a48b (offset within invoking method: 29)
    Next instruction….: 0x4c
    Frame pointer…….: 2270104
    Local pointer…….: 22700e8
    Stack size……….: 128; sp: 227011c; ranges: 22700b4-22702b4;
    Contents of the current stack frame:
        22700e8: 2270910 (lp)
        22700ec: 0
        22700f0: 23ee174
        22700f4: 2280120
        22700f8: 23ee188
        22700fc: 10274b20
        2270100: 23ee154
        2270104: 22700cc (fp)
        2270108: 103ce331
        227010c: 22700e4
        2270110: 10233084
        2270114: 22700ac
        2270118: 0 (end of frame)
        227011c: 246f814 (sp)
    Execution stack contains 108 items:
    2270b18 
    22801fc 
    2270910 





    23ee158 
    10295954 
    22700ac 

    22801fc 
    2270910 

    23ee174 
    2280120 
    23ee188 
    10274b20 
    23ee154 
    22700cc 
    103ce331 
    22700e4 
    10233084 
    22700ac 

    246f814 

    Execution completed.
    3409181 bytecodes executed
    80 thread switches
    1669 classes in the system (including system classes)
    17879 dynamic objects allocated (552288 bytes)
    2 garbage collections (462020 bytes collected)
    Execution completed.
    3409181 bytecodes executed
    ALERT: java/lang/ClassFormatError: Bad Utf8 string.

    80 thread switches
    1669 classes in the system (including system classes)
    17879 dynamic objects allocated (552288 bytes)
    2 garbage collections (462020 bytes collected)

    The source code of my application is the following:

    program NewProject;

    var label_id,itemId,j1,j2 : integer;

        cmdOk,cmdQuit,cmdEdit,cmdAddNew,cmdCancel,cmdDelete : command;

        parol,trueparol : string;

        rs : recordstore;

        zapname,zaptext : array of string;

        kolzap : integer;

        

    procedure LOADDATABASE;

    var nomzap : integer;

    begin

      if GetRecordStoreSize(rs)=0 then nomzap := AddRecordStoreEntry(rs, trueparol);

      kolzap:=(GetRecordStoreSize(rs)-1) div 2;

      for nomzap:=1 to kolzap do

      begin

        zapname:=ReadRecordStoreEntry(rs,nomzap*2);

        zaptext:=ReadRecordStoreEntry(rs,nomzap*2+1);

      end;

    end;

    procedure SAVEDATABASE;

    var i,nomzap : integer;

    begin

      CloseRecordStore(rs);

      DeleteRecordStore('Count');

      rs := OpenRecordStore('Count');

      i := AddRecordStoreEntry(rs, trueparol);

      kolzap:=(GetRecordStoreSize(rs)-1) div 2;

      for nomzap:=1 to kolzap do

      begin

        i := AddRecordStoreEntry(rs, zapname);

        i := AddRecordStoreEntry(rs, zaptext);

      end;

    end;

    procedure EDITZAP (nomer:integer);

      var textField_id1,textField_id2 : integer;

          text1,text2 : string;

          comm : command;

    begin

      ClearForm;

      ShowForm;

      SetFormTitle('Редактирование');

      AddCommand(cmdCancel);

      AddCommand(cmdOk);

      text1:=zapname;

      text2:=zaptext;

      textField_id1 := FormAddTextField('Название записи', text1, 20, TF_ANY);

      textField_id2 := FormAddTextField('Текст записи', text2, 200, TF_ANY);

      repeat comm:=GetClickedCommand until (comm=cmdCancel) or (comm=cmdOk);

      if comm=cmdOk then

      begin

        text1 := FormGetText(textField_id1);

        text2 := FormGetText(textField_id2);

        if text1='' then  text1:='Без имени';

        zapname:=text1;

        zaptext:=text2;

      end;

    end {EDITZAP};

    procedure ADDNEWZAP;

      var textField_id1,textField_id2 : integer;

          text1,text2 : string;

          comm : command;

    begin

      ClearForm;

      ShowForm;

      SetFormTitle('Новая запись');

      AddCommand(cmdCancel);

      AddCommand(cmdOk);

      textField_id1 := FormAddTextField('Название записи', '', 20, TF_ANY);

      textField_id2 := FormAddTextField('Текст записи', '', 200, TF_ANY);

      repeat

        delay(100);

        comm:=GetClickedCommand

      until (comm=cmdCancel) or (comm=cmdOk);

      if comm=cmdOk then

      begin

        text1 := FormGetText(textField_id1);

        text2 := FormGetText(textField_id2);

        if text1='' then  text1:='Без имени';

        kolzap:=kolzap+1;

        zapname:=text1;

        zaptext:=text2;

      end;

    end {ADDNEWZAP};

    procedure DELETEZAP (nomer:integer);

      var i : integer;

    begin

      for i:=nomer to kolzap-1 do

      begin

        zapname_:=zapname;

        zaptext:=zaptext;

      end;

      kolzap:=kolzap-1;

      showTextBox('title',IntegerToString(nomer),2000,TF_ANY);

    end {DELETEZAP};

    procedure MAINWORK;

      var nomzap,i,j,vibran: integer;

          comm : command;

    begin

      LOADDATABASE;

      repeat

        ShowMenu('Выберите запись', CH_IMPLICIT);

        for nomzap:=1 to kolzap do

        begin

           j := menuAppendString(zapname);

        end;

        if kolzap=0 then j:=menuAppendString('Добавить новую запись');

        AddCommand(cmdQuit);

        if kolzap>0 then AddCommand(cmdEdit);

        AddCommand(cmdAddNew);

        if kolzap>0 then AddCommand(cmdDelete);

        repeat

          delay(100);

          comm:=GetClickedCommand

        until (comm=cmdQuit) or (comm=cmdEdit) or (comm=cmdAddNew) or (comm=cmdDelete);

        vibran:=MenuGetSelectedIndex+1;

        if comm=cmdEdit then

          if kolzap=0 then ADDNEWZAP else EDITZAP(vibran);

        if comm=cmdAddNew then ADDNEWZAP;

        if comm=cmdDelete then

          begin

            DELETEZAP(vibran);

          end;

      until comm = cmdQuit;  

      SAVEDATABASE;

    end;

    function DEC2HEX(s:string):string;

      var i,m:integer; s16:string;

          a16:array of char;

    begin

      a16:='0';

      a16:='1';

      a16:='2';

      a16:='3';

      a16:='4';

      a16:='5';

      a16:='6';

      a16:='7';

      a16:='8';

      a16:='9';

      a16:='A';

      a16:='B';

      a16:='C';

      a16:='D';

      a16:='E';

      a16:='F';

      s16:='';

      i:=StringToInteger(s);

      repeat

        m:=i mod 16;

        s16:=a16+s16;

        i:=i div 16;

      until i=0;

      dec2hex:=s16;

    end;

    begin

      rs := OpenRecordStore('Count');

      cmdOk := CreateCommand('Готово', CM_OK, 1);

      cmdEdit := CreateCommand('Изменить', CM_ITEM, 1);

      cmdQuit := CreateCommand('Выйти', CM_EXIT, 1);

      cmdAddNew := CreateCommand('Создать', CM_SCREEN, 1);

      cmdCancel := CreateCommand('Отмена', CM_CANCEL, 1);

      cmdDelete := CreateCommand('Удалить', CM_SCREEN, 1);

      ShowForm;

      AddCommand(cmdOk);

      if GetRecordStoreSize(rs) = 0 {store is empty}

       then

        begin

          SetFormTitle('Надо дважды ввести одинаковое число.');

          itemId := FormAddTextField('Введите целое число', '', 20, TF_NUMERIC);

          repeat until GetClickedCommand = cmdOk;

          trueparol := FormGetText(itemId);

        end

       else trueparol:=ReadRecordStoreEntry(rs,1);

      itemId := FormAddTextField('Введите целое число', '', 20, TF_NUMERIC);

      repeat until GetClickedCommand = cmdOk;

      parol := FormGetText(itemId);

      if parol=trueparol

        then MAINWORK

        else begin

              ShowCanvas;

              DrawText('Число ' + parol, 0, 0);

              DrawText('в шестнадцатеричной системе', 0, 20);

              DrawText('равно ' + DEC2HEX(parol), 0, 40);

              AddCommand(cmdQuit);

              Repaint;

              repeat until GetClickedCommand = cmdQuit;  

             end;

      CloseRecordStore(rs);  

    end.
    _

     
  • wesw

    wesw - 2010-01-13

    Thanks for the report. We are still at alpha/beta stages, so it is a bit too early to set up bug tracking.

    I'm still getting up to speed on the compiler, but the message:
    ALERT: java/lang/ClassFormatError: Bad Utf8 string.
    suggests that your Russian(?) strings may contain 8 bit characters.

    The current compiler only supports a 7 bit character set, and does not have any detection of invalid characters, or the ability to convert to valid Utf8. I think I may have seen something about not supporting Russian at boolean.com.

    I'm currently converting the compiler into Pascal source, and proper utf8 conversion will be listed to be added at a later date. MP2.02 may have had this conversion in a pre-compiler parser, or in a post-compiler class file verifier.

    Meanwhile, you could try converting your strings to valid Utf8. Its explained in detail at wikipedia http://en.wikipedia.org/wiki/UTF-8 and many other places on the net.

     
  • Javier Santo Domingo

    Salavata: Sorry for the delay. Could you please post the .mpproj file contents also? So I can test your code with the same Project Settings (Build Configuration) that you use.

    Wes: Thanks for replying, and good luck with the compiler conversion!

     

Log in to post a comment.