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[i]);
}
catch (Exception e)
{
System.out.println("Error - " + e);
}
}
}
-------------------------------------------------------------------------------
Chris Uppal - 28 Jun 2006 10:29 GMT
> 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
Raffi - 29 Jun 2006 08:20 GMT
> > 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
[quoted text clipped - 8 lines]
>
> -- 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
Chris Uppal - 29 Jun 2006 11:52 GMT
> 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
Paul Hamaker - 28 Jun 2006 11:02 GMT
Guess it's a Motorola bug, did you try other phones ?
Raffi - 29 Jun 2006 08:11 GMT
> 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.
Rogan Dawes - 29 Jun 2006 12:11 GMT
> Hi Folks,
>
[quoted text clipped - 30 lines]
> }
> -------------------------------------------------------------------------------
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
Raffi - 29 Jun 2006 21:56 GMT
> > Hi Folks,
> >
[quoted text clipped - 39 lines]
>
> 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