Java Notes-1

来源:互联网 发布:练习打字的最好软件 编辑:程序博客网 时间:2024/06/05 19:36
- C# has gone on to become a very good language in its own right, enjoying more innovation in recent years than has Java.

But Java continues to spread on a wide variety of platforms. 

- Java source is compiled into a universal format—instructions for a virtual

machine.

-Compiled Java bytecode is executed by a Java runtime interpreter. The runtime system
performs all the normal activities of a hardware processor, but it does so in a safe, virtual
environment. 


-The Java interpreter is relatively lightweight and small; it can be implemented in what‐
ever form is desirable for a particular platform. 


-The fundamental unit of Java code is the class. As in other object-oriented languages,
classes are application components that hold executable code and data. Compiled Java
classes are distributed in a universal binary format that contains Java bytecode and other
class information

-In addition to the platform-specific runtime system, Java has a number of fundamental
classes that contain architecture-dependent methods. These native methods serve as the
gateway between the Java virtual machine and the real world.

-runtime system can further optimize their performance by compiling bytecode to native machine code

on the fly. This is called just-in-time (JIT) or dynamic compilation. 

-Every object in Java has a well-defined type that is known at compile

time. This means the Java compiler can do the same kind of static type checking and
usage analysis as C++.

-However, Java is fully runtime-typed as well. The Java runtime system keeps track of all
objects and makes it possible to determine their types and relationships during execu‐
tion. This means you can inspect an object at runtime to determine what it is.

-you can write new code that

references binary class files without losing the type safety you gain from having the
source code.

-As long as a class maintains a
valid form of its original structure, it can evolve without breaking other classes that are
derived from it or that make use of it.

-Java eliminates ad hoc “pointers” that

can reference arbitrary areas of memory and adds object garbage collection and high-
level arrays to the language.

- Java runtime system keeps track
of all references to those objects. When an object is no longer in use, Java automatically
removes it from memory.

-Java uses a sophisticated garbage collector that runs in the background, which means
that most garbage collecting takes place during idle times, between I/O pauses, mouse
clicks, or keyboard hits. Advanced runtime system

- What Java provides are references—a safe kind of pointer. A refer‐
ence is a strongly typed handle for an object. 

-pointers to methods can be accomplished more cleanly using interfaces and
adapter classes instead. 

-When an exception occurs, it causes the flow of program execution to be transferred to
a predesignated “catch” block of code.

-Java supports
synchronization based on the monitor and condition model—a sort of lock and key
system for accessing resources. 

-Over classes, Java provides packages, a layer of structure that
groups classes into functional units. 



-In this little C++ drama, we have written some code that violates the encapsulation of
the  Finances class and pulls out some secret information. 

-The Java security model wraps three layers
of protection around imported classes



-The Java bytecode verifier is a fixed part of the Java runtime system

-Java’s first line of defense is the bytecode verifier. The verifier reads bytecode before it is
run and makes sure it is well behaved and obeys the basic rules of the Java language. 

-Once code has been verified, it’s considered safe from certain inadvertent or malicious
errors.

-Java adds a second layer of security with a class loader. A class loader is responsible for
bringing the bytecode for Java classes into the interpreter.

-A
security manager is an object that can be installed by an application to restrict access to
system resources. 

-The  main() method is
the entry point for applications. 




0 0
原创粉丝点击