Sunday, April 15, 2012

New build system of openJDK (jdk8 master forest) rocks!

Just tried with new build system in OpenJDK (jdk8 master forest) on Windows, now there is no pain as it was with the old build. Just start the build and relax....

If any one interested to try out just check this link "http://openjdk.java.net/projects/build-infra/guide.html"

PS: if you end up with "Defs-utils.gmk: No such file or directory", just go and create a dummy file named "Defs-utils.gmk" in "jdk/makefiles/common/shared"

Monday, January 23, 2012

Lesson learnt during writing Java Agent

"Never Use Class Object reference which you want to transform in the 'agent classes' itself".

To understand above sentence, lets take an example if I want to instrument class "com.my.target.Klass1" and some where in agent jar file itself we made a reference to Klass1 object by saying
"Klass1.class"
then this class will not be called for transformation by registered ClassFileTransformer in the agent.

In my case I wanted "Klass1" name so I added code in ClassFileTransformer implementation as below:

String klassObject = Klass1.class.getName();

and when I made agent jar and wanted to use it for instrumentation, this class (Klass1.class) was no where to be seen. I struggle for hours and noticed that all other classes were called in by ClassFileTransformer implementation and only "Klass1" class was not. I had to change above code not to refer to class object directly. So I removed "Klass1.class" statement and replaced it with complete class name as below
String klassObject = "com.my.target.Klass1";

Now it worked like a charm...

Sunday, December 18, 2011

Threads Class Hierarchy OpenJDK (Ref thread.hpp)

Below is taken from hotspot\src\share\vm\runtime\thread.hpp file

Class hierarchy

Thread
   |-> NamedThread
          |-> VMThread
          |-> ConcurrentGCThread
          |-> WorkerThread
                  |-> GangWorker
                  |-> GCTaskThread
   |-> JavaThread
   |-> WatcherThread

Thursday, December 15, 2011

Comments from OpenJdk Source

When going through openJDK source found good comments in the source file, thought it would help me a lot for reference....so blogging it

Source: jdk7-b147 (tag)
File Name: hotspot\src\share\vm\memory\space.hpp [line number from 48 to 65]

//  A space is an abstraction for the "storage units" backing
// up the generation abstraction. It includes specific
// implementations for keeping track of free and used space,
// for iterating over objects and free blocks, etc.

// Here's the Space hierarchy:
//
// - Space-- an asbtract base class describing a heap area
// - CompactibleSpace -- a space supporting compaction
// - CompactibleFreeListSpace -- (used for CMS generation)
// - ContiguousSpace -- a compactible space in which all free space
// is contiguous
// - EdenSpace -- contiguous space used as nursery
// - ConcEdenSpace -- contiguous space with a 'soft end safe' allocation
// - OffsetTableContigSpace -- contiguous space with a block offset array
// that allows "fast" block_start calls
// - TenuredSpace -- (used for TenuredGeneration)
// - ContigPermSpace -- an offset table contiguous space for perm gen

----- END of hotspot\src\share\vm\memory\space.hpp

Friday, September 16, 2011

Hotspot Runtime Overview

OpenJDK's doc contains one very important note/document related to JVM runtime overview, this should have been read by me way back but its never late until you do it :)....so here is the link RuntimeOverview. I enjoyed it reading and came to know very key point/areas about the code in OpenJDK.

Sunday, September 11, 2011

I tried with WinDbg but found it much easier with VC10 debuging executable found at this link "How to: Debug an Executable Not Part of a Visual Studio Solution".
I am still going through the OpenJDK by debuging and found few useful classes, like for example we have used few JVM options like PermSize which are defined in the file "hotspot/src/share/vm/runtime/globals.hpp", here you can find all the global JVM options defined and we have used in our day to day java application.

Wednesday, July 20, 2011

First step towards windows debugging for OpenJDK

Yesterday I have installed WinDbg for the purpose of debugging openJDK (mostly around b118), I haven't started using it, will update how it goes