J2ME Application Error

Discussion in 'Java' started by Raffi, Jun 28, 2006.

  1. Raffi

    Raffi Guest

    Hi Folks,

    I have the Class below for deleting all record stores for a MIDLet.

    It works fine with the SUN wireless toolkit as well as the IBM J9 VM,
    but throws an application error on a Motorola V551 phone. If I replace
    "names.length" with the actual count of the record stores, it works
    fine. Am I doing something wrong? If not and this is a limitation of
    the VM the phone uses, are there other ways to get the array length
    besides "names.length"?

    Thanks,
    Raffi

    Code-----------------------------------------------------------------------
    public void deleteAllRMS()
    {

    names = RecordStore.listRecordStores();
    int count = names.length;

    for (int i = 0; i < count; ++i)
    {
    try
    {
    RecordStore.deleteRecordStore(names);
    }
    catch (Exception e)
    {
    System.out.println("Error - " + e);
    }
    }
    }
    -------------------------------------------------------------------------------
    Raffi, Jun 28, 2006
    #1
    1. Advertising

  2. Raffi

    Chris Uppal Guest

    Raffi wrote:

    > It works fine with the SUN wireless toolkit as well as the IBM J9 VM,
    > but throws an application error on a Motorola V551 phone. If I replace
    > "names.length" with the actual count of the record stores, it works
    > fine.


    I know nothing about J2ME, but from what you say, either the JVM is so badly
    screwed that it doesn't know how long an array is -- which seems unlikely -- or
    the Motorola implementation has entries in the array which are not legal
    arguments to deleteRecordStore(). I'd try putting check for null into the loop
    and see what happens.

    -- chris
    Chris Uppal, Jun 28, 2006
    #2
    1. Advertising

  3. Raffi

    Paul Hamaker Guest

    Guess it's a Motorola bug, did you try other phones ?
    Paul Hamaker, Jun 28, 2006
    #3
  4. Raffi

    Raffi Guest

    Paul Hamaker wrote:
    > Guess it's a Motorola bug, did you try other phones ?


    Not yet. Code that doesn't run on Motorola phones won't fly since there
    are so many of them out there.
    Raffi, Jun 29, 2006
    #4
  5. Raffi

    Raffi Guest

    Chris Uppal wrote:
    > Raffi wrote:
    >
    > > It works fine with the SUN wireless toolkit as well as the IBM J9 VM,
    > > but throws an application error on a Motorola V551 phone. If I replace
    > > "names.length" with the actual count of the record stores, it works
    > > fine.

    >
    > I know nothing about J2ME, but from what you say, either the JVM is so badly
    > screwed that it doesn't know how long an array is -- which seems unlikely -- or
    > the Motorola implementation has entries in the array which are not legal
    > arguments to deleteRecordStore(). I'd try putting check for null into the loop
    > and see what happens.
    >
    > -- chris


    The deleteRecordStore() method is not the problem since when I enter
    the array length manually in the code, the class works fine. It's when
    it tries to get the array length from the method that it throws the
    application error.

    I've already tried your suggestion and on the emulator both
    array.length and a do-while loop with a null check give the same result
    for the array length. I have since re-written the class to use a
    do-while loop which does work on all the platforms available for me.
    The only problem with a do-while loop is for it to exit, an array out
    of bounds exception is thrown. I've hacked around that by ignoring the
    error (I know - not a good idea but it's the only solution right now).

    If anybody else has a suggestion please post it.

    Thanks,
    Raffi
    Raffi, Jun 29, 2006
    #5
  6. Raffi

    Chris Uppal Guest

    Raffi wrote:

    > The deleteRecordStore() method is not the problem since when I enter
    > the array length manually in the code, the class works fine. It's when
    > it tries to get the array length from the method that it throws the
    > application error.


    Eek ! Then that Java implementation has a /really/ serious bug. Expect to
    find more...

    -- chris
    Chris Uppal, Jun 29, 2006
    #6
  7. Raffi

    Rogan Dawes Guest

    Raffi wrote:
    > Hi Folks,
    >
    > I have the Class below for deleting all record stores for a MIDLet.
    >
    > It works fine with the SUN wireless toolkit as well as the IBM J9 VM,
    > but throws an application error on a Motorola V551 phone. If I replace
    > "names.length" with the actual count of the record stores, it works
    > fine. Am I doing something wrong? If not and this is a limitation of
    > the VM the phone uses, are there other ways to get the array length
    > besides "names.length"?
    >
    > Thanks,
    > Raffi
    >
    > Code-----------------------------------------------------------------------
    > public void deleteAllRMS()
    > {
    >
    > names = RecordStore.listRecordStores();
    > int count = names.length;
    >
    > for (int i = 0; i < count; ++i)
    > {
    > try
    > {
    > RecordStore.deleteRecordStore(names);
    > }
    > catch (Exception e)
    > {
    > System.out.println("Error - " + e);
    > }
    > }
    > }
    > -------------------------------------------------------------------------------
    >


    How are you deciding on the length of names, to manually put it in your
    code?

    Can you see what names.length actually is on the hardware?


    And, exactly what error does it throw?

    Rogan
    Rogan Dawes, Jun 29, 2006
    #7
  8. Raffi

    Raffi Guest

    Rogan Dawes wrote:
    > Raffi wrote:
    > > Hi Folks,
    > >
    > > I have the Class below for deleting all record stores for a MIDLet.
    > >
    > > It works fine with the SUN wireless toolkit as well as the IBM J9 VM,
    > > but throws an application error on a Motorola V551 phone. If I replace
    > > "names.length" with the actual count of the record stores, it works
    > > fine. Am I doing something wrong? If not and this is a limitation of
    > > the VM the phone uses, are there other ways to get the array length
    > > besides "names.length"?
    > >
    > > Thanks,
    > > Raffi
    > >
    > > Code-----------------------------------------------------------------------
    > > public void deleteAllRMS()
    > > {
    > >
    > > names = RecordStore.listRecordStores();
    > > int count = names.length;
    > >
    > > for (int i = 0; i < count; ++i)
    > > {
    > > try
    > > {
    > > RecordStore.deleteRecordStore(names);
    > > }
    > > catch (Exception e)
    > > {
    > > System.out.println("Error - " + e);
    > > }
    > > }
    > > }
    > > -------------------------------------------------------------------------------
    > >

    >
    > How are you deciding on the length of names, to manually put it in your
    > code?
    >
    > Can you see what names.length actually is on the hardware?
    >
    >
    > And, exactly what error does it throw?
    >
    > Rogan


    The Class generates a number of record stores which are used by
    defferent Classes for data entry. For testing I statically populate the
    record stores and know how many there are and what their content is. So
    I substitute the number of recurd stores in the place of names.length.

    The MIDLet installs fine on the V551 but throws an "Application Error"
    alert when run.

    Raffi
    Raffi, Jun 29, 2006
    #8
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Damian
    Replies:
    3
    Views:
    12,484
    Jim Cheshire [MSFT]
    Dec 30, 2003
  2. robin
    Replies:
    0
    Views:
    844
    robin
    Jul 20, 2003
  3. Boldra
    Replies:
    0
    Views:
    1,264
    Boldra
    Dec 3, 2003
  4. Markus
    Replies:
    4
    Views:
    1,769
    Darryl Pierce
    Feb 12, 2005
  5. nishadixit
    Replies:
    5
    Views:
    1,235
    Joe Discar
    Jun 1, 2005
Loading...

Share This Page