> As you said "Every class, including
> SnapShot, has a static field "class" that is a reference to its
> java.lang.Class object."
At the language level, it's as if every object has a static class field.
In much the same way as an array has a length field. In fact, neither
field exists as such, although the data will be held within the object
header. class is a keyword, so grammatically it is a special case.
> So the below class Should also give me 4 fields.but it is printing me 3
> fileds only
It's vital with these sort of things that you give the exact code. Which
compiler and version you are using may also be important.
Given a class file, you can see the members a class has with javap
-private. Try it on a few of your classes.
You may see classes that use class literals (for instance
SnapShot.class), will have fields something like:
static java.lang.Class class$SnapShot;
static java.lang.Class class$SomeOtherClass;
The fields are lazily initialised reference to java.lang.Class objects,
obtained through Class.forName. You can use javap -c to see the byte
code that performs this.
If you target 1.5+ (the default from 1.5), the fields will not be
generated. Instead a new use of the ldc (load constant) byte code
operation will load the Class reference directly. The semantics change
slightly in that the class will not be caused to initialise (the static
initialiser will not be run).
Tom Hawtin

Signature
Unemployed English Java programmer
http://jroller.com/page/tackline/