- 1 -
The Study on JVM and the Transportability of Java
Zheng Weiguo,Tian Qichong
School of Computer Science and Technology, China University of Mining and Technology,
Xuzhou (221116)
Abstract
This paper introduces the Java virtual machine based on which analyzes the dynamic loading
mechanism, the working principles and uses of class loader, expounds the implementation process
of Java class is loaded, summarizes the impact of class loader on efficiency of the Java virtual machine.
At last, Java transportability is also discussed, analyzes the relevant factors that influence the
transportability of Java.
Keywords: JVM; Class Loader; Transportability
1. Introduction
JAVA was launched by the Sun as a programming language, is an open, standard,
general-purpose computing platform for the network program. Applications programmed by JAVA
can be applied to a wide variety of terminals devices such as laptop, PDA, cell phones, pagers, etc,
not needing rewriting. It is a network-oriented programming language to allow programmers to
create applications, which can be downloaded through the network and can run safely on any
computing platform. Java as a distributed, object-oriented programming language, you can make
any computer anywhere use the application of network applications. It is important that know
what the working principle of java is and how to the transportability is implemented.
2. Background
Java is designed for the network. It has security, network and has nothing to do with the
platform, mobility. The original design from Java on the consideration of these issues, so it has the
inherent advantages comparing with C / C + +, such as early high-level language.
Java is suitable for the development and application of the Internet, one of the reasons is that
it uses the virtual machine. The virtual machine is a Java command package used to explain the
java instructions to allow Java to run on any machine, for example, there are virtual machine
packages running on Mac or UNIX. Java Virtual Machine is not the language itself, it is a
preparation for a specific interpretation of the machine software[1]. Java virtual machine strategy is
equivalent to Esperanto, which is the man-made international language; the purpose is to make the
translation and communication between different languages easier.
3. Java Virtual Machine
Java Virtual Machine (the acronym for the JVM) is a fiction computer, through the computer
in the actual simulation to achieve a variety of computer functions. It has its own hardware
architecture (such as processor, stack, registers, etc.), but also with the corresponding instructions.
The use of "Java virtual machine" programme is in order to support that the programme can run in
any system but has nothing to do with the specific operating system.
The public concept of class files and instruction set are given in Java Virtual Machine
specification of SUN[2]. In public design, based on the achievement of private, anyone can design
a high efficiency or high efficiency operation of a certain part of the Java Virtual Machine.
Class Loader
中国科技论文在线
- 2 -
The first step to run class file of Java Virtual Machine is loading it, during which class loader
is the main tool to achieve this step. Java Class Loader mechanism is a core virtual machine
technology, can dynamically load or replace some of the features of the system modules in run
time, without affecting the normal operation of the other functional modules of the system. And
whether the realization of the Java Virtual Machine class loader or not influences the efficiency of
virtual machine to run directly[3].
Fig. 1. The structure of JVM
Java class loading model is a kind of agent model, class loading process is the process of
loading agent. In Java, loading a class loader into the Java virtual machine, it is necessary to go
through three steps to complete: loading, linking and initialization, which can be divided into
validation link, preparation and analytical steps, in addition to analytic the other steps are
completed in accordance with the order strictly.
Java architecture includes four separate but related technologies: Java programming language,
Java Class File Format, Java API, Java Virtual Machine. The latter two formed a platform for Java,
called Java run-time platform. We usually say that the Java2 platform, this means, Java's
transportability, the key lies in the fact that the platform will focus on the relevant part of the Java
run-time platforms, different operating platforms have different run-time Java platform, and
ensure that the standard of Java language itself is unified.
Java virtual machine specification does not require specific ways, it is only proposes an
interface specification, outlines the characteristics of Java platform. Virtual machine running speed,
manner and efficiency, and norms has nothing to do with the concrete realization of a great
relationship. For example, the implementation of the virtual machine engine, often three types:
one-time interpretation of byte-code, real-time compiler (JIT), adaptive optimizer. In addition,
specific hardware, as well as the virtual machine based on hardware[4].
中国科技论文在线
- 3 -
Fig. 2. The Function of JVM
JNI
There is another Java virtual machine form, that is, the localization method (JNI).
Localization method provides a specific platform, or the efficiency of the specific features support
in addition to the standard in Java. In the realization, JNI call in after the Java virtual machine will
take over all the control, including control over whether or not to return to Java Virtual Machine;
and security, JNI is not guaranteed. So in essence, that the status of JNI with Java virtual machine
is the same. It can be said, JNI is the Java virtual machine expansion. Java virtual machine type of
structure is loaded by the engine and the implementation of the two parts. And virtual machine
features, but also by the two parts together to complete[5].
Class loader is the loading entrance of all Java class files, so in the control of the security
process, it is only behind in the Class file. The bottom is the "start" (Bootstrap) class loader, Java
virtual machine which is part of the achievement. Followed, the system class loader is responsible
for loading the system-level Java API category. Finally, user-defined class loader. If an object is
called, it's the defaulted class loader will be the user-defined class loader. In this way, it and its
caller are linked through the dynamic class loader.
Java class files. This is a standard binary file. Like other characteristics of Java, the unity
depends on of the Java virtual machine will get all the non-uniform body together. It can be said
that, Class of documents, which is to facilitate the safe and fast network between computers in
different transmission. Java known as the "write once, run everywhere", class plays an important
role in that.
Java API. This is the Java user's unified way to access to different host resources. It must be
platform-dependent, different platforms have different realization of the Java API. But they have
to follow the same API interface standards, to ensure that the Java platform and the
platform-independent. In addition to the achievement of specific, Java API's design also gone to
great pains to as little as possible in the interface layer and platform-dependent, such as the design
of AWT and Swing, on a platform in the pursuit of independence, from design to realization.
Java programming language. Java language itself is the a reflection and summary of oriented
process of the past-oriented / object-oriented programming language. Starting from a new starting
point, so that Java should not confine itself to the past, and become the owner of a brand new
up-to-date summary of the most advanced technologies and experience of programming
languages.
Besides these advantages, we also must see these characteristics inherent shortcomings,
efficiency, brought about by imperfect compatibility in Java along the way have been saying too
中国科技论文在线
- 4 -
much. We can not change the problems of Java itself, but it requires us to Java in the preparation
of procedures, the need for programmers in other languages than the balance between efficiency
and more elegant code. This is a pressure, but also a privilege.
4. Transportability of Java
Support of Java architecture on the platform-independent
Java architecture to provide support of platform independence through many aspects. Java
platform, which is the most important aspects. Java platform plays a role of buffer that running
Java program under which between the operating system and hardware. Another point of view,
Java platform, in fact serves as a standard OS.
Java programming language itself also provides the support on the platform independence,
but it is based on the Java platform. For C / C + + programmers, the most obvious example is the
definition on a basic data type of the range and behavior. We have been emphasizing different
platforms, different machines, different CPUs have different definitions of bytes in length, but in
Java, the difference does not exist, because the Java language unified. As for the act, how
hardware work is not need to care for Java programmers. Java platform will the complete this
automatic conversion.
In addition, another support on a platform-independent of the Java-Class is the file format. It
is unified for all Java virtual machine, which also provides possibility of a delivery cross-platform
program code.
Therefore, the overall point of view, Java platform-independent architecture of support,
mainly from the design of the Java platform, which is equivalent to provide a standard layer of
shell for different hardware and operating system. Java architecture designed to operate based on a
virtual platform, will achieve the purpose of the platform-independent, while at the same time also
brought about a lot of shortcomings. However, this trend is unstoppable.
Of course, when it comes to platform-independent, and it can not be ignored that Java is not
only realized cross-platform in the computer field, but also in the field of smart devices. This is
achieved through the definition of different virtual machine standards. That is what we are familiar
with, J2EE, J2SE, and J2ME. In fact, the three Java versions are different from the smart devices
in the virtual machine specification. In the J2ME field, the platform-independent is more obvious,
because the mobile/embedded devices manufacturers and standards are much more than the
computer field and unity is much more difficult. Therefore, in the field of J2ME, besides the
general J2ME framework, but also make the definition in their respective standards for smaller
areas of the virtual machine, which are called the profile.
. The factors that influence the platform-independent
First of all factors, that is the deployment of the Java platform. The characteristic that Java
platform-independent determines the corresponding platform that fits the specific client operating
system must be installed when Java programs run, that is, Java Virtual Machine. These conditions
can not be met by every computer operating system. Fortunately however, Java has been got a
wide range of promotion; therefore, this problem has been resolved in the majority of customers.
The second factor is the Java platform version. This problem is mainly concentrated in the
different versions of Java API. Although the Java platform is more stable, but the Java API is a
relatively frequent changed, which will lead to a new version of the Java program can not run on
the old platform, as is like the common languages.
中国科技论文在线
- 5 -
The third factor is local method. When the Java platform uses some of the characteristics of
the operating system and needs to use local methods, it will undermine the platform independence.
Sun Corporation promotes pure Java program, that is, to avoid the use of local methods as far as
possible through the efforts of programmers.
The fourth factor is the non-standard run-time library. Although the local method may
destruct the platform independence, the standard local methods provided by the Java API are not
listed in it. Besides the standard API, there are a number of manufacturers and organizations to
provide non-standard methods, these methods may use local methods, but are not included in any
Java platform, so these non-standard methods must be used with caution. If they use the local
methods the platform-independent will be destroyed.
The fifth factor is the dependence of virtual machines. Java Virtual Machine is just like a
standard text, not a specific realization. The virtual machine we usually use is provided by Sun,
but this is not a standard virtual machine to achieve, in fact, the only criterion is the standard given
by Sun[6]. Therefore, the standard provided by the virtual machine can not be used as a part of the
procedure. Because the standard only points that we must achieve these characteristics, but how to
achieve specifically is achieved by the virtual machine. For example, the garbage collection
mechanism, thread priority and so on. They are achieved, but there is no determined way of the
realization, for example, the timing of garbage collection, the priority level of thread determines
the time of CPU distribution.
The last factor is the dependence on the user interface. On different Java platforms, it is
difficult for each UI of platform to satisfy all the users Therefore, when cross-platform is designed,
it is necessary to carefully design the interface UI.
5. Conclusion
Java Virtual Machine support a strong functional mechanism for dynamic loading, it has
inertia loading, the secure type connection, user-defined loading strategy, as well as the dynamic
characteristics of the name space. The dynamic Java class loading mechanism is a core technology
of the Java Virtual Machine, which can dynamically load or replace some of the features of the
system modules during the running time, without affecting normal operation of the other
functional modules of the system. It achieved that dynamically load the required class file in the
course of program execution, and the dynamic behavior can be artificially controlled.
The support of Java architecture on platform independence mainly comes from the design of
the Java platform. The deployment of Java platform, Java platform version, the local method, the
non-standard run-time library, the dependence on the virtual machine and user interface and so on,
are the main factors that influence its transportability.
References
[1] Wang Lidong, Zhang Kai. Analysis of Java Virtual Machine[J]. Journal of Beijing Institute of Technology, 2002,
22(1): 60-61.
[2] Sun Microsystems Inc. The Java Virtual Machine Specification (Second Edition)[M/OL].
1999-09-01.
[3]Huang Ming, Liu Yang. Analyses the Loading Mechanism of Java Virtual Machine[J]. Science and Technology
Consulting Herald, 2007(2):12-14.
[4] Wang Lidong, Zhang Kai. Realization of Class Loader in Java Virtual Machine[J]. Computer Applications,
2002, 22(11):107-109.
[5] Bill Venners. Further Study of Java Virtual Machine[M]. Beijing: China Machine Press, 2005.
[6] Bill Venners. The lean,Mean,Virtual Machine[J/OL]. Java World, 1996 (6).
中国科技论文在线
- 6 -
Biography:
Zheng Weiguo, male, born in 1986, his main research interests include Computer Application and
Artificial Intelligence.
中国科技论文在线