jastrachan | 26 Mar 07:28 2004
Picon

Re: Super?

On 25 Mar 2004, at 20:26, Owen Densmore wrote:
> Does "super" work yet in the CVS version of groovy?

Yes.

Sounds like a bytecode gen bug - would you mind raising a JIRA issue 
and we'll take a look real soon.

>  I ask because it is a show stopper for a local project here.
>
> 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)
> 				...
>
> Is this still a problem?  Is there a work around?
>
> 	-- Owen
>
> Owen Densmore         908 Camino Santander   Santa Fe, NM 87505
> Cell: 505-570-0168    Home: 505-988-3787     http://backspaces.net
>
> _______________________________________________
> groovy-user mailing list
> groovy-user@...
> http://lists.codehaus.org/mailman/listinfo/groovy-user
>
>

James
-------
http://radio.weblogs.com/0112098/

Gmane