Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Developer
Posts: 52
Registered: ‎07-17-2008
My Device: Not Specified

RuntimeStore is returning an invalid object

Here's the code snipped where we are seeing the problem:

 

public Foo getInstance() { Object obj = null; RuntimeStore store = null; try { store = RuntimeStore.getRuntimeStore(); obj = store.get(rtsId); } catch (ControlledAccessException e) { _log.error("No permission", e); } if (obj == null ) { Foo foo = new Foo(); if (store != null) { store.replace(RTS_ID, foo); return (Foo) store.get(RTS_ID); } return manager; } else { return (Foo) obj; } }

 

 (Multiple exit points, ControlleAccessExcpetion is not handled properly,...  I know, I know... the code is not great.  Point taken, we will refactor it.  But, none of those flaws should cause the problem I am going to explain below)

 

This code has worked just fine on many many BB models/OS versions. However, on Bold running OS software 4.6.0.167, this method throws ClassCastException.  We have other Bolds with same exact OS version that run my app perfectly fine.

 

Could anybody explain how ClassCastException can possibly happen in this method?

 

Thanks in advance! 

 

Developer
Posts: 1,415
Registered: ‎07-30-2008
My Device: Not Specified

Re: RuntimeStore is returning an invalid object

It may help if you ask it what it thinks the thing is ( use get class and name, print with error). Sometimes

in one app I get a null byte[] coming back after modifying some ( apparently unrelated ) code- it is

always one particular object and I suspect it is a latent bug/threading problem in my code but this

always resolves on reloading the questionable object. Not sure if this should happen but only seems

to happen with code changes, haven't seen any problems in another app.

 

Did you uninstall and try again?

Developer
Posts: 52
Registered: ‎07-17-2008
My Device: Not Specified

Re: RuntimeStore is returning an invalid object

I have had similar issues while dealing with PersistentObject.  Of course, in those cases the root cause was changed object structure. Uninstalling the app and reinstalling would solve the problem.

 

However, the situation I am facing right now is quite different. Even after the user rebooted the device (by pulling the battery), ClassCastException did not go away. When the device comes back up, there shouldn't be a random object by that ID in the runtime store (as I understand, runtime store gets recycled upon device reboot).  So this doesn't make sense at all.

 

 

Developer
Posts: 1,415
Registered: ‎07-30-2008
My Device: Not Specified

Re: RuntimeStore is returning an invalid object

Did you print out the class? What does it think it is? If you have some accidental stuff or changed a package name

etc it should be obvious. In any case what does it think?

 

Highlighted
Developer
Posts: 52
Registered: ‎07-17-2008
My Device: Not Specified

Re: RuntimeStore is returning an invalid object

... waiting for the logs from the user to figure this out.