Geertjan's Blog

  • October 18, 2007

Stepping through Groovy in NetBeans IDE

Geertjan Wielenga
Product Manager
I put a breakpoint in the Java class I showed yesterday and am now able to step through the Groovy script, with the Local Variables window showing the current state of my Groovy variables:

Funnily enough, Scott Hickey, the main guy behind the Eclipse plugin for Grails and Groovy, is the one who worked with me in (a) coming up with the procedure I outlined yesterday and (b) thinking up the possibility of debugging Groovy, in the way demonstrated above! The Grails eXchange is definitely one of the best conferences I have been to, in terms of people freely exchanging ideas and learning from each other's insights and enthusiasms. The main message I'm going home with is the rather obvious realisation that Groovy is in a completely different category to any other scripting language, because of its relationship with Java. Hence, lots of stuff (such as the Java debugger, as indicated above) can simply be reused when working with Groovy. That insight should also inform the tooling provided for Groovy. The closer we stay to Java, the more we can get from it, the less we'll be reinventing the wheel, and the greater the chance that we'll be providing something truly useful for Groovy users in NetBeans IDE.

Join the discussion

Comments ( 5 )
  • Ramon Ramos Thursday, October 18, 2007

    very cool

  • Pan Feng Thursday, October 18, 2007


  • Peter Williams Friday, October 19, 2007

    JSR 223 doesn't support a debug api and since you did mention a groovy compiler in your post yesterday, I'm assuming you have compiled the groovy code to .class files that have debug information mapping back to the original groovy source.

    That would let you debug via JDPA certainly but then groovy is not being interpreted so for changes, you'd have to compile and then reload the classes (e.g. hot swap where possible, otherwise restart) vs. an interpreted scripting language (e.g. javascript via 223) where you can literally fix/change the code and keep going as if nothing happened.

    Also, are groovy variables typed and/or can their type change dynamically (e.g. x="foo" followed by x=1 being legal, though the type is changing from string to integer?) If so, is the NetBeans debugger displaying this change properly?

  • Jim White Monday, October 22, 2007


    The Groovy interpreter always performs compilation to bytecode on the fly so there is no need for a seperate compile to .class file step for using the debugger.

    And variables declared without a type ('def x' or 'x =') are implicitly defined as Object.

  • Gonzalo Tirapegui Monday, June 1, 2009

    Geertjan , can i make you a question?? , is it the debugger's netbeans API open to use it on a custom RCP application?? , i mean , can i use it into a small suite designed by me to take a java file , read it by retouche API, execute the constructor of the class and save the object's state at the end of the execution , all of this in design time??? , i ask you this cuz i'm developing a prototype of a Visual PHP Designer (as a degree thesis) based on xpcom-Gecko renderer , but i want to generate the preview based on the source code , not based on "xml's middle files" like Matisse does. If the answer is yes , can you give me some feedback about it?? thanks a lot!!! , Regards ... Gonzalo.

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