Any word on reified generics in Java?

2019-03-27 03:33发布

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.

3条回答
爷的心禁止访问
2楼-- · 2019-03-27 04:04

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楼-- · 2019-03-27 04:14

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.

查看更多
走好不送
4楼-- · 2019-03-27 04:31

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

查看更多
登录 后发表回答