开发者

Is there an updated javabean reflection library that includes generics?

开发者 https://www.devze.com 2022-12-23 18:18 出处:网络
Before re-inventing the wheel, I thought I\'d see if an开发者_高级运维yone is aware of an updated version of something like apache commons-beanutils (basically interested in using reflection-based ser

Before re-inventing the wheel, I thought I'd see if an开发者_高级运维yone is aware of an updated version of something like apache commons-beanutils (basically interested in using reflection-based services for populating and extracting bean values), especially one that supports generics.


I don't believe that there is any current library which allows reflection of Java generics. When Java generics were introduced in Java 1.5, they were implemented in the compiler but were not implemented in the VM. So you have a problem of type-erasure when trying to reflect upon a class which implements generics as the types are only visible at compile time and not at runtime. To see more about this and possible work-arounds, check out:

  • Super type tokens
  • Reflecting generics
  • Scala's way of working around reified types
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号