CLDC's purpose
• For small, limited resources, and Connected Limited devices define a standard Java platform. • Allow dynamics to publish content and applications to these devices.
· Convenient third-party software vendors and developers to transplant content and applications to these equipment.
Scope of CLDC
· Java language and virtual machine characteristics · Core Java class library (such as java.lang. *, Java.util. *) · Input / output · Support for network • Support for security · Support for internationalization
CLDC does not include the range (ie, is managed by MIDP) • Management of application Life-cycle (that is, how the application is installed, run, deleted) · UI interface (user interface)
· EVENT treatment
· Advanced application mode (here referring to the user's interaction with the application).
CLDC security
The low-end virtual machine-based security is guaranteed by the verification step of the Class file when downloaded.
. (If you have written and compile the MIDlet program, you will know that this step is necessary. There is a concept in here.
I will tell the specific steps in detail when I tell how to create a MIDlet program.
The application-based security is guaranteed by enabling each application in a relatively independent enclosure environment.
And the classes in the protected system package cannot be overridden by the application.
Special aspects for Java language support
CLDC is always compatible with the Java language, but you need to pay attention to the following points: Do not support floating point data types (ie, no float and double) (this is actually mainly due to CLDC
Prepare, its hardware does not support floating point operations due to its memory restrictions or security-based considerations)
Finalization, not supported, ie Object.Finalize
()method. (Note: Finalization refers to another one that is provided with Garbage Collection provided in Java.
Object cleaning method. Specifically, please refer to the "Thinking in Java Second Edition" of Houjie Teacher Translation.
Download in www.jjhou.com)
Limited error handling, that is, the subclasses of most java.lang.Error are not supported. In contrast, CLDC includes
A quite complete exception class.
Special aspects supporting Java Virtual Machine support
Substantially CLDC reached a compatibility of the Java virtual machine under its strict memory restriction. But still
The following differences.
· Does not support floating point data types (no float and double)
· Does JNI (THE JAVA Native Interface)
· Class loaders do not support user-defined Java-class loaders (Class Loaders)
· There is no reflection characteristic (Note: reflection "Java provides java.lang.Reflect
You can analyze the ability to analyze the capabilities of class. Often used to check the structure of the class, there is a wide range of javabeans
Use the Core Java2 Volumei, II, and machinery that can be found in Gary Cornell.
· Does not support the THREAD Group (DAEMON THREADS) · Finalization, does not support class instance (Finalization)
· No Weak References (Note: Weak Reference provides a solution to being
Garbage Collector is cleared by the object. Introduced in Java2. Please refer to Java.Lang.Ref API for details.
Documentation, and article about Reference Objects and Garbage Collection on your SUN. )
· Limited error handling (Error Handling)
4. In-depth understanding of CLDC (Part II)
The part of this section is translated from J2ME White Paper, which is boring, but keep in mind, after all, correct
The concept is more than everything.
Class Files Verification
CLDC requires the lower layer of virtual machines to identify and reject illegal Class files. But due to CLDC itself
This premise for small equipment consumed by small memory. His class file detection mechanism and standard class defined in J2SE
Document audit mechanisms are different. Please note the picture below:
MyApp.java │ ┌ - ┐ │JAVAC │┄ Compiler └ - ─ ┘ ↓ ↓ p. ┌──────────── ─ ┐ │preverifier │ ┈ Pre-auditor - ────── ─ ┘ ↓ ↓ MyApp.class │ ↓ Download ... ┌ - ────── ─ ┒│ ┠┄┄KVM operating environment │ ┌────────────────────── /> │ │ Verifier │ └────── ─ ─ ┘ ┘ │ │ ┌──────── ┐ ││ │ │ interpreter │ │ │ │ │ │ │ │ └──────────────────────────────────────────────────────────────────── ┕━━└━━━┛┛
Figure 2 CLDC / KVM audit process
Note the preverification process in CLDC. This is the CLDC distinguishably from the usual class file.
The key to the review process. As shown in the figure above, after the source program is compiled, it must be pre-tried by the pre-audible.
Behind it can be downloaded to the target device. The reason why this step is mainly to reduce KVM trial
The burden and speed up the audit speed. Just like mentioned above, this is for hardware supporting CLDC support
(After all, the mobile phone and PDA did not pentium "core"! ^ - ^) as the PC. Remember this summation here
I will do it. Specific operation methods I will introduce when writing MIDlet programs later.
Class file format
Sun requires Java applications through JAR (Compressed Java Archive), here is also
No exception. So if you want to download your MIDlet program to the device, you have to pack it with JAR.
. Specific operation methods I will introduce when writing MIDlet programs later.
CLDC class library
If it is not strict, the CLDC's class library is a small subset of J2SE, which has the following approximate relationship, that is, J2SE includes CDC containing CLDC. But pay attention to CLDC is not fully included in J2SE, which also includes one
Some specifically for wireless facilities. So you can briefly divide the CLDC's class library into two parts: follow J2SE
The class and CLDC proprietary class.
(1) Class from J2SE inherited
This part consists of three packages, Java.lang, Java.util and Java.IO. Note that even these
The class of J2SE inherits is also a big "shrinking water". For example, Java.util's class and interface by J2SE
47 shrinks to 10. The other two have corresponding reductions.
System class
From Java.lang: Object, Class, Runtime, System, Thread, Runnable, String, StringBuffer, Throwable
Data type class
From Java.lang: Boolean, Byte, Short, Integer, Long, Character
Container Class
From Java.util: Vector, Stack, Hashtable, ENUMERATION
I / O class
From java.io:InputStream, OutputStream, ByteArrayInputStream, ByteArrayOutputStream, DataInput, DataOutput, DataInputStream, DataOutputStream, Reader, Writer, InputStreamReader, OutputStreamWriter, PrintStream
Date and time class
From java.util: Calendar, Date, Timezone
Additional practical class
Java.util.random, java.lang.math
Exception classes
From java.lang: Exception, ClassNotFoundException, IllegalAccessException, InstantiationException, InterruptedException, RuntimeException, ArithmeticException, ArrayStoreException, ClassCastException, IllegalArgumentException, IllegalThreadStateException, NumberFormatException, IllegalMonitorStateException, IndexOutOfBoundsException, ArrayIndexOutOfBoundsException, StringIndexOutOfBoundsException, NegativeArraySizeException, NullPointerException, SecurityException
From java.util: EmptyStackException, NosuchelementException
From java.io :eofexception, ioException, interruptedException, unsupportedEncodingexception, UTFDataFormatexception
Wrong class
From Java.lang: Error, VirtualMachineError, OutofMemoryError
(2) CLDC proprietary class
Here SUN provides javax.microedition.IO package. Use it to provide bridges communicating with the outside world.
(Note: Just as in J2SE we use java.net. *) Note that all connections are created by javax.microedition.connector. E.g:
You can open an HTTP connection
Connector.Open ("http://www.chinajavaworld.com")
Javax.microedition.IO interface includes: Connection, InputConnection, OutputConnection, StreamConnection, ContentConnection, DataGramConnection, StreamConnectionNotifier
Here, you can also see that you can also see that the class library included in CLDC is not enough to develop applications.
program. For example, there is no support for the UI interface, etc. This is also the design concept of CLDC. CLDC itself never
I want to solve all the problems. These issues are resolved by PROFILE-MIDP on the upper layer. E.g
Javax.microEdition.lcdui is the UI package defined in the MIDP.