Profile Javac!

Two weeks ago Sun Microsystems announced opensourcing key Java implementations including javac, the Java programming language compiler. You can get the javac source code also from netbeans.org with a detailed tutorial to getting, building, and running the javac sources in NetBeans IDE.

Since the javac sources are available as NetBeans project inside the IDE, you can easily build and run the compiler as well as investigate how things work inside. For this the Profiler can be also useful showing you the stack traces and other information about compiler's runtime. Just follow these five simple steps to check out how easy is now to profile javac.

  1. Download and install NetBeans IDE 5.5 and NetBeans Profiler 5.5.
  2. Follow these instructions to download javac source code and open it as a project in the IDE.
  3. Create sample J2SE project in the IDE using New Project wizard: category Samples/General, project Anagram Game. For the following instructions the project is expected to be located in C:\\AnagramGame.
  4. Edit the javac buildscript build.xml: append target profile for example below target build-bin.javac.
  5. Set javac project as the Main project and invoke the Profile Main Project action. Choose Java platform for profiling (most likely the Default one) and select the profiling task you want to use. After clicking the Run button the Profiler asks you to select the ant target for profiling - choose profile in the combo and click OK.

That's all - now you are profiling compilation of Anagram Game by the javac!

Note: The above scenario is for Windows and Anagram Game project. If you want to profile compilation of other project/application on other operating system, you need to modify (some of) following target properties:

  • app.dir: root directory of profiled project/application
  • app.mainclassfile: relative path to mainclass java file of profiled project/application
  • app.srcdir: relative path to profiled project/application source root
  • app.builddir: relative path to profiled project/application compiled classes root
Comments:

Post a Comment:
  • HTML Syntax: NOT allowed
About

A blog by NetBeans Profiler & VisualVM developers.

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