07-30-2008 06:17 PM - edited 07-30-2008 06:31 PM
We have been building our application using JDE 4.3 and so far it has worked fine on handhelds with software versions 4.2x and 4.3x. In the next release of our app, we would like to use couple of JDE 4.3 specific methods while still supporting 4.2x handhelds. I thought about using if condition around these special method calls, so that they get invoked only if the software version at runtime is 4.3x or better. While searching through this forum recently, I found out that a COD file buit using a specific JDE version MAY NOT work on handhelds running other version of the OS software. Does this mean we are required to maintain seperate source files for each OS version we are intending to support?
I could use the Java equivalant of C++'s [ifdef] nightmare. (http://weblogs.java.net/blog/schaefa/archive/2005
Having seperate source file copies seems to be the only other approach, which will adversly affect the maintainability of the application.
Is there any other recommended approach to deal with this situation?
Thanks in advance...
07-30-2008 07:52 PM - edited 07-30-2008 07:53 PM
Thanks. Can't figure out how I missed that. Your solutions seems to be one of the best options currently available. Kudos!
I am really curious to know what is RIM's recommended way to handle this situation. I am sure they face this problem more often than we do
07-31-2008 01:19 AM
How about a class Factory? Its a bit more boilerplate code, but you can avoid scripting.
Include the appropriate concrete classes in the associated JDE projects. For instance, you want to determine if the device has a camera:
DeviceCaps caps = DeviceCaps.getCaps();
if ( caps.hasCamera() )
///DeviceCaps.java - include this in all projects
public abstract class DeviceCaps
public abstract boolean hasCamera();
public static DeviceCaps getCaps()
DeviceCaps ret = null;
// do magic to get firmware version... ( using a double for simplicity...)
double version = 4.2;
// flesh these out for each of your suported firmwares....
if ( version >= 4.2 )
return (DeviceCaps) Class.forName("DeviceCaps42" ).newInstance();
else if ( version < 4.2 )
return (DeviceCaps) Class.forName("DeviceCaps40" ).newInstance();
/// DeviceCaps40.java (include this on JDE 4.0.X)
public class DeviceCaps40 extends DeviceCaps
public boolean hasCamera()
/// DevceCaps42.java (include this on JDE 4.2.X projects)
public class DeviceCaps42 extends DeviceCaps
public boolean hasCamera()
05-21-2010 06:30 AM
I tested with Class.forname() as suggested.
However, it does not work.
When application starts, BB will load all class included in COD file and it will raise Class XXX not found exception.
So I choose to use preprocessor