Any word on reified generics in Java?

╄→尐↘猪︶ㄣ 提交于 2020-01-31 08:42:31

问题


I know this question will probably provoke more discussion than concrete answers (which I know isn't preferable). But with the recent acquisition by Oracle, I was wondering if there's been any word that Java might (someday) get reified generics? I've heard that Oracle wants to give Java a bit of a boost, and I can think of no better way.


回答1:


There's a good article on the discussion of reified generics, here, that you should read in regards to Java. Basically it outlines some of the pitfalls that might happen with the introduction of such a change. It's fairly brutal for backwards compatibility when you think about it. Picked it up on Hacker News if you're wondering where it came from.

Be grateful that there's talk of adding closures to Java. No more having to slog through with only things like Functional Java and their ilk (not that these were bad, on the contrary.)




回答2:


I don't know about the future beyond Java 7 but it looks like Reified Generics won't be in Java 7 (and if Oracle wants to give Java a bit of boost, they should start with releasing Java 7).




回答3:


Contrary to what almost everyone believe, reified Generics is possible in Java, which means that type erasure can be avoided. Actually, it is a trick or pure dark magic if you will.

I've written an article on this at

http://rgomes-info.blogspot.co.uk/2013/12/using-typetokens-to-retrieve-generic.html

In the end of the article there's a section on pros and cons of this trick. Actually, the correct thing would be having "proper" reified Generics in Java and not a trick like this... but unfortunately this is not the case.



来源:https://stackoverflow.com/questions/3359347/any-word-on-reified-generics-in-java

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!