Nat Mills wrote:
> I found it interesting that int.class returns "int" --

Actually, to be perfectly accurate (and maybe a little pendantic :-), the
value of int.class is the instance of java.lang.Class elsewhere represented
as java.lang.Integer.TYPE (look it up in the API javadocs).

> I'd never have
> thought to try this as I've never considered native types to be classes,
> just arrays of native types...

And you would be very close to competely completely correct to think so.
Primative (native) types are not the same as class types.  If you draw out
the hierarchy as explained in the language spec, it looks like this:
    o   ALL TYPES:
        o   Primative types
        o   Reference types:
            o   Class types (includes interfaces)
            o   Array types
            o   Null type (special case for the "null" literal,
                freely casts type to any reference type)

As the Java language reflection features have evolved (especially from
version 1.0 to version 1.1), the meaning of the class java.lang.Class has
strayed quite a bit from its original intent, which was to provide metaclass
information and features for "class types".  Rather than refactor
java.lang.Class into an inheritance hierarchy that would match the spec, the
developers expanded the reach of instances of java.lang.Class to encompass
other categories of types from the spec, including, since Java 1.1,
primative types.

Conceptually you would think that a java.lang.Class instance would represent
the metaclass for only a "class type". But the fact of the matter is rather
different.  A java.lang.Class instance can represent the *METATYPE* for any
Java type except the null type.

-- Roger Glover
   [EMAIL PROTECTED]



____________________________________________________
To change your JDJList options, please visit:
http://www.sys-con.com/java/list.cfm

Be respectful! Clean up your posts before replying
____________________________________________________

Reply via email to