readme.mkd 7.18 KB
Newer Older
1
2
3
4
5
# Multi-Phasic Applications: SquirrelJME

  * Copyright (C) 2013-2016 Steven Gawroriski
    <steven@multiphasicapps.net>
  * Copyright (C) 2013-2016 Multi-Phasic Applications
6
    <http://multiphasicapps.net/>
7

8
**SquirrelJME** is intended to be a Java ME 8 compatible environment for
Stephanie Gawroriski's avatar
Stephanie Gawroriski committed
9
strange and many other devices. The source is written in pure Java.
10

11
## Licenses
12
13
14

  * [GNU Affero General Public License, Version 3 or later](license.mkd)

15
## Links
16
17

  * [Online repository](http://multiphasicapps.net:8080/squirreljme)
Stephanie Gawroriski's avatar
Stephanie Gawroriski committed
18
  * [Sub-Reddit](https://www.reddit.com/r/SquirrelJME/)
19

20
21
22
## Goals

 * _To be self-hosting_ - it can build itself while running on itself, provided
Stephanie Gawroriski's avatar
Fixups.    
Stephanie Gawroriski committed
23
   there is a filesystem and enough memory.
24
25
26
27
28
29
30
 * _To be small_ - Smaller programs are easier to maintain and are usually
   simpler.
 * _To be fast_ - With the potential of AOT/JIT, systems that do not normally
   have a port of an existing virtual machine will usually only have an
   interpreter.
 * _To be compatible_ - So that existing Java ME 8 applications can run on this
   virtual machine.
Stephanie Gawroriski's avatar
Stephanie Gawroriski committed
31
32
33
34
35
36
37
 * _To compile once and run anywhere_ - Current and up to date Java
   implementations are limited only to a few select systems (_Solaris_,
   _Linux_, _BSD_, _Mac OS X_, and _Windows_). Java ME 8 as of this writing
   only supports the *FRDM-K64F* and the *Raspberry Pi*. There are multitudes
   of devices that support **J2ME**, however that is horribly out of date when
   compared with the Java that is used today (**J2ME** is equal to Java 1.4
   which was released in _2002_).
38
39
40

## Donations

Stephanie Gawroriski's avatar
Stephanie Gawroriski committed
41
42
You may donate to SquirrelJME to help keep the author alive and to possibly
help the purchase of various hardware:
43
44
45
46
47
48
49
50

  * BitCoin (**BTC/XBT**): [`1HNRD44krsCFUzUvVWaXr5jqvuyZDZy71M`](
    bitcoin:1HNRD44krsCFUzUvVWaXr5jqvuyZDZy71M)
  * LiteCoin (**LTC**): [`LKytAQcbPyox75uYMKo1NH1w2k1SqBaELi`](
    litecoin:LKytAQcbPyox75uYMKo1NH1w2k1SqBaELi)
  * DogeCoin (**DOGE**): [`DPsW21MV8RMuXhA3GoN8VPjkmQEugrEn8h`](
    dogecoin:DPsW21MV8RMuXhA3GoN8VPjkmQEugrEn8h)

Stephanie Gawroriski's avatar
Stephanie Gawroriski committed
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# Important Statements

***THIS SOFTWARE IS INCOMPLETE AND IN ITS CURRENT STATE IS NOT CURRENTLY
100% COMPATIBLE WITH JAVA ME 8. THERE ARE CURRENTLY NO RELEASED VERSIONS OF
THIS SOFTWARE. AS SUCH THE FIRST RELEASE WILL BE WHEN IT IS COMPATIBLE SO AS TO
NOT VIOLATE POTENTIAL LICENSES, AND IF POSSIBLE BE VERIFIED WITH ANY
APPLICABLE TCKS (SO IT WOULD BE AN "OFFICIAL" IMPLEMENTATION).***

***JAVA AND ALL OTHER RELATED TRADEMARKS AND COPYRIGHTS ARE OWNED BY ORACLE
CORPORATION <http://www.oracle.com/>. THE IMPLEMENTATIONS OF THE JAVA ME 8
APIS AND ASSOCIATED JSRS/JEPS IS CONSIDERED BY MYSELF TO BE IN THE FAIR USE
(AND IT ALSO HELPS THE JAVA ECOSYSTEM BY PERMITTING IT TO RUN IN MORE PLACES
WHERE IT IS NOT SUPPORTED BY ORACLE).***

65
66
# Supported Operating Systems and Freestanding Hardware

67
68
_% -- Only tested on emulators, not real hardware._

69
70
71
72
## Hosted

## Freestanding

73
74
## Virtual

75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
# Differences Between Java SE and Java ME

Java ME is a much lighter Java platform and here are the things which are
missing along with a reason as to why this may be a good thing:

 * No finalizers (the `finalize()` method).
   * Finalizers are very integrated with how the garbage collector works.
   * It is never known when they will actually be called (if ever).
   * Timing attacks could be performed when finalizers are called between
     garbage collection runs.
 * No serialization.
   * Not all objects are `Serializable`.
   * Serialization uses virtual machine magic to access internal details.
   * The `transient` keyword should never appear.
   * Simplifies implementation.
 * No reflection.
   * There is `Class.forName()` and `Class.newInstance()`, however they are
     trivial to support.
   * More secure because access checks do not have to be performed at run-time
     to determine if it is permissable to access an object.
   * Random object fields (and finals) can be cached because their reference
     or primitive values will never change.
   * More secure because for example changing `Boolean.TRUE` to be `false` may
     cause security exploits with code that relies on it being `true`.
 * No `invokedynamic` instruction.
   * Simplifies virtual machine operation, at the cost of lambdas (which could
     be smartly wrapped in anonymous classes by a compiler).

However, given these differences there are advantages:

 * Faster
   * Due to the lack of reflection, optimization is safer because finals are
     truly final. This means no exceptions are required to allow for this
     change.
 * Lighter
   * The main library is much smaller which means it will load faster and
     use less memory. Less memory means it can run on smaller systems such as
     calculators.

There are also disadvantages however:

 * Without reflection, one cannot include plugins dynamically from the program.
   * However, Java ME 3 (or so) added LIBlets which may be optional and provide
     a slight alternative to plugins. These however are fixed to the JAR/JAD
     which means that the difficulty is increased.
   * Alternatively, Java ME 8 has `ServiceLoader` which enables JARs to
     potentially be merged to provide services. Also using `Class.forName()`
     and `Class.newInstance()`, plugins using a common interface can be
     initialized when they are not directly known.

Stephanie Gawroriski's avatar
Stephanie Gawroriski committed
125
126
127
128
129
130
131
132
# Limitations

These are planned limitations:

 * Only _4,096_ classes may be used at any one time, provided there is enough
   memory to load all of them. Note that in standard desktop Java, this would
   mean that almost the entire standard class library has been loaded.

133
134
135
136
137
138
139
140
## Supported Character Encodings

Only two character encodings are supported:

 * ISO-8859-1
   * This is essentially the first 256 unicode characters.
 * UTF-8

Stephanie Gawroriski's avatar
Notes.    
Stephanie Gawroriski committed
141
142
143
144
145
146
# Programming Considerations

## Do Not Use Static Modifiable/Mutable Globals In Standalone Classes

The garbage collector upon determining that a class (which may contain static
variables treated as globals) is no longer referenced, it may be garbage
Stephanie Gawroriski's avatar
Stephanie Gawroriski committed
147
148
149
150
collected. This means that if you set a global in a class such as that and
then reference it later, it may be reset to its default value. This is more
likely to happen on lower memory systems where the garbage collector will act
more aggressively.
151

152
153
154
155
156
157
158
159
160
161
## Use Error Codes

Error codes are located in [errors.mkd](errors.mkd).

Although descriptive details of why an exception is thrown is a nice thing, it
can waste much space on the static constant data and some extra time building
the messages. In general cases, exceptions that require detailed messages
might not always occur while in the case where they are needed the details
are important.

162
163
# Style Requirements

164
165
166
167
168
169
170
171
172
173
## Always Tab With Size 4

Indentation is not done with spaces at all, it is pure tab. The tab size used
is 4 spaces.

## Never Exceed 79 Characters Per Column

There is a maxiumum limit of 79 characters per line of source code and in
other files also.

174
175
176
177
178
179
## Always Surround Ternary Operators With Parenthesis

When using ternary operators, you must always surround them in parenthesis even
if they are obvious. That is they must appear in the form of
`(condition ? true : false)`.

180
181
182
183
184
185
186
# Consistency Requirements

## Unknown Characters Representation

When the target is UTF-8 the unknown character will become `0xFFFD`.

When the target is ISO-8859-1 the unknown character will become `?`.
187