Re: class/getClass()
Dennis wrote:
In class Object, getClass() returns a Class object representing
whatever object the method was called on. In something like:
initialize(UserContext.class);
protected void initialize (Class cls){
initializeAtributes(cls);
initializeDomains(cls);
}
something similar appears to be happening with _class_. What is this
and where is _class_ defined? It looks like UserContext, or something
it's extending, has an attribute named _class_, but I don't see it
anywhere. Also, MyEclipse highlights this along with other java
keywords. I've poked around the language specification but couldn't
find anything about it.
The `class' keyword, when used like a static variable, returns an object
of type Class<T> (where T is the type name to which it is attached) [1].
Typically, Class objects are used for reflection purposes, although they
are occasionally used for other purposes.
[1] There is a slight bug in the Java compiler whereby List.class
returns Class<List> and not Class<List<?>> (List<?>.class does not
work); this has previously caused at least me some enormous grief.
--
Beware of bugs in the above code; I have only proved it correct, not
tried it. -- Donald E. Knuth