Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-3071

include example of observing and editing compilation phase during class loading

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 1.6-beta-2
    • 1.6-rc-1, 1.5.8, 1.7-beta-1
    • None
    • None
    • I've attached an example which has been tested on Xandros Linux and Windows XP. Works fine with latest build of source.
    • Patch

    Description

      I've attached an example of observing the compilation process.
      This came out of the discussion here: http://www.nabble.com/Groovy-as-arithmetic-expression-evaluator--to19459935.html

      This example code is in /src/examples/groovyShell

      The class is called ArithmeticShell. "The arithmetic shell is similar to a GroovyShell in that it can evaluate text as code and return a result. It is not a subclass of GroovyShell because it does not widen the contract of GroovyShell, instead it narrows it. Using one of these shells like a GroovyShell would result in many runtime errors." It should how to observe the compilation process and how to walk the AST.

      I did not do a static import on java.lang.Math because it was a hassle to test. I did not extend CodeVisitorSupport for reasons stated in the Javadoc.

      It includes a GroovyTestCase but does not include an Ant script to build it.

      Perhaps this can help someone.

      Attachments

        Activity

          People

            guillaume Guillaume Sauthier
            hamletdrc Hamlet D'Arcy
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: