D
Dale King
Chris said:Dale King wrote ...
In either case, 4.5 is very specific: a parameterized type is a class or
interface name, and then a list of type parameters. No arrays are
possible, whether are not arrays are also considered to have type
parameters.
I did some more reading and think perhaps it is not a question of
whether it is parameterized, but whether it is reifiable. And I must say
that the reifiable discussion is very fuzzy to me. They have a section
in chapter 4 on it, but the word is not even used in chapter 5.
The question is whether you consider ArrayList[] to be a raw type. 4.8
says a raw type is "The name of a generic type declaration used without
any accompanying actual type parameters." I think that would be
applicable. This gives us a path through section 5.2 (identity
conversion followed by unchecked conversion because it is a raw type).
At the end of chapter 10 on arrays in the section on the runtime
ArrayStoreException it has a discussion section that says:
"If the element type of an array were not reifiable (§4.7), the virtual
machine could not perform the store check described in the preceding
paragraph. This is why creation of arrays of non-reifiable types is
forbidden. One may declare variables of array types whose element type
is not reifiable, but any attempt to assign them a value will give rise
to an unchecked warning (§5.1.9)."
According to 4.7 ArrayList<Node>[] is not reifiable and so any attempt
to assign to it should give the unchecked warning. It would be nice if
this information were incorporated into section 5.1.9.
I have a print copy of the JLS 3rd edition, so it is published at least
under the common definition of that term. If it's still tentative,
that's interesting. I haven't seen anything like that.
I'm just going by what the website said. I see now that it is just out
of date information since it says "the physical book should be available
in June 2005."
It would still be a good idea to provide feedback that they might add
some errata or clarification.