Uploaded image for project: 'Lucee Development'
  1. LDEV-554

Stack overflow creating object instance while in the static constructor

    Details

    • Type: Bug
    • Status: Deployed
    • Priority: New
    • Resolution: Fixed
    • Affects Version/s: 5.0.0.66
    • Fix Version/s: 5.0.0.96
    • Labels:
    • Environment:

      Tomcat 8
      Java 1.8.0_60
      Windows Pro 64bit

      Description

      Given class

      Colors.lucee:

      class {
          static {
              public final RED = new Colors(255,0,0);
          }
      
          private r;
          private g;
          private b;
      
          package function init(numeric r, numeric g, numeric b) {
              this.r = argument.r;
              this.g = argument.g;
              this.b = argument.b;
          }
      }
      

      If I try to access Colors::RED from somewhere else, say index.lucee:

      <:dump var="#Colors::RED#" />
      

      I get a stack overflow error. I suspect the reason is that when the instance constructor is called directly from the static constructor block, the class is looked up again, causing the static block to execute again and thus the cycle repeats.

      I was hoping to use this as a pseudo-enumeration type.

        Attachments

          Activity

            People

            • Assignee:
              michaeloffner Michael Offner
              Reporter:
              dajester2015 Jesse Shaffer
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: