sandip chitale's blog    Sandip Chitale's blog (scblog)
NOTE: I have moved many of my modules to NetBeans Plugin Portal . Please check there for latest versions of modules described on this blog.
20060930 Saturday September 30, 2006

Use new Java 6 JDK tools to explore Netbeans runtime

Java 6 JDK has some very cool new tools:

  • jps JVM Process Status Tool - Lists instrumented HotSpot Java virtual machines on a target system.
  • jmap Memory Map for Java - Prints shared object memory maps or heap memory details of a given process or core file or a remote debug server.
  • jhat Heap Dump Browser - Starts a web server on a heap dump file (eg, produced by jmap -dump), allowing the heap to be browsed.
I was running Netbeans 5.5 Beta2. I decided to experiment with these tools and explore the Netbeans runtime. So here is what I did:

Use jps to find out the process id of the Netbeans IDE:
$ jps -l
2716 org/netbeans/Main
3824 sun.tools.jps.Jps
Use jmap to dump the heap of the Netbeans IDE process:
$ jmap -dump:format=b,file=heap.bin 2716
Dumping heap to heap.bin ...
Heap dump file created
Use jhat to run a web server so that I can run OQL queries on the information in the heap dump file:
$ jhat.exe -J-Xmx512m heap.bin
Reading from heap.bin...
Dump file created Sat Sep 30 17:32:29 PDT 2006
Snapshot read, resolving...
Resolving 603765 objects...
Chasing references, expect 120 dots...
Eliminating duplicate references...
Snapshot resolved.
Started HTTP server on port 7000
Server is ready.
Ran the browser with URL:
http://127.0.0.1:7000/oql/
Entered the following query in the OQL query text box and click Execute:
select map(
    heap.objects('org.netbeans.StandardModule$OneModuleClassLoader'),
    function (it) {
    function printit(it, indent) {
        var res = '';
        if (classof(it).name == 'org.netbeans.StandardModule$OneModuleClassLoader') {
            var itsModule = it.this$0;
            var codeName = itsModule.codeName.value.toString();
            var specVers = itsModule.specVers.digits.toString();
            var jar = itsModule.jar.path.value.toString();
   
        res += indent + '<a name="'+ escape(codeName + specVers) + '">' +
codeName + '&nbsp' + specVers + ' [' + jar + ']'+
'</a>' + '<br>';
           
            indent += '&nbsp;&nbsp;&nbsp;&nbsp;';

            if (itsModule.publicPackages) {
                res += '<br>' + indent + 'Public packages:' + '<br>';
                for (i = 0; i < itsModule.publicPackages.length; i++) {
                    var publicPackage = itsModule.publicPackages[i];
                    res += indent + publicPackage.pkg.value.toString() +
                    (publicPackage.recursive ? '**' : '') +
                    '<br>';
                }
            }                   
           
            if (it.parents) {
                res += '<br>' + indent + 'Dependencies:' + '<br>';
                for (i = 1; i < it.parents.length; i++) {
                    var parent = it.parents[i];
                    if (classof(parent).name == 'org.netbeans.StandardModule$OneModuleClassLoader') {
                        var parentCodeName = parent.this$0.codeName.value.toString();
                        var parentSpecVers = parent.this$0.specVers.digits.toString();
   
                    res += indent + '<a href="#'+ escape(parentCodeName + parentSpecVers) +
 '">' + parentCodeName + '&nbsp' +
parentSpecVers + '</a>' + '<br>';
                    }                   
                }
            }
        }
        return res;
    }
    return '<br>' + printit(it, '');
})

On the query page there is a link to help on the OQL syntax and supported functions.

And here is the screenshot of the query result which is a simple report on Netbeans module dependencies

This is just the tip of the iceberg. Using OQL one can explore what is going on inside Java application's heap.

Netbeans Profiler now has HeapWalker tool to look at heap dumps generated by jmap tool.


Posted by sandipchitale ( Sep 30 2006, 06:14:26 PM PDT ) Permalink Comments [1]


20060922 Friday September 22, 2006

TIP: Dealing with trailing whitespaces in Netbeans editor

Expose trailing whitespaces using Find dialog

Delete trailing whitespaces using Replace dialog - before

Delete trailing whitespaces using Replace dialog - after

 

Lame tip huh?

 


Posted by sandipchitale ( Sep 22 2006, 12:51:05 AM PDT ) Permalink Comments [3]


20060920 Wednesday September 20, 2006

