sim, I don't think it is possible right now.  I am not an expert, but...

On Fri, Mar 2, 2012 at 5:04 AM, Daniel Solano Gomez <cloj...@sattvik.com> wrote:
> Yes, it is possible.  At the byte-code level there is (at least at
> run-time) no difference between a generic and a non-generic class.  All
> methods take/return the generic type just use Object.

This is mostly true, but for the use case needed, deriving from a
parameterized superclass, the JVM does track the parameterized
generic.  Class.getGenericSuperclass returns a ParameterizedType for
Classes extending a parameterized generic.

I would like this functionality as well for writing a Dropwizard
service in Clojure.  The Dropwizard framework relies on reflecting on
the parameter of a parent, and this doesn't seem possible in Clojure
right now.  Writing a Java shim to do the inheritance also won't work
with the current version of Dropwizard (though perhaps that is a
design bug in the framework).

I've taken a look at how annotations are done in generate-class, and
would like input on the best way to add this functionality.  My rough
plan is:

- Create an implementation of ParameterizedType for Clojure
- Add a metadata argument to the symbol passed to gen-class :extends
or :implements
- when that metadata is present, override getGenericSuperclass in the
generated class to return the ParameterizedType

Is this reasonable?  Are there other areas that need to expose generic
parameters?

Jim

http://docs.oracle.com/javase/6/docs/api/java/lang/Class.html#getGenericSuperclass()
https://github.com/codahale/dropwizard/blob/master/dropwizard-core/src/main/java/com/yammer/dropwizard/AbstractService.java#L75

-- 
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