24
Java problems Raw type parameters Working with the Java compiler Logging Static analysis CS/SE Individual Practical Stephen Gilmore November 11, 2011 School of Informatics, University of Edinburgh 1 / 24 CS/SE Individual Practical N

Fixing errors in Android Java applications

Embed Size (px)

Citation preview

Page 1: Fixing errors in Android Java applications

Java problems Raw type parameters Working with the Java compiler Logging Static analysis

CS/SE Individual Practical

Stephen Gilmore

November 11, 2011

School of Informatics, University of Edinburgh

1 / 24CS/SE Individual Practical

N

Page 2: Fixing errors in Android Java applications

Java problems Raw type parameters Working with the Java compiler Logging Static analysis

Java problems

Common Java problems: raw types

shot 2011-11-10 at 14.23.51.png

2 / 24CS/SE Individual Practical

N

Page 3: Fixing errors in Android Java applications

Java problems Raw type parameters Working with the Java compiler Logging Static analysis

Java problems

Quick fix: a bad suggestion

shot 2011-11-10 at 14.24.16.png

3 / 24CS/SE Individual Practical

N

Page 4: Fixing errors in Android Java applications

Java problems Raw type parameters Working with the Java compiler Logging Static analysis

Java problems

Check the constructor documentation

shot 2011-11-10 at 14.26.09.png

4 / 24CS/SE Individual Practical

N

Page 5: Fixing errors in Android Java applications

Java problems Raw type parameters Working with the Java compiler Logging Static analysis

Java problems

Check the class documentation

shot 2011-11-10 at 14.40.52.png

5 / 24CS/SE Individual Practical

N

Page 6: Fixing errors in Android Java applications

Java problems Raw type parameters Working with the Java compiler Logging Static analysis

Java problems

What type of array are we adapting?

shot 2011-11-10 at 14.26.30.png

6 / 24CS/SE Individual Practical

N

Page 7: Fixing errors in Android Java applications

Java problems Raw type parameters Working with the Java compiler Logging Static analysis

Java problems

Type parameter added

shot 2011-11-10 at 14.26.56.png

7 / 24CS/SE Individual Practical

N

Page 8: Fixing errors in Android Java applications

Java problems Raw type parameters Working with the Java compiler Logging Static analysis

Raw type parameters

Raw type in method header

shot 2011-11-10 at 14.57.11.png

8 / 24CS/SE Individual Practical

N

Page 9: Fixing errors in Android Java applications

Java problems Raw type parameters Working with the Java compiler Logging Static analysis

Raw type parameters

Consult the Java documentation

shot 2011-11-10 at 14.59.44.png

9 / 24CS/SE Individual Practical

N

Page 10: Fixing errors in Android Java applications

Java problems Raw type parameters Working with the Java compiler Logging Static analysis

Raw type parameters

Adapter doesn’t work here

shot 2011-11-10 at 14.58.23.png

10 / 24CS/SE Individual Practical

N

Page 11: Fixing errors in Android Java applications

Java problems Raw type parameters Working with the Java compiler Logging Static analysis

Raw type parameters

Adapter is an interface

shot 2011-11-10 at 15.00.03.png

11 / 24CS/SE Individual Practical

N

Page 12: Fixing errors in Android Java applications

Java problems Raw type parameters Working with the Java compiler Logging Static analysis

Raw type parameters

T is not a class

shot 2011-11-10 at 15.29.34.png

12 / 24CS/SE Individual Practical

N

Page 13: Fixing errors in Android Java applications

Java problems Raw type parameters Working with the Java compiler Logging Static analysis

Raw type parameters

Object: the goto class

shot 2011-11-10 at 14.58.06.png

13 / 24CS/SE Individual Practical

N

Page 14: Fixing errors in Android Java applications

Java problems Raw type parameters Working with the Java compiler Logging Static analysis

Raw type parameters

T extends Adapter doesn’t work

shot 2011-11-10 at 15.29.09.png

14 / 24CS/SE Individual Practical

N

Page 15: Fixing errors in Android Java applications

Java problems Raw type parameters Working with the Java compiler Logging Static analysis

Raw type parameters

“?” — the wild card parameter

shot 2011-11-10 at 15.44.02.png

15 / 24CS/SE Individual Practical

N

Page 16: Fixing errors in Android Java applications

Java problems Raw type parameters Working with the Java compiler Logging Static analysis

Raw type parameters

“Quick fix” would have worked here

shot 2011-11-10 at 16.11.46.png

16 / 24CS/SE Individual Practical

N

Page 17: Fixing errors in Android Java applications

Java problems Raw type parameters Working with the Java compiler Logging Static analysis

Raw type parameters

Same result

shot 2011-11-10 at 16.11.57.png

17 / 24CS/SE Individual Practical

N

Page 18: Fixing errors in Android Java applications

Java problems Raw type parameters Working with the Java compiler Logging Static analysis

Working with the Java compiler

Setting Java compiler preferences

shot 2011-11-11 at 09.00.58.png

18 / 24CS/SE Individual Practical

N

Page 19: Fixing errors in Android Java applications

Java problems Raw type parameters Working with the Java compiler Logging Static analysis

Working with the Java compiler

Changing defaults

shot 2011-11-11 at 09.01.20.png

19 / 24CS/SE Individual Practical

N

Page 20: Fixing errors in Android Java applications

Java problems Raw type parameters Working with the Java compiler Logging Static analysis

Working with the Java compiler

Potential programming problems

shot 2011-11-11 at 09.01.34.png

20 / 24CS/SE Individual Practical

N

Page 21: Fixing errors in Android Java applications

Java problems Raw type parameters Working with the Java compiler Logging Static analysis

Working with the Java compiler

Tighter checking

shot 2011-11-11 at 09.02.19.png

21 / 24CS/SE Individual Practical

N

Page 22: Fixing errors in Android Java applications

Java problems Raw type parameters Working with the Java compiler Logging Static analysis

Working with the Java compiler

Bug found

shot 2011-11-11 at 09.10.40.png

22 / 24CS/SE Individual Practical

N

Page 23: Fixing errors in Android Java applications

Java problems Raw type parameters Working with the Java compiler Logging Static analysis

Logging

Don’t forget to add logging . . .

shot 2011-11-11 at 10.41.02.png23 / 24

CS/SE Individual Practical

N

Page 24: Fixing errors in Android Java applications

Java problems Raw type parameters Working with the Java compiler Logging Static analysis

Static analysis

Deeper analysis (resource leaks . . . )

shot 2011-11-11 at 10.49.22.png

24 / 24CS/SE Individual Practical

N