20.01.2014 Views

thesis - Faculty of Information and Communication Technologies ...

thesis - Faculty of Information and Communication Technologies ...

thesis - Faculty of Information and Communication Technologies ...

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 4. Measuring Evolving S<strong>of</strong>tware<br />

1 /∗∗ A simple method to print " Hello World" to console ∗/<br />

2 public void printHelloWorld ( )<br />

3 {<br />

4<br />

5 System . out . println ( " Hello World " ) ;<br />

6<br />

7 // Annotated bytecode instructions<br />

8 // Numbers that start with a # are the index into the constant pool<br />

9<br />

10 // getstatic #5; //LOAD Field java/lang/System. out : java/io/PrintStream<br />

11 // ldc #6; //LOAD String Hello World<br />

12 // invokevirtual #7; //CALL Method java/io/PrintStream . println<br />

13 // return<br />

14 }<br />

Listing 4.1:<br />

method<br />

Same <strong>of</strong> bytecode generated for a simple Hello World<br />

by zero or more oper<strong>and</strong>s which contain the values to be operated<br />

upon [180]. There are a total <strong>of</strong> 256 possible opcodes instructions that<br />

can be generated by the compiler <strong>and</strong> all <strong>of</strong> these instructions are embedded<br />

in the method body (see Table 4.1). We process the bytecode<br />

instructions <strong>and</strong> determine the nature <strong>of</strong> the operation in order to compute<br />

appropriate metrics. The sample code in Listing 4.1 for a “Hello<br />

World” method shows the set <strong>of</strong> bytecode instructions that are generated<br />

as comments within the method body. In this sample listing, there<br />

are 4 bytecode instructions generated from a single line <strong>of</strong> source code<br />

(three bytecode instructions take a single oper<strong>and</strong>, while one <strong>of</strong> the operations<br />

has zero oper<strong>and</strong>s). In our study, we process these bytecode<br />

instructions, as well as all <strong>of</strong> the other information embedded in the<br />

compiled class (as indicated in Table 4.1) to compute the various metrics.<br />

A fully annotated Java program is presented in Appendix D to<br />

further illustrate how our metric extraction approach counts the various<br />

metrics from the compiled class file.<br />

Differences between source code <strong>and</strong> compiled code<br />

Though, the compiled Java class is close to the source code, there are<br />

some differences:<br />

76

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!