Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #25712
| From | Lew <noone@lewscanon.com> |
|---|---|
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: JLS 3/e -- Lots Of Errors |
| Date | 2011-02-04 23:59 -0500 |
| Organization | albasani.net |
| Message-ID | <iiilep$spb$2@news.albasani.net> (permalink) |
| References | <iiflvc$keg$2@lust.ihug.co.nz> <iii9ku$58c$1@lust.ihug.co.nz> |
On 02/04/2011 08:37 PM, Lawrence D'Oliveiro wrote:
> Here’s another fun one.
>
> In section 4.8, on page 58, it says:
>
> The use of raw types is allowed only as a concession to compatibility of
> legacy code. The use of raw types in code written after the introduction
> of genericity into the Java programming language is strongly
> discouraged. It is possible that future versions of the Java programming
> language will disallow the use of raw types.
>
> (That last sentence is in bold.) However, in the discussion on page 136:
>
> Note that expression names may be qualified by type names, but not by
> types in general. A consequence is that it is not possible to access a
> class variable through a parameterized type
> class Foo<T> {
> public static int classVar = 42;
> }
> Foo<String>.classVar = 91; // illegal
> Instead, one writes
> Foo.classVar = 91;
> This does not restrict the language in any meaningful way. Type
> parameters may not be used in the types of static variables, and so the
> actual parameters of a parameterized type can never influence the type
> of a static variable. Therefore, no expressive power is lost.
> Technically, the type name Foo above is a raw type, but this use of raw
> types is harmless, and does not give rise to warnings.
>
> So one the one hand raw types are deprecated, but on the other hand they are
> the only permitted way to access static fields of a parameterized type.
That is neither an error nor a typo, nor sloppy, but a precise description of
the actual rules.
You may think the rules are screwy, but the JLS itself is not sloppy nor
erroneous there.
--
Lew
Ceci n'est pas une fenêtre.
.___________.
|###] | [###|
|##/ | *\##|
|#/ * | \#|
|#----|----#|
|| | * ||
|o * | o|
|_____|_____|
|===========|
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar
Re: JLS 3/e -- Lots Of Errors Lawrence D'Oliveiro <ldo@geek-central.gen.new_zealand> - 2011-02-05 14:37 +1300
Re: JLS 3/e -- Lots Of Errors Joshua Cranmer <Pidgeot18@verizon.invalid> - 2011-02-05 00:15 -0500
Re: JLS 3/e -- Lots Of Errors Joshua Cranmer <Pidgeot18@verizon.invalid> - 2011-02-05 10:10 -0500
Re: JLS 3/e -- Lots Of Errors Lawrence D'Oliveiro <ldo@geek-central.gen.new_zealand> - 2011-02-05 19:41 +1300
Re: JLS 3/e -- Lots Of Errors Lew <noone@lewscanon.com> - 2011-02-04 23:59 -0500
Re: JLS 3/e -- Lots Of Errors Lawrence D'Oliveiro <ldo@geek-central.gen.new_zealand> - 2011-02-05 19:42 +1300
Re: JLS 3/e -- Lots Of Errors Lew <noone@lewscanon.com> - 2011-02-05 09:34 -0500
Re: JLS 3/e -- Lots Of Errors "javax.swing.JSnarker" <gharriman@boojum.mit.edu> - 2011-02-05 12:52 -0500
csiph-web