Getting T.class despite Java's type-erasure

后端 未结 5 866
小鲜肉
小鲜肉 2020-11-30 11:24

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

5条回答
  •  被撕碎了的回忆
    2020-11-30 11:35

    No it's not possible.

    The only exception to Java's type erasure is that via reflection you can find out the parameterized type via reflection on a class's fields.

提交回复
热议问题