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

super used in method causes Verify error

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.0-beta-4
    • 1.0-beta-5
    • None
    • None
    • Version: 1.0-beta-4 JVM: 1.4.1_01-27; Mac OS X 10.3.3 powerbook 17" 1.33 GHz

    Description

      On the mail list, I asked about whether super was still broken and submitted the test case below. James responded "Sounds like a bytecode gen bug - would you mind raising a JIRA issue and we'll take a look real soon."

      This is the test case:
      SimpleModel.java
      public class SimpleModel {
      public String s;
      public SimpleModel ()

      { s="SimpleModel"; }

      public void setup(String str)

      { s=str; }

      public void show()

      { System.out.println(s); }

      }

      This works fine from groovy:
      tut.groovy:
      #!/usr/bin/env groovy
      public class TutModel extends SimpleModel {
      int count;
      public void TutModel()

      { count = 0; setup("TutModel"); }
      }
      SimpleModel simp = new SimpleModel()
      simp.show()
      simp.setup("Simp setup")
      simp.show()
      TutModel t = new TutModel()
      t.show()
      t.setup("t setup")
      t.show()
      simp.show()
      ..producing the correct output:
      owen|~/src/groovy[735]: ./tut.groovy
      SimpleModel
      Simp setup
      TutModel
      t setup
      Simp setup

      But when I add an overriding method for setup:
      tut.groovy:
      #!/usr/bin/env groovy
      public class TutModel extends SimpleModel {
      int count;
      public void TutModel() { count = 0; setup("TutModel"); }

      public void setup(String str)

      { count += 1; super.setup(str); }

      }
      SimpleModel simp = new SimpleModel()
      simp.show()
      simp.setup("Simp setup")
      simp.show()
      TutModel t = new TutModel()
      t.show()
      t.setup("t setup")
      t.show()
      simp.show()
      .. I get this:
      owen|~/src/groovy[736]: ./tut.groovy
      SimpleModel
      Simp setup
      Exception in thread "main" java.lang.VerifyError: (class: TutModel,
      method: setup signature: (Ljava/lang/String;)V) Unable to pop operand
      off an empty stack
      at java.lang.Class.forName0(Native Method)
      at java.lang.Class.forName(Class.java:140)
      at tut.class$(tut.groovy)
      at tut.run(tut.groovy:21)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      ...

      Attachments

        Activity

          People

            Unassigned Unassigned
            backspaces Owen Densmore
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: