The Java® Language Specification

12.Execution:

The Java Virtual Machine starts execution by invoking the method main of some
specified class, passing it a single argument, which is an array of strings


1 Load the Class.

The loading process is implemented by the class ClassLoader and its subclasses.
Different subclasses of ClassLoader may implement different loading policies. In
particular, a class loader may cache binary representations of classes and interfaces,
prefetch them based on expected usage, or load a group of related classes together.


If an error occurs during class loading, then an instance of one of the following
subclasses of class LinkageError will be thrown at any point in the program that
(directly or indirectly) uses the type:
• ClassCircularityError: A class or interface could not be loaded because it
would be its own superclass or superinterface (§8.1.4, §9.1.3, §13.4.4).
• ClassFormatError: The binary data that purports to specify a requested
compiled class or interface is malformed.
• NoClassDefFoundError: No definition for a requested class or interface could
be found by the relevant class loader.
12.3 Linking of Classes and Interfaces EXECUTION
320
Because loading involves the allocation of new data structures, it may fail with an
OutOfMemoryError.
2.Link Test: Verify, Prepare, (Optionally) Resolve
Verification checks that the loaded representation of Test is well-formed, with a
proper symbol table.


Preparation involves allocation of static storage and any data structures that are
used internally by the implementation of the Java Virtual Machine, such as method
tables.[url]http://en.wikipedia.org/wiki/Symbol_table[/url]

Preparation involves creating the static fields (class variables and constants) for a class or interface and initializing such fields to the default values

does not require the execution of any source code; explicit initializers for static fields are executed as part of initialization (§12.4), not preparation.


Resolution is the process of checking symbolic references with other
classes and interfaces, by loading the other classes and interfaces that are mentioned
and checking that the references are correct.

errors in Resolution step: IncompatibleClassChangeError,IllegalAccessError,InstantiationError,NoSuchFieldError,NoSuchMethodError, UnsatisfiedLinkError.


3. Initialization of Classes and Interfaces
Initialization consists of execution of any class variable initializers and static
initializers of the class

4.Creation of New Class Instances
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值