SETM LAB 5:)
2009 AUG 21

cd "Z:\SETM lab5"

Bytecodeparser
->constant pool symbol table

Z:\SETM lab5>java setm.metrics.ByteCodeParser

open ->prac4.class

-------------------------output------------------------

Constant Pool Symbol Table
Entry Tag Value
0 undefined (0) undefined
1 CONSTANT_Utf8 bytes=
2 CONSTANT_Utf8 bytes=()V
3 CONSTANT_Utf8 bytes=mystery
4 CONSTANT_Utf8 bytes=(II)I
5 CONSTANT_Utf8 bytes=Code
6 CONSTANT_Utf8 bytes=
7 CONSTANT_NameAndType name[0x6]= descriptor[0x2]=()V
8 CONSTANT_Utf8 bytes=java/lang/Object
9 CONSTANT_Classref index[0x8]=java/lang/Object
a CONSTANT_Methodref class[0x9]=java/lang/Object NameAndType[0x7]
= ()V
b CONSTANT_Utf8 bytes=SourceFile
c CONSTANT_Utf8 bytes=Prac4
d CONSTANT_Classref index[0xc]=Prac4
e CONSTANT_Utf8 bytes=prac04.java

end of ConstantPoolTable


Parsing classs area in class files is not supported in this version


Z:\SETM lab5>java setm.gui.HexViewer


------------------output----------------------


0: ca fe ba be 00 03 00 - 00 0f 01 00 08 < c l
15: i n i t > 01 00 03 ( ) V 01 00 07 m y
31: s t e r y 01 00 05 ( I I ) I 01 00 04
47: C o d e 01 00 06 < i n i t > 0c 00 06
63: 00 02 01 00 10 j a v a / l a n g / O
79: b j e c t 07 00 08 0a 00 09 00 07 01 00 0a
95: S o u r c e F i l e 01 00 05 P r a
111: c 4 07 00 0c 01 00 0b p r a c 0 4 . j
127: a v a 00 ! 00 0d 00 09 00 00 00 00 00 02 00
143: 09 00 03 00 04 00 01 00 05 00 00 00 15 00 02 00
159: 02 00 00 00 09 1a 1b a2 00 05 1a ac 1b ac 00 00
175: 00 00 00 01 00 06 00 02 00 01 00 05 00 00 00 11
191: 00 01 00 01 00 00 00 05 * b7 00 0a b1 00 00 00
207: 00 00 01 00 0b 00 00 00 02 00 0e

magic: ca fe ba be
minor version: 00 03
major version : 00 -
constant pool count : 00 0f -15
-----------------------------
inside constant pool table we need to have 130 bytes:
-----------------------------

access flags: 00 0! public
name of the class :00 0d Prac4
name of the super_class : 00 09 java/lang/object
the number of interfaces implemented : 00 00
the number of fields :00 00
the number of methods:00 02

---------------Methods-------------
-------------------------------------------------------------------------
*****Constructor methods cannot analysed **********
-------------------------------------------------------------------------
2 methods -constructor class & mystery method
-------------------------------------------------------------------------
• access flags :00 09 public static
• name of the class :00 03 mystery
• return type and the types of all parameters :00 04(I I)I

return type: integer Parameter types: integer (2 parameters)
attribute-00 01
• the number of bytes in the code attribute



code length=00 00 00 09

1a 1b a2 00 05 1a ac 1b ac


--------------------------------Part 6----------------------------------

Z:\SETM lab5>javap -l -c Prac4

--------------------------------output----------------------------------


Compiled from "prac04.java"
public class Prac4 extends java.lang.Object{
public static int mystery(int, int);
Code:
0: iload_0
1: iload_1
2: if_icmpge 7
5: iload_0
6: ireturn
7: iload_1
8: ireturn




public Prac4();
Code:
0: aload_0
1: invokespecial #10; //Method java/lang/Object."":()V
4: return




}


------------------------------------



• Determine the number of return statements contained in method. = 2
• Determine if this method follows generally accepted coding standards and justify your answer.

Labels:

0 Responses so far.

Sri Lanka .NET 
                Forum Member