J2ME Environment

It is very possible for SquirrelJME to have an environment generated by the JIT which targets J2ME devices (MIDP 1.0 to 2.1). These VMs have some limitations however when it comes to objects and such. However most of them can be avoided by using tricks and such. The purpose of this environment would be to get some kind of environment for J2ME devices if they cannot get binaries generated to them or as early support for said devices (such as Palm OS).

Speed Considerations

One consideration is speed. I can have an emulated environment or one that runs the actual byte code, the latter would be far faster and more practical so any work would be as if it were running.

Limitations and Workarounds

These are the limitations and workarounds for problems that Java ME 8 code may have trouble with.

Object layout

Due to the way the code works, having objects that reference each other and their superclasses might not work out if they were to keep their normal layout. That could work however, except there would be cases where if a class extends another class in a namespace which shares the same class of another namespace (an alternative implementation so to speak). All instances of classes and objects in the VM would have to extend just a single base class. The inheritence as seen by the running code would have to use the specific object access. Then virtually all code would be translated to static methods with a VM reference (for process support) and then ran as such.

Garbage collection and References

J2ME has no references, As such, there is no real way to emulate garbage collection of references. As such, references will pretty much have to remain as being strong references. However, one consideration is that System.gc() for this target can go through all of the allocated reference types and null them out. However, this would mean that there would need to be a chain of reference types, which means they cannot be garbage collected either. One consideration is to lay out objects in a way where all of their values can be obtained and retrieved as a kind of virtual reflection, although this would create much more objects and potentially slow things down.


Since everything would be a single environment, processes along with their statics would have to be stored in instances which hold all of the values to be initialized for the virtual machine.