Wednesday Sep 03, 2008

detecting jvm from the java_home

One can use the following method to detect whether one is using JVM or JRE.  I had to write this code as I wanted to execute jmap, jstack etc under certain conditions which doesn't seem to be possible if the java_home is set to the default JRE location.





Monday Feb 11, 2008

Life of a java class from loading to exit

Step 1. Loading of the class. Throws subclasses of LinkageError ex. ClassFormatError, NoClassDefFoundError.

Step 2. Linking of the class:
The process of taking a binary form of a class or interface type and combining it into the runtime state of the Java virtual machine,
    a. Verification – instruction code is verified.
    b. Preparation – static variables and method tables are created .
    c. Resolution – Checking symbolic references from loaded class to other classes. Resolution translates the names into explicit references.Also checks for  field/method existence and whether access is allowed.

 Step 3. Initialization of the static variables and initializers.Note that the static variables have already been created during the Preparation phase.

Step 4. main(..) is executed.

Step 5. A class or interface may be unloaded if and only if its class loader is unreachable.

Step 6. The Java virtual machine terminates all its activity and exits when one of two things happens:
 - All the threads that are not daemon threads terminate.
-  Some thread invokes the exit method of class Runtime or class System, and the exit operation is permitted by the security manager.

About

This is the blog of a software engineer, specialized in identity management. Kunal Sinha works in Directory Services Engineering (OpenDS) team from Austin,Texas.

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today
Bookmarks