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


Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.


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?

 

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.