Sundararajan's Weblog

  • Java
    August 8, 2008

Scriptifying BTrace?

Guest Author

One of the issues reported with BTrace is that the trace authors have to write "verbose" code [some people say Java is "verbose"!]. In BTrace, we have to repeat the same set of imports, annotations in every btrace file and all methods have to be "public static void" and so on. Instead of inventing a new scripting language, I've added a simple C preprocessor like step in BTrace compilation. This preprocessor is based on the one in the GlueGen project. Thanks to Ken Russell for this code and for reviewing my changes specific to BTrace project. The preprocessor solution does not rule out a scripting solution in future :-) If you have nice ideas or would like contribute in this area, you are always welcome! But, I think preprocessor solution is simple and will be useful to some.

Simple Example:



To run this sample, the following command can be used:

btrace -I . <pid-of-the-traced-process> ThreadBean.java

Without the -I option in command line, BTrace skips the preprocessor step.

Join the discussion

Comments ( 2 )
  • Moinak Ghosh Friday, August 8, 2008

    Hey Man, Java is indeed verbose. You have to type a lot. However some things introduced in recent times have helped reduce some of the verbosity. In addition using Netbeans also helps in reducing typing as well.

  • A. Sundararajan Friday, August 8, 2008

    Hi Moinak: Hope you are having fun in the new place!!


    On verbosity: I'd rather prefer slightly verbose code compared to the one with lots of "defaults" and systems/languages that encourage writing terse/"too smart" code :-) But, that is just a preference - not everyone may agree.

Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.