Binary class format
Format:
Constant pool data
Stores all constants used by the class definition
Attributes
Some container for data
e. g. method bytecode, constants, value of a constant field
- JVM ignores attributes of unknown type - flexibility for extending use of attributes to serve other purposes [metadata for frameworks that work with user classes - C#]
JVM
- operands: immediate or from constant pool
JVM implementation
Linking process in C
C => machine code
linking merges code from separately compiled source files + shared library code to form an executable
Linking in Java
Loading classes in Java - when
Loading classes in Java - what happens
Bootstrap class loader
- built into JVM, responsible for loading basic Java class libraries special features: - only load classes found on the boot class path - less validation since these are trusted system classes
Extension class loader
CL for loading classes from standard Java extension APIs
System class loader
for loading classes from the general class path including your application classes
Application defined class loaders - why
Runtime reloading of classes Derived from java.lang.ClassLoader provides core support for building an internal class representation from an array of bytes Each constructed class is owned by the class loader that loaded it ... they keep a map from name => Class instance, for all loaded classes, to be able to find one by name if it's requested again
Class loader tree
1- class loader keeps reference to a parent class loader, defining a tree of class loaders with the bootstrap loader at the root. 2- When an instance of a particular class (identified by name) is needed, whichever class loader initially handles the request normally checks with its parent class loader first before trying to load the class directly. 3- This applies recursively if there are multiple layers of class loaders, so it means that a class will normally be visible not only within the class loader that loaded it, but also to all descendant class loaders. 4- It also means that if a class can be loaded by more than one class loader in a chain, the one furthest up the tree will be the one that actually loads it.
Example: utility of multiple class loaders, J2EE framework