This is just something I hope is a simple question but having not had a lot of mobile experience yet I don't yet know.
I wanted to understand the relationship between the different versions of JavaSE and the JavaME CLDC and CDC platforms. In JavaSE new language level features have been introduced (i.e. not tied into the Java Libraries). Generally Java has been created in such a way that newer language features are compiled such that the generated byte-code is byte-code compatible with older VMs. I don't know if CLDC and CDC are based on a single fixed language version of JavaSE or that certain newer language features can be use as long as these are language only features (because these only matter at compile time anyway).
The reason I ask is that I have a project with some source code which I am trying to separate out into portions which should compile in JavaSE, JavaME CLDC and CDC. Many interfaces and such which just use the most core types like primitives and Strings etc should
be able to compile on all platforms.
I am not sure about such things as those introduced in Java 5 i.e. the enhanced for loop might work if it is compile time only (but this depends on whether JavaME is locked to one specific JavaSE language style). I would expect Generics and Enums would not work on mobile as new classes were introduced in JavaSE to allow for these to be supported. I am not sure if I am right or if these features may vary between CLDC and CDC given that CDC is much closer to desktop level Java.
In practice it makes the difference as to whether anything which uses enums and/or generics which is very useful for desktop Java must be categorised as desktop only source code whereby a mobile compatible implementation would have to be created of that class using only mobile compatible classes and constructs.
It would really help to solidify my understanding of this issue.
Programming isn't about writing code. It is about managing complexity.
CDC is a superset of CLDC, and JSE is a superset of CLDC, but their versions follow different trajectories, so there's no equivalent of any JSE version (such as Java 5) on JME. (And actually, "superset" is not strictly true, since JSE doesn't have the same grachics classes JME has, but it is true for the general language features.)
The best approach for getting an idea of what's supported by which C(L)DC version might be to read their respective release notes. A new version of MIDP just came out, but it's not clear that it'll be widely supported.
Ping & DNS - updated with new look and Ping home screen widget
Joined: Oct 09, 2008
I wonder if I should clarify a bit more in case what I was asking is not clear.
New versions of JavaSE introduced sometimes new language features. Granted they also introduced new classes. I understand that CDC/CLDC has its own independent class library which is based on in some parts but independent of JavaSE.
Some language features I can see would not work without corresponding related class libraries. Assert in 1.4 introduced an AssertationException and so the assert keyword could not work in JavaME if it did not also support that class.
In the case of Generics and Enums new classes were added to the JavaSE libraries to support Enums and Generics. Without these being present in JavaME then Generics and Enums also would not work either. I suppose these items are
Some language features are less clear however like the enhanced for loop which I don't think required new classes to support it but would be replaced at compile time with something which works with older versions of Java using an index or enumerator/iterator. Also auto boxing/unboxing is just a kind of compile time syntactic sugar. I think var-args is also a kind of syntactic sugar.
I would suspect that the language level constructs are based at the point at which JavaME was formed and the JavaSE language constructs which existed at that time. However I could be wrong as if a feature is compile time feature and the compilation (and pre-verification for CLDC) takes place on the desktop and so if the compiler is the same one used for compiling JavaSE but used with special options to target a given mobile platform then the compiler might be able to support some of the newer features in the source code like enhance for loops or auto-boxing. To be honest these kinds of features are less of a big deal for me. Using thing like Enums on the desktop are a matter of "best practices" for desktop code.
Joined: Oct 09, 2008
To be fair I should be able to establish that kind of behaviour with some sample code and just trying it out and seeing what happens.