Java Reference
In-Depth Information
The method main must be declared public , static , and void . It must specify a formal parameter
8.4.1 ) whose declared type is array of String . Therefore, either of the following declara-
tions is acceptable:
public static void main(String[] args)
public static void main(String... args)
12.2. Loading of Classes and Interfaces
Loading refers to the process of finding the binary form of a class or interface type with
a particular name, perhaps by computing it on the fly, but more typically by retrieving a
binary representation previously computed from source code by a Java compiler, and con-
structing, from that binary form, a Class object to represent the class or interface.
The precise semantics of loading are given in Chapter 5 of The Java Virtual Machine Spe-
cification, Java SE 7 Edition . Here we present an overview of the process from the view-
point of the Java programming language.
The binary format of a class or interface is normally the class file format described in The
Java Virtual Machine Specification, Java SE 7 Edition cited above, but other formats are
possible, provided they meet the requirements specified in § 13.1 . The method defineClass of
class ClassLoader may be used to construct Class objects from binary representations in the
class file format.
Well-behaved class loaders maintain these properties:
• Given the same name, a good class loader should always return the same class ob-
ject.
• If a class loader L1 delegates loading of a class C to another loader L2 , then for
any type T that occurs as the direct superclass or a direct superinterface of C , or as
the type of a field in C , or as the type of a formal parameter of a method or con-
structor in C , or as a return type of a method in C , L1 and L2 should return the
same Class object.
A malicious class loader could violate these properties. However, it could not undermine
the security of the type system, because the Java Virtual Machine guards against this.
For further discussion of these issues, see The Java Virtual Machine Specification,
Java SE 7 Edition and the paper Dynamic Class Loading in the Java Virtual Machine ,
by Sheng Liang and Gilad Bracha, in Proceedings of OOPSLA '98 , published as ACM
SIGPLAN Notices , Volume 33, Number 10, October 1998, pages 36-44. A basic prin-
ciple of the design of the Java programming language is that the run-time type system
Search WWH ::




Custom Search