J2ME Application Error

R

Raffi

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);
}
}
}
-------------------------------------------------------------------------------
 
C

Chris Uppal

Raffi said:
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
 
R

Raffi

Paul said:
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.
 
R

Raffi

Chris said:
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
 
C

Chris Uppal

Raffi said:
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
 
R

Rogan Dawes

Raffi said:
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
 
R

Raffi

Rogan said:
Raffi said:
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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top