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.
- Download and install NetBeans IDE 5.5 and NetBeans Profiler 5.5.
- Follow these instructions to download javac source code and open it as a project in the IDE.
- 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. - Edit the javac buildscript
build.xml: append targetprofilefor example below targetbuild-bin.javac. - 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
profilein 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/applicationapp.mainclassfile:relative path to mainclass java file of profiled project/applicationapp.srcdir:relative path to profiled project/application source rootapp.builddir:relative path to profiled project/application compiled classes root

