Inside the JVM(1)

来源:互联网 发布:mysql自动递增 编辑:程序博客网 时间:2024/05/16 07:31

机遇和挑战:

platform independence, security, and network-mobility.


JVM:

The Java Virtual Machine is an abstract computer.
A Java Virtual Machineís main job is to load class files and execute the bytecodes they contain.


native methods are the connection between a Java program and an underlying host operating system.

The Class Loader Architecture

The primordial class loader loads trusted classes, including the classes of the Java API, usually from the local disk.

Classes loaded by different class loaders are in different name-spaces and cannot gain access to each other unless the application explicitly allows it.

不同的classloader有不同命名空间,不同classloader装载的类不可互相访问。


class文件是虚拟机的“机器语言”


API是虚拟机的一部分

Precisely because the Java Virtual Machine and Java API are implemented specifically for each particular host platform, Java programs themselves can be platform independent.

 security manager?


JAVA编程语言

One of the most compelling reasons for using Java as a language is that it can enhance developer productivity.

提高了生产力!!

 The main disadvantage is slower execution speed. 

缺点是较慢的执行速度


面向对象,使得代码重用度高,比起c,很明显;和c++比,面向对象特性较为相似,但是java不允许直接操纵内存。

Java程序员不用担心错误的类型,不用手工回收内存。

Java有数组边界的检查,C++没有

null引用的使用会得到异常,而C++使用空指针往往造成程序崩溃。


Javaís extra run-time housekeeping--array bounds checking, type-safe
reference casting, checking for null references, and
garbage-collection--will cause your Java program to be slower than an
equivalent C++ program.


When running on a virtual machine that interprets bytecodes, a Java
program may be 10 to 30 times slower than an equivalent C++ program
compiled to native machine code.


When running on a virtual machine that interprets bytecodes, a Java
program may be 10 to 30 times slower than an equivalent C++ program
compiled to native machine code.


可以在安装的时候把java编译成本地代码。——install-time compiled


Architectural Tradeoffs ——架构的权衡

It is suitable for solving
problems that involve networks and has utility in many problem that donít
involve networks, but its architectural tradeoffs will disqualify it for
certain types of jobs.



HOT SPOT

原创粉丝点击