UPDATED: LineTools module - Added exchange mark and dot action i.e. move the caret to the other end of the selection

I have updated the Line Tools Module on my NetBeans 5.0 update center described (here).

What is new

Added exchange mark and dot action. The action moves the caret to the other end of the selection.

Sources

DISCLAIMER: This module is experimental. So no guarantees. Use the module at your own risk.


Posted by sandipchitale ( Sep 20 2006, 07:37:50 PM PDT ) Permalink Comments [1]


TIP: Debugging JDK classes with Netbeans

Many times one needs to debug (step) into the JDK classes. Most IDEs allow the user to associate the sources (JDK_INSTALLATION_DIR/src.zip file)with the JDK in use and step into the JDK sources.

In case of Netbeans stepping into JDK sources is disabled by default. As a result one is unable to step into the JDK sources. Another symptom of this is that the stack frames correspoing to the JDK sources are shown under the collapsed Hidden Source Calls node.To enable stepping into the JDK sources (or any other hidden source calls) do the following:

  • Start your debug session
  • Show the Sources window using Windows:Debugging:Sources(Alt+Shift+8 on Windows)menu item
  • Locate the JDK sources entry and select the checkbox under Use for debugging column.

I wish a tooltip on the Hidden Source Calls node could have some indication of this information. I have already filed and RFE for it.

In an upcoming blog entry I will explain how to view the local variable values in the JDK classes.


Posted by sandipchitale ( Sep 20 2006, 07:44:56 AM PDT ) Permalink Comments [2]


20060916 Saturday September 16, 2006

UPDATED: JPDA (Java) Debugger Call Stack View Enhancements Module

I have updated the JPDA (Java) Debugger Call Stack View Module on my NetBeans 5.0 update center described (here).

What is new?

  • The InvalidStackFrameException issue has been fixed
  • The pop up window now shows "Please wait..." message and can be dismissed before the classes are displayed.

For more details about the module see this and this blog entry.

Sources

DISCLAIMER: This module is experimental. So no guarantees. Use the module at your own risk.


Posted by sandipchitale ( Sep 16 2006, 01:31:19 PM PDT ) Permalink Comments [0]


20060904 Monday September 04, 2006

Tuscany II


Posted by sandipchitale ( Sep 04 2006, 09:37:35 PM PDT ) Permalink Comments [0]


20060901 Friday September 01, 2006

UPDATED: View Classes and Classloader information - JPDA (Java) Debugger Call Stack View Enhancements Module

I have updated the JPDA (Java) Debugger Call Stack View Module on my NetBeans 5.0 update center described (here).

What is new?

The following new popup actions is supported:

  • Show Classes... Shows the table of all classes loaded in the debugee. Each row in Classes table shows Class name, Package name and the value returned by the toString() method of class's ClassLoader and Initiating ClassLoader (See the revised Java Virtual Machine Specification section 5.3 Creation and Loading for more information on the initiating classloader). Each column is sortable.To invoke the action right click on any call stack frame in the Calls Stack view of the debugger.

Notice how the ClassLoader's toString()value is showing the module code base name e.g. org.openide.loaders. Also notice how the loading of org.openide.loaders.DataFolder class was initiated by org.netbeans.web.core.syntax module's ClassLoader, but the class was actually loaded by the org.openide.loaders module's ClassLoader. This can be useful for debugging applications such as App Servers, IDE Frameworks (e.g. Netbeans itself), that employ a complex multi-ClassLoader architecture. This view helps you determine which ClassLoader initiated and which ClassLoader loaded the class.

The following figure shows which Netbeans modules ClassLoader has loaded certain classes.

Sources

DISCLAIMER: This module is experimental. So no guarantees. Use the module at your own risk.


Posted by sandipchitale ( Sep 01 2006, 01:43:10 PM PDT ) Permalink Comments [0]










« September 2006 »
SunMonTueWedThuFriSat
     
2
3
5
6
7
8
9
10
11
12
13
14
15
17
18
19
21
23
24
25
26
27
28
29
       
Today

Get NetBeans 5.5

Locations of visitors to this page

Today's Page Hits: 305


XML
All
/Creator
/General
/Hobby
/Java
/JavaScript
/Mozilla
/NetBeans
/Ubuntu
/VisualWeb
/VisualWebPack
/Web 2.0

XML
All
/Creator
/General
/Hobby
/Java
/JavaScript
/Mozilla
/NetBeans
/Ubuntu
/VisualWeb
/VisualWebPack
/Web 2.0

scblog
scblog