Uploaded image for project: 'Apache Freemarker'
  1. Apache Freemarker
  2. FREEMARKER-214

New LookAheadSuccess instance created for each instance of FMParser

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 2.3.33
    • None
    • None

    Description

      Each instance of FMParser creates a new instance of LookAheadSuccess.

      In our case, where we tend to work with a lot of FreeMarker templates (in some cases generating freemarker template as an intermediate representation of a more abstract form), this has had a couple of impacts:
      1. LookAheadSuccess extends java.lang.Error which adds noise to our Java Flight Recorder recordings, similar to the situation described in http://hirt.se/blog/?p=1288
      2. Each instance fills in a stack trace, causing unnecessary object allocation, given that

       

      These issues (non-static LookAheadSuccess instance, extending java.lang.Error, populating a stack trace) have been addressed in JavaCC 7 in the following PR
      https://github.com/javacc/javacc/pull/99/files

       

      If it seems reasonable, I would be willing to create a PR to update FreeMarker 2.3 to Java CC 7.x. The unit tests do seem to pass with Java CC 7.

       

      If upgrading JavaCC is deemed undesirable, the approach used to make the class static in https://github.com/apache/freemarker/blob/2.3-gae/build.xml#L157 could probably also be used to make the instance final.

      Attachments

        1. javacc-7.1.2-diff.txt
          37 kB
          Donnchadh Ó Donnabháin

        Activity

          People

            Unassigned Unassigned
            donnchadh Donnchadh Ó Donnabháin
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0h
                0h
                Logged:
                Time Spent - 50m
                50m