Reputation: 11
I am newbie in Java, I am trying to adjust the output classes generated by JASN1 OpenMUC compiler (for java 1.5+) to run it on a BGS5 CLDC 1.1 platform. Most basic classes have been altered and compiled successfully but there remains an issue regarding the using of parametrised List or collection class. It is used on one of basic class and used severely in most of the produced classes. and it is not supported by the CLDC 1.1 device's java libraries.
My question has two branches:
A sample of a targeted class containing the parametrised List member is:
//This class file was automatically generated by jASN1 v1.6.0 (http://www.openmuc.org)
package MyPackage;
import java.util.List;
import java.util.ArrayList;
import java.util.Iterator;
// those packages are not available
public class DeviceInputOutputStatus {
public List<IOStatus> seqOf = null;
//IOStatus is a class of the package
public DeviceInputOutputStatus () {
seqOf = new ArrayList<IOStatus>();
}
public int encode(BerByteArrayOutputStream os) throws IOException
{
int codeLength = 0;
for (int i = (seqOf.size() - 1); i >= 0; i--) {
codeLength += seqOf.get(i).encode(os, true);
//encode is a method of IOStatus
}
return codeLength;
}
}
Upvotes: 1
Views: 110
Reputation: 1978
You will have to modify all of your generated code to not use generics. More than that, to not use any of the collections classes, since they are not supported in JavaME CLDC 1.1.
You can think of this as a two-step process. First, get rid of the use of generics. To eliminate the generics, you would use just plain List (no angle brackets following), and then add casts (from Object to IOStatus or whatever) where needed (e.g. whenever you get objects out of the list).
Step two: replace List with Vector. You will have to compare the documentation for the two classes and adjust your code accordingly.
Tip (probably you know this already): use javac's -bootclasspath option to point your compiler to the CLDC 1.1 class library to ensure that you don't use API that are not supported and -source 1.3 and -target 1.3 to ensure your source is compatible and that you produce compatible byte code.
Upvotes: 1