Eric Sosman wrote:
[ SNIP ]
Also, it appears that `void' is not a "type" in Java. That
may be a controversial position (i.e., I may have to eat my
words), but note that `void' is not listed as a type anywhere
in JLS 4. The description of java.lang.Void says it's a place-
holder for "the Java *keyword* [emphasis mine] void," not for
a type. So `void' has an entirely different status in Java than
in C, where it's a full-fledged (but rather special) "type." An
argument that `void' in Java should behave like `void' in C seems
to me to be on shaky ground; one might make a similar argument
about `goto'!
[ SNIP ]
My reading of the JLS leads me to the same conclusion as you, that
"void" is not a Java type (primitive). As you pointed out, it's a keyword.
I figure it's best to stay away from type theory with 'void' and 'Void'.
Most people that do stray down this road think of Java 'void' as being
somewhat like an empty (zero/bottom) type. But since a bottom type means
the lack of a normal return, Java 'void' isn't probably a real empty
type, and I've seen some folks say that it's more of a unit type. And if
you really, really have to draw that wrapper parallel between 'void' and
java.lang.Void, and 'Void''s' uses in reflection and generics, that
seems to reinforce the interpretation that the unit type concept is
perhaps more apt.
And then you've got void.class, of which the type is Class<Void>. :-)
My way of thinking about it - if type theory had to be brought into it -
is that both 'void' and 'Void' are unit types that express "nothing that
matters to me".
Ever since generics entered Java, thinking in terms of type theory has made sense
for Java programming, not that it didn't before.
Arved's analysis gives signposts for further research, at least I will take it that way.