On Dec 11, 12:27 pm, Keith Irwin <keith.ir...@gmail.com> wrote:
> Folks--
>
> I've got a class I can't change which has an abstract method I'd like
> to override using the proxy macro in Clojure.
>
> The class looks something like:
>
> public abstract class Foo {
>
>    private Map stuff;
>
>    private void initStuff() {
>
>        stuff = new HashMap();
>        stuff.put("a", new Object());
>        addStuff(stuff);
>    }
>
>    protected void abstract addStuff(Map stuff);
>  }
>
> Normally, you extend the above and implement the addStuff method.
> Works in Groovy as long as I explicitly state the void return type and
> the type of the parameters.
>
> In Clojure, I construct:
>
>    (proxy [Foo] []
>       (addStuff [stuff] (println "yay!")))
>
> But get an AbstractMethodError when I attempt to use the Foo class
> (calling a method which eventually calls addStuff).
>
> The docs suggest I can override a protected method class, but can't
> call other protected methods, which I think is fine, here.
>
> Is there something I'm missing?
>
> Keith

Given what you have written, the proxy function will return an
instance that extends Foo, implementing the addStuff method; it
doesn't modify the Foo class, nor provide you with a derived class.
If you want to create a derived class that's accessible from java,
you'll need to use something related to gen-class.

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to