Groups | Search | Server Info | Keyboard shortcuts | Login | Register
Groups > comp.lang.java.programmer > #4554
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail |
|---|---|
| From | Susan Calvin <s.calvin@usr.invalid> |
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: Java generics and type erasure |
| Date | Wed, 25 May 2011 00:13:08 +0000 (UTC) |
| Organization | A noiseless patient Spider |
| Lines | 30 |
| Message-ID | <irhhik$9rc$3@dont-email.me> (permalink) |
| References | <9d4c2b16-beb5-40b1-87a2-f03e971efeed@k17g2000vbn.googlegroups.com> <nospam-871A48.22542123052011@news.aioe.org> <irfgkl$lca$1@news.albasani.net> <Xns9EEF8515AF3B6vaj4088ianshef@138.125.254.103> <irh6kb$gse$1@news.albasani.net> <Xns9EEFA3AE378DDvaj4088ianshef@138.125.254.103> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=UTF-8 |
| Content-Transfer-Encoding | 8bit |
| Injection-Date | Wed, 25 May 2011 00:13:08 +0000 (UTC) |
| Injection-Info | mx04.eternal-september.org; posting-host="cNpCepq5ls7RITQAmvxvhg"; logging-data="10092"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+qgBcpd+GaYSJ6DSTAAihxXd54904RmaE=" |
| User-Agent | slrn/3.1 (USERIX 1.7) |
| Cancel-Lock | sha1:rhXdlq0bwwczpvjavumm7GweH2A= |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:4554 |
Show key headers only | View raw
On Tue, 24 May 2011 23:05:25 +0000, Ian Shef wrote:
> "The type of a constructor (§8.8), instance method (§8.8, §9.4), or non-
> static field (§8.3) M of a raw type C that is not inherited from its
> superclasses or superinterfaces is the erasure of its type in the
> generic declaration corresponding to C."
This seems silly to me. I mean, if you have a class that starts:
public class Foo <T> {
public Map<String,Integer> m1;
public Map<String,T> m2;
then the logical way to deal with a raw Foo is to treat it as if T were ?
(or ? extends whatever its lower type bound was, or etc.), so in
Foo aFoo = new Foo();
aFoo.m1 would have compile-time type Map<String,Integer> (since no matter
what T was, it would be a Map<String,Integer>) and aFoo.m2 would have
compile-time type Map<String,?> -- disallowing puts and having gets have
type ?, assignable only to Object, but still recognizing the key type as
String.
The only reason I can think of for not doing this (the logic seems simple
enough to implement) is that it turned out doing so would break legacy
code that used util collections' raw types. Was that why? Perhaps there
should be a compile flag that turns on the legacy-compatible behavior for
use when compiling 1.4 and older sources, but which is off by default?
Though I guess it's too late for that now. :P
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar
Java generics and type erasure Marcin Pietraszek <m.pietraszek@gmail.com> - 2011-05-23 13:18 -0700
Re: Java generics and type erasure "John B. Matthews" <nospam@nospam.invalid> - 2011-05-23 22:54 -0400
Re: Java generics and type erasure Lew <noone@lewscanon.com> - 2011-05-24 01:45 -0400
Re: Java generics and type erasure Marcin Pietraszek <m.pietraszek@gmail.com> - 2011-05-24 12:39 -0700
Re: Java generics and type erasure Ian Shef <invalid@avoiding.spam> - 2011-05-24 20:04 +0000
Re: Java generics and type erasure Lew <noone@lewscanon.com> - 2011-05-24 17:06 -0400
Re: Java generics and type erasure Ian Shef <invalid@avoiding.spam> - 2011-05-24 23:05 +0000
Re: Java generics and type erasure Susan Calvin <s.calvin@usr.invalid> - 2011-05-25 00:13 +0000
Re: Java generics and type erasure Lawrence D'Oliveiro <ldo@geek-central.gen.new_zealand> - 2011-05-26 10:18 +1200
Re: Java generics and type erasure Susan Calvin <s.calvin@usr.invalid> - 2011-05-26 01:12 +0000
Re: Java generics and type erasure Lawrence D'Oliveiro <ldo@geek-central.gen.new_zealand> - 2011-05-26 13:59 +1200
Re: Java generics and type erasure Susan Calvin <s.calvin@usr.invalid> - 2011-05-26 04:18 +0000
Re: Java generics and type erasure Lawrence D'Oliveiro <ldo@geek-central.gen.new_zealand> - 2011-05-26 18:48 +1200
Re: Java generics and type erasure Esmond Pitt <esmond.pitt@bigpond.com> - 2011-05-26 18:34 +1000
Re: Java generics and type erasure Lew <noone@lewscanon.com> - 2011-05-26 07:45 -0400
Re: Java generics and type erasure "John B. Matthews" <nospam@nospam.invalid> - 2011-05-26 15:25 -0400
Re: Java generics and type erasure Esmond Pitt <esmond.pitt@bigpond.com> - 2011-05-27 12:01 +1000
Re: Java generics and type erasure Lew <noone@lewscanon.com> - 2011-05-26 22:15 -0400
Re: Java generics and type erasure Esmond Pitt <esmond.pitt@bigpond.com> - 2011-05-27 13:04 +1000
Re: Java generics and type erasure Lew <noone@lewscanon.com> - 2011-05-27 01:27 -0400
Re: Java generics and type erasure Esmond Pitt <esmond.pitt@bigpond.com> - 2011-05-27 18:07 +1000
Re: Java generics and type erasure Lew <noone@lewscanon.com> - 2011-05-27 10:18 -0400
Re: Java generics and type erasure Andreas Leitgeb <avl@gamma.logic.tuwien.ac.at> - 2011-05-27 17:03 +0000
Re: Java generics and type erasure Lew <noone@lewscanon.com> - 2011-05-27 13:27 -0400
Re: Java generics and type erasure Esmond Pitt <esmond.pitt@bigpond.com> - 2011-05-30 15:19 +1000
Re: Java generics and type erasure Tom McGlynn <taqmcg@gmail.com> - 2011-05-26 19:53 -0700
Re: Java generics and type erasure Lew <noone@lewscanon.com> - 2011-05-27 01:30 -0400
Re: Java generics and type erasure Esmond Pitt <esmond.pitt@bigpond.com> - 2011-05-27 18:09 +1000
Re: Java generics and type erasure Lew <noone@lewscanon.com> - 2011-05-27 10:22 -0400
Re: Java generics and type erasure Esmond Pitt <esmond.pitt@bigpond.com> - 2011-05-30 15:23 +1000
Re: Java generics and type erasure Lew <noone@lewscanon.com> - 2011-05-30 02:35 -0400
csiph-web