Accurate Polymorphism Detection Nevena Milojkovi Software - - PowerPoint PPT Presentation

accurate polymorphism detection
SMART_READER_LITE
LIVE PREVIEW

Accurate Polymorphism Detection Nevena Milojkovi Software - - PowerPoint PPT Presentation

Accurate Polymorphism Detection Nevena Milojkovi Software Composition Group University of Bern Problem public static void main(String[] args){ AttributeFigure figure = new ComponentFigure(); figure.basicDisplayBox( point1, point2); }


slide-1
SLIDE 1

Accurate Polymorphism Detection

Nevena Milojković Software Composition Group University of Bern

slide-2
SLIDE 2

Problem

public static void main(String[] args){ AttributeFigure figure = new ComponentFigure(); figure.basicDisplayBox(point1, point2); }

slide-3
SLIDE 3

public static void main(String[] args){ AttributeFigure figure = FigureFactory.getFigure(); figure.basicDisplayBox(point1, point2); }

slide-4
SLIDE 4

basicDisplayBox(Point origin, Point corner)

We know this information at run-time.

slide-5
SLIDE 5

Agenda

Problem: Program comprehension in the presence of polymorphism Goal: Create an accurate call-graph at code-reading- time Idea: Compare dynamically collected results with static algorithms

slide-6
SLIDE 6

Static algorithms

  • 1. UN

Class hierarchy ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔

  • 2. CHA
  • 4. CTA
  • 3. RTA
  • 7. XTA
  • 6. FTA
  • 5. MTA

✔ Instances per project Instances per method Instances per class Instances per field

slide-7
SLIDE 7

What is really happening?

slide-8
SLIDE 8

Collect information from a running system

Collect information about all method invocations from the project in question Store information in a RTI (run-time information) database Compare dynamically collected results from RTI database with static algorithms

slide-9
SLIDE 9

Using Javassist to get the information

public void basicDisplayBox(Point origin,Point corner){ bounds = new Rectangle(origin); bounds.add(corner); } public void basicDisplayBox(Point origin,Point corner){ Profiler.log($0, $sig, $args); bounds = new Rectangle(origin); bounds.add(corner); }

slide-10
SLIDE 10
  • rg.jhotdraw.contrib.ComponentFigure.basicDisplayBox(Point,Point);
  • rg.jhotdraw.contrib.PolygonFigure.basicDisplayBox(Point,Point);
  • rg.jhotdraw.contrib.TextAreaFigure.basicDisplayBox(Point,Point);
  • rg.jhotdraw.figures.EllipseFigure.basicDisplayBox(Point,Point);
  • rg.jhotdraw.figures.ImageFigure.basicDisplayBox(Point,Point);
  • rg.jhotdraw.figures.RectangleFigure.basicDisplayBox(Point,Point);
  • rg.jhotdraw.figures.RoundRectangleFigure.basicDisplayBox(Point,Point);
  • rg.jhotdraw.contrib.ComponentFigure.basicDisplayBox(Point,Point);
  • rg.jhotdraw.contrib.PolygonFigure.basicDisplayBox(Point,Point);
  • rg.jhotdraw.contrib.TextAreaFigure.basicDisplayBox(Point,Point);
  • rg.jhotdraw.figures.EllipseFigure.basicDisplayBox(Point,Point);
  • rg.jhotdraw.figures.ImageFigure.basicDisplayBox(Point,Point);
  • rg.jhotdraw.figures.RectangleFigure.basicDisplayBox(Point,Point);
  • rg.jhotdraw.figures.RoundRectangleFigure.basicDisplayBox(Point,Point);

125 78 43

figure.basicDisplayBox(origin, corner);

slide-11
SLIDE 11

How confident are we in our results?

62% of used fields 26% of used methods 64% of used constructors 65% of used classes

slide-12
SLIDE 12
  • Implement more static algorithms
  • Implement three-stage analysis
  • Improve performance for dynamic

analysis

  • Run analysis on more projects
  • Integrate a tool into IDE
slide-13
SLIDE 13

Additional uses of the RTI database

  • Usage of fields
  • All methods invocations
  • Study null pointer propagation
slide-14
SLIDE 14

Summary

  • Call graph helps source code comprehension
  • Polymorphism introduces ambiguity in the

call-graph

  • Static algorithms give false positives
  • Dynamic analysis give false negatives
  • Their combination could yield more accurate

results, at a reasonable cost, to support the developer