I\'m trying to bind an interface to its implementation as read from a configuration file so that I can feed it to my IoC container. Here\'s roughly what I\'m trying to do:<
You can get the actual type arguments for a generic superclass of a class. This blog post explores the possibilities presented by this, including a nice little trick using trivial anonymous inner classes. To quote directly:
It turns out that while the JVM will not track the actual type arguments for instances of a generic class, it does track the actual type arguments for subclasses of generic classes. In other words, while a
new ArrayListis really just a() new ArrayList()at runtime, if a class extendsArrayList, then the JVM knows thatStringis the actual type argument forList's type parameter.