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

bad constructor in generating classes for 'loose' scripts

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Critical
    • Resolution: Fixed
    • 1.0-beta-5
    • 1.0-beta-6
    • class generator
    • None

    Description

      The ModuleNode.createStatementsClass() seems add a constructor that calls the super's constructor with a Binding object, which does not exist.

      It looks like this after decompiled by Jad.

      public FuncLoose(Binding binding)

      { super(binding); }

      The code won't compile of course.

      I tried changing the logic in the createStatementClass() to look like this:

      classNode.addConstructor(
      ACC_PUBLIC,
      new Parameter[]

      { new Parameter(Binding.class.getName(), "context")}

      ,
      new ExpressionStatement(
      new MethodCallExpression(
      new VariableExpression("super"),
      "setBinding",
      new ArgumentListExpression(
      new Expression[]

      { new VariableExpression("context")}

      ))));

      This time it generates the constructor in the right form:

      public FuncLoose(Binding binding)

      { super.setBinding(binding); }

      Unfortunately it won't run, with a verfication error:

      java.lang.VerifyError: (class: FuncLoose, method: <init> signature: (Lgroovy/lang/Binding;)V) Expecting to find object/array on stack

      There must be inconsistency somewhere...

      Attachments

        Activity

          People

            jstrachan James Strachan
            bingran Bing Ran
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: