Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / Virtual Machine / September 2005

Tip: Looking for answers? Try searching our database.

Reading "Programming for JVM"...  Class Area Question

Thread view: 
Will - 18 Aug 2005 00:21 GMT
Hi,

I'm interesting in studying the JVM, and I'm reading Joshua Engel's
book.  On page 7, he describes the class area.  I'm not clear on
exactly what this class area holds.  It says "Class area, where the
code and constants are kept".  Well, strictly speaking, the code is
only the bytecodes, right?  Which means that the class area supposedly
holds an area of bytecodes (with their immediate operands) in some kind
of array-like structure (each array being a constant size that holds
the opcode and immediate operand bytes for a single method.  Then, the
class area would supposedly be composed of an array of these arrays,
whose size is equal to the number of methods that a single class has.
And that's just talking about a single loaded class, not a bunch of
classes.  I'm struggling with the concept, and would appreciate a more
detailed description about the class area.  And, back to the constants
area... is there a one-to-one mapping between the contant pool in the
class file and the contant pool in the class area?  Is the constant
pool in the class area the same thing as the "runtime constant pool"
(as opposed to the static constant pool coded in the class file?  Also,
are other JVM attributes (besides the Code attribute) stored in the
class area?  Page 7 also says that a class has several properties, but
it doesn't say if these properties (Superclass, list of interfaces,
list of fields, etc... basically, looks like the format of an entire
class file) are stored in the class area.

Thanks,
- Will
Will - 18 Aug 2005 00:30 GMT
To add to that... it looks like the 5 things listed on p. 7 correspond
to different parts of the ClassFile structure, except I'm not clear
what happens to the other parts of the class file that are not listed
as one of the 5 things... for example, does the minor and major version
get stored in the class area?  How about all of the class attributes --
do they go into the class area too?  The access flags?  The
"this_class" ref?  The magic number?

Thanks,
- Will
Chris Uppal - 18 Aug 2005 08:23 GMT
> I'm interesting in studying the JVM, and I'm reading Joshua Engel's
> book.  On page 7, he describes the class area.  I'm not clear on
> exactly what this class area holds.  [...]

I think it's probably worth taking a step back and looking at this from a
slightly wider perspective.  I can't remember much detail about Engel's book,
but I don't remember that the "class area" concept really helps with anything
at all.

It may be worth emphasising that the .class file format has nothing to do with
the internal operation of a JVM implementation.  That format is an
implementation-independent /transfer/ format, and there is little chance of it
being very useful for anything else.  So the JVM will /parse/ that format, and
build up its own internal data structures containing equivalent data in
whatever format(s) and arrangements best suit its own implementation.

To give some examples:

The integer bitsets used to mark members as public/private/default/protected,
are inconvenient to use since "default access" has value 0 -- which makes code
that tests access permissions more complicated than it should be.

At the other end of the scale, the bytecodes themselves are overcomplicated and
underefficient.  A JVM that uses an interpreter might choose to rewrite them
into a more efficient internal format (maybe 16-bit).  It's possible that a
JITing JVM might translate them into a format that the JITer found easier to
handle, though I don't know whether that would actually be worth the extra
effort.  In any case, a JITing JVM would -- by definition -- translate (some
of) the bytecodes into machine-native form, and the resulting buffers of
machine-code would have to be stored, and linked to from the class/method
definitions.

As a last example, the "constants pool" in a class file is /only/ there as a
way of reducing the size of the classfile.  Its a compression technique,
nothing more.  There is no reason on God's earth why a JVM implementation would
want to keep it hanging around. (Which is another reason why the .classfile
bytecode format -- which refers to the constants pool -- is unsuitable for
direct interpretation.)

So the JVM will /extract/ the information that it wants from the classfile.
That will almost certainly end up being represented as things like hashtables,
lists, and arrays of whatever internal structures the JVM uses to represent
classes and methods.  (The instances of java.lang.Class would contain
internal -- hidden -- references to that data.)  That large and complicated
(set of) data structures is what Engle's (and the JVM spec too, IIRC) lump
together and call the "class area".  It has no real existence as anything
except an expository short-cut.

The bottom line is that the class area "contains" /everything/ that the JVM
needs to remember about classes in order to run.

   -- chris
getMadhur() - 11 Sep 2005 14:30 GMT
can u please let me know the title of the book you are reading. I am,
too, interested in reading about jvm. Thanks

-Regards
Madhur
Andrew Thompson - 11 Sep 2005 14:43 GMT
> can u please let me know the title of the book you are reading. I am,
> too, interested in reading about jvm. Thanks

The title of the book was/is hidden in the subject line..
'Programming for Java Vurtual Machine'.. but the lack of mention in
Amazon led me to Google it ...
<http://www.google.com/search?hl=en&lr=&c2coff=1&q=%22Programming+for+Java+Virtua
l+Machine%22+engel
>
..the information I saw (three links, two of which were to a
bookstore that had since changed that page) and a reference
to '99' makes me think the book must be 6 years old.

Signature

Andrew Thompson
physci.org 1point1c.org javasaver.com lensescapes.com athompson.info
"It's a never ending battle, for a peace that's always torn.."
Bob Dylan 'Shelter from the Storm'

A Pietu Pohjalainen - 20 Sep 2005 20:10 GMT
> Hi,

> I'm interesting in studying the JVM, and I'm reading Joshua Engel's
> book.  

Personally, I find the O'Reillys 'Java Virtual Machine' much clearer to
read on JVM concepts when compared to Engel's book. Engel's book
contribution is from chapter 10 onwards - how to implement different
languages when targeting to the JVM.

> On page 7, he describes the class area.  

What about reading some pages more ;)

> I'm not clear on exactly what this class area holds.  
> It says "Class area, where the code and constants are kept".  
> Well, strictly speaking, the code is only the bytecodes, right?  
 [lots of speculation deleted. what about using paragraphs in
  postings?]
> class file and the contant pool in the class area?  Is the constant
> pool in the class area the same thing as the "runtime constant pool"
> (as opposed to the static constant pool coded in the class file?  

He referring to JVM runtime view. Class area is the runtime storage of
classes, whatever its internal representation might be. Pages 8-20 give
elaboration on these concepts.

> Also, are other JVM attributes (besides the Code attribute) stored
> in the class area?  Page 7 also says that a class has several
> properties, but it doesn't say if these properties (Superclass,
> list of interfaces, list of fields, etc... basically, looks like
> the format of an entire class file) are stored in the class area.

Code is not a JVM attribute, but a method's attribute. Information on
class properties conceptually belongs to class area, as it is not
runtime stack information, heap information, or native method stacks.

For clarity on JVM definition, I really recommend the O'reillys book
over Venners' and Engel's. When writing my Java interpreter, I found the
O'reilly's one to be most accessible.

br,
Pietu Pohjalainen


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.