【正文】
s primitive data types are not objects. Values of primitive types are either stored directly in fields (for objects) or on the stack (for methods) rather than on the heap, as monly true for objects (but see Escape analysis). This was a conscious decision by Java39。s automatic memory management model is that programmers can be spared the burden of having to perform manual memory management. In some languages, memory for the creation of objects is implicitly allocated on the stack, or explicitly allocated and deallocated from the heap. In the latter case the responsibility of managing memory resides with the programmer. If the program does not deallocate an object, a memory leak occurs. If the program attempts to access or deallocate memory that has already been deallocated, the result is undefined and difficult to predict, and the program is likely to bee unstable and/or crash. This can be partially remedied by the use of smart pointers, but these add overhead and plexity. Note that garbage collection does not prevent logical memory leaks, . those where the memory is still referenced but never used.Garbage collection may happen at any time. Ideally, it will occur when a program is idle. It is guaranteed to be triggered if there is insufficient free memory on the heap to allocate a new object。 there are microcontrollers that can run java in hardware instead of a software JVM, and ARM based processors can have hardware support for executing Java bytecode through its Jazelle option.Automatic memory managementJava uses an automatic garbage collector to manage memory in the object lifecycle. The programmer determines when objects are created, and the Java runtime is responsible for recovering the memory once objects are no longer in use. Once no references to an object remain, the unreachable memory bees eligible to be freed automatically by the garbage collector. Something similar to a memory leak may still occur if a programmer39。 execution speed improved significantly with the introduction of Justintime pilation in 1997/1998 for Java , the addition of language features supporting better code analysis (such as inner classes, StringBuffer class, optional assertions, etc.), and optimizations in the Java Virtual Machine itself, such as HotSpot being the default for Sun39。s acquisition of Sun Microsystems in 2009–2010, Oracle has described itself as the steward of Java technology with a relentless mitment to fostering a munity of participation and transparency.PrinciplesThere were five primary goals in the creation of the Java language: should be simple, object oriented, and familiar、 should be robust and secure. should be architecture neutral and portable、 should execute with high performance、 should be interpreted, threaded, and dynamic.Java PlatformMain articles: Java (software platform) and Java Virtual MachineOne characteristic of Java is portability, which means that puter programs written in the Java language must run similarly on any supported hardware/operatingsystem platform. This is achieved by piling the Java language code to an intermediate representation called Java bytecode, instead of directly to platformspecific machine code. Java bytecode instructions are analogous to machine code, but are intended to be interpreted by a virtual machine (VM) written specifically for the host hardware. Endusers monly use a Java Runtime Environment (JRE) installed on their own machine for standalone Java applications, or in a Web browser for Java applets. Standardized libraries provide a generic way to access hostspecific features such as graphics, threading, and networking.A major benefit of using bytecode is porting. However, the overhead of interpretation means that interpreted programs almost always run more slowly than programs piled to native executables would. JustinTime pilers were introduced from an early stage that pile bytecodes to machine code during Microsystems officially licenses the Java Standard Edition platform for Linux, Mac OS X, and Solaris. Although in the past Sun has licensed Java to Microsoft, the license has expired and has not been renewed. Through a network of thirdparty vendors and licensees, alternative Java environments are available for these and other platforms.Sun39。s vicepresident Rich Green has said that Sun39。s lack of the piler, utility programs, and header November 13, 2006, Sun released much of Java as open source software under the terms of the GNU General Public License (GPL). On May 8, 2007, Sun finished the process, making all of Java39。 it went by the name Green later, and was later renamed Java, from a list of random aimed to implement a virtual machine and a language that had a familiar C/C++ style of notation.Sun Microsystems released the first public implementation as Java in 1995. It promised Write Once, Run Anywhere (WORA), providing nocost runtimes on popular platforms. Fairly secure and featuring configurable security, it allowed network and fileaccess restrictions. Major web browsers soon incorporated the ability to run Java applets within web pages, and Java quickly became popular. With the advent of Java 2 (released initially as J2SE in December 1998–1999), new versions had multiple configurations built for different types of platforms. For example, J2EE targeted enterprise applications and the greatly strippeddown version J2ME for mobile applications (Mobile Java). J2SE designated the Standard Edition. In 2006, for marketing purposes, Sun renamed new J2 versions as Java EE, Java ME, and Java SE, respectively.In 1997, Sun Microsystems approached the ISO/IEC JTC1 standards body and later the Ecma International to formalize Java, but it soon withdrew from the process. Java remains a de facto standard, controlled through the Java Community Process. At one time, Sun made most of its Java implementations available without charge, despite their proprietary software status. Sun generated revenue from Java