Generics & Reification Was Code Review Request: 7157893: Warnings Cleanup in java.util.*
Stuart Marks
stuart.marks at oracle.com
Fri Apr 13 01:33:52 UTC 2012
On 4/11/12 4:42 AM, Rémi Forax wrote:
> On 04/07/2012 02:35 AM, Stuart Marks wrote:
>> In order to program effectively with generics, I think you have to understand
>> erasure and its implications. It may have been an unfortunate choice, but
>> erasure is part of the language and we have to deal with it and in some cases
>> rely on it. I don't think it's merely an "implementation glitch."
>
> Erased casts are an implementation glitch, not the erasure by itself.
>
>> The difficulty I have with reification is that while there are proposals
>> floating around for how it could be done, nobody really knows how it will
>> eventually turn out, nor whether it will actually be done. If it is
>> eventually done, there will legal and illegal constructs, constructs that
>> generate warnings, and perhaps a style guide for how to use reified generics
>> properly.
>>
>> Right now, we can *imagine* what these future rules might be, but it seems
>> untenable to me to try to make today's code conform to those imaginary future
>> rules, especially in the absence of tools to help support those rules.
>
> There are several implementations that exist,
> here is the publicly available papers.
>
> M. Cimadamore and M. Viroli.
> Reifying wildcards in Java using the EGO approach.
> In SAC '07: Proceedings of the 2007 ACM symposium on
> Applied computing, pages 1315{1322, New York, NY, USA,
> 2007. ACM.
>
> M. Cimadamore and M. Viroli.
> On Reication of Java Wildcards.
> Science of Computer Programming, 2008
There's also Neal Gafter's blog post on the subject [1].
I haven't read these papers. Maybe I should just ask Maurizio about them. :-) I
guess, is there enough commonality among all of these, and enough confidence
that future-Java's generics reification will be similar to these, that today we
should make coding style decisions based on future-Java?
I can sort-of see it if there's a choice to be made in circumstances like the
following. Suppose we need to choose between a code fragments A and B where
they're more-or-less equivalent in an erased world but B is clearly better in
some future-Java world. Sure, we could choose B, I don't see the harm in it.
I'm just not convinced that we know enough about future-Java to make a strong
case for B.
s'marks
[1] http://gafter.blogspot.com/2006/11/reified-generics-for-java.html
More information about the core-libs-dev
mailing list