Ob jective
OOSE, Workshop 2 Debugging Software Artefacts
In this coursework, you will learn how to use a debugger to analyse a simple software artefact. You would be able to analyse a debugger output for its soundness and precision for trivial program code. Finally, you would also be able to identify when it is more or less suitable to apply manual code inspection compared to automated debugging.
Setup
1. Download SpotBugs debugger binary files from http://spotbugs.readthedocs. io/en/latest/. To install and run the tool, follow the installation and running guide on the link. Successful installation and running of SpotBugs would generate a graphical user interface identical to Figure 1.
Figure 1: SpotBugs GUI
2. Next, download w2customreader.zip from Moodle. The zip file contains source code of two programs. The first is Util.java, this contains customCharReader method that reads first n characters from a file and swaps every even character with a blank then prints the output. For a file with less than n characters, the specification does not care about how many characters were actually read by the BufferedReader. It also contains charReplace method for swapping characters in a text. The second class is the Driver.java. This is responsible for taking an input
1
file from a user and calling the customCharReader method in Util.java with the value of n equals 7.
Using your Eclipse IDE, create java project and call it oosew2. Then create a package oose.w2 in the src folder. Copy the content of w2customreader.zip into the oose.w2 package.
3. Finally, use SpotBugs to analyse oosew2 project. This can be done by selecting File ¡ú New Project on SpotBugs menu bar. Click Add next to Classpath for analysis and navigate to choose your oosew2 project on Eclipse. Alternatively, you can export oosew2 on eclipse as a jar file and select the jar file by clicking the Add button. A successful project configuration on SpotBugs would look similar to Figure 2. Now click the analyse button, then inspect the results generated after analysis.
Figure 2: SpotBugs new project configuration
Tasks
1. Enumerate the bugs identified in Util.java using SpotBugs.
2. Based on the bugs report from (1), present an argument in not more than 100 words on whether the bug detection system is sound or unsound. Identify the lines of code in the program to justify your argument. If you argue that the system is sound, then you don¡¯t need to present any counterexample. If you argue that it is unsound, then you should give three counterexamples.
2
3. Based on the bugs report from (1), present an argument in not more than 100 words on whether the bug detection system is precise or imprecise. Identify the lines of code in the program to justify your argument. If you argue that the system is precise, then you don¡¯t need to present any counterexample. If you argue that it is imprecise, then you should give one counterexample.
4. Create a new version of the Util.java fixing identified bugs in Task 1. You should ignore imprecise bugs and include any additional ones you may have identified while checking the system for soundness.
Deliverables
Submission should be made electronically via Moodle for Workshop 2. You should turn in a zipped folder called xyz.zip, where xyz is your registration number. The folder should contain the following solutions:
1. A file called BugsReport xyz.pdf containing your solutions to tasks 1, 2 and 3. Clearly state at the top of the pdf document your name and registration number.
2. Your refactored Util.java containing solution to task 4. Ensure that the place holders for
Assessment
Coursework is due by 16.30 on 22nd Feb, 2019. and submissions will be marked out of 5 marks. Task 1 will be awarded a maximum of 0.5 mark, while tasks 2, 3 and 4 awarded a maximum of 1.5 marks each.
As per the Code of Assessment policy regarding late submissions, submissions will be accepted for up to 5 working days beyond due date. Any late submissions will be marked as if submitted on time, but reduced by 1 mark for each additional day. Submissions received more than 5 working days after the due date will receive an H (band value of 0).
Dr Inah Omoronyia, S152, School of Computing Science, University of Glasgow
3