lvr123
lvr123

Reputation: 584

java subset supported by Codename One

I got several build errors on my very new Codename One application:

The build complains on the FileNotfoundException class and the String split() method. Any idea why ?

xxx\Page.java:11: error: cannot find symbol
import java.io.FileNotFoundException;
  symbol:   class FileNotFoundException
  location: package java.io

and

xxx\Page.java:97: error: cannot find symbol
            final String[] parts = number_label.split("-");
  symbol:   method split(String)
  location: variable number_label of type String

By the way, is that true that there is a restriction to use java 1.5 in CodenameOne ? I couldn't find where to say to compile with java 7.

Kind regards,

Upvotes: 1

Views: 192

Answers (1)

Shai Almog
Shai Almog

Reputation: 52760

EDIT: This reply is somewhat out of date. Codename One supports a subset of Java 8 now although string.split() is still a problematic API call.

Codename One supports a subset of Java 5, you shouldn't try and change that since the server translation code relies on bytecode behaviors of the target Java 5 and only supports a very specific subset of the API.

The reasoning is simple, since Codename One has multiple VM implementations (iOS, Dalvik/ART, XMLVM/ParparVM, blackberry etc.) its really hard to test new stuff (e.g. newer bytecodes) and its really hard to add new API's in a way that will be totally cross platform. You can use StringUtils.split() to implement this functionality as well as StringTokenizer.

Limiting the API's also allows us to keep the executable efficient and small (relatively). Compared to a more full featured VM we are at least 5 times smaller in production. This is a big deal for mobile apps...

We are working on consolidating the various VM's on the server side which will allow us to add core VM API's more easily in the future as well as features like Java 8 support.

You can learn more in this answer: How does Codename One work?

Upvotes: 1

Related Questions