Menu

Java 5/6/7 language on MIDP

A new subproject of GUMP uses GUMP technology to port Java bytecode generated from Java 5, 6 or 7 sourcecode into a format capable of execution on a CLDC VM (and so is usable on MIDP devices).

"New For ME"

New Java 5/6/7 features on Java ME (CLDC/MIDP). Mainly, support for new language features, but also one or two extras to make life a little easier. Main aims:

  • Make developing on Java ME a little less painful
  • Assist code sharing between Java ME and platforms such as Java SE and Android

You get:

  • New language features:
    • Generics
    • Auto-boxing and unboxing
    • Enums
    • New for-each loop syntax on arrays, Vector, Hashtable.keySet() and Hashtable.values()
    • Variable length argument lists
    • Strings in switch
    • try with AutoClose
    • try with multicatch
    • @Override annotation
  • Additional classes, such as:
    • java.io.BufferedReader
  • Additional methods, such as:
    • String.replace(String, String)

You need to:

  1. Build portlib
  2. Build GUMP
  3. Build the NewForME compile-time library
    • you need to compile your code against this before conversion
    • you can use this in the IDE to ensure you use compatible features
  4. See the test/ folder for an example conversion project
    • converted code will run on CDC or CLDC

Before, you wrote:

Vector v = new Vector();
v.addElement(new Integer(1));
v.addElement(new Integer(2));
v.addElement(new Integer(3));
v.addElement(new Integer(4));
for (Enumeration en = v.elements(); en.hasMoreElements(); ) {
    System.out.println(((Integer) en.nextElement()).intValue());
}

Now, you can write:

Vector<Integer> v = new Vector<>();
v.add(1);
v.add(2);
v.add(3);
v.add(4);
for (int i : v) {
    System.out.println(i);
}
Posted by Graham Hughes 2013-03-13

Log in to post a comment.