PROGRAM INTRODUCTION


We hope that by now you have enough knowledge on what a class file is all about.So lets begin to understand the program.

The bytecodes are in a specific format and we have to store them somewhere for future reference and manipulation. Hence, we have the structures which make things more simple. Here we are reading the bytes according to the length specified ie.,2 bytes or 4 bytes and store them into appropriate structures. For eg. the whole information is stored in the structure file , the structure meth stores the information of the methods present in the class file. Structure cinfo tells about the code present in the methods.

NOTE: Here interfaces and fields are assumed to be zero and hence interfaces, fields, line no. table are skipped.

The constant pool information is stored in an array. But as we know that in the constant pool the first member is the tag. According the tag value following bytes are read in various formats ( Refer constant pool explanation in "INTRODUCTION TO CLASS FILES").

In main(), we have a switch statement which checks for the tag value and according to the value the following bytes are read abd stored. The small() function to converts the bytes from Big Endian to Little Endian format as Intel microprocessor understands Little Endian format only. After storing the constant pool in an array, we continue further to read bytes abd store them according to the class file format.

The bytes may be stored as a string or an index into a constant pool. Ultimately we have to look for the string as it will give information about the class file. So, if we come across a tag whose following bytes are again an index to the constant pool, then again we have to check the case and read the bytes. The get() function dose the job of extracting the information (ie. string) from the constant pool. It will check whether the bytes after the tag are an index into the constant pool or an information. If it is an information, a pointer to it is returned abd if it's an index then the get() function goes into recursion where ultimately it comes across some information.

The program also contains some important functions like cview(), arrange() etc. which are discussed in DISASSEMBLER part.


Back to the main page


Vijay Mukhi's Computer Institute
VMCI, B-13, Everest Building, Tardeo, Mumbai 400 034, India
Tel : 91-22-496 4335 /6/7/8/9     Fax : 91-22-307 28 59
e-mail : vmukhi@giasbm01.vsnl.net.in
http://www.vijaymukhi.com