mining operational preconditions
play

Mining Operational Preconditions Andrzej Wasylkowski Andreas - PowerPoint PPT Presentation

Mining Operational Preconditions Andrzej Wasylkowski Andreas Zeller Saarland University bug.aj @interface A {} aspect Test { declare @field : @A int var* : @A; declare @field : int var* : @A; interface Subject {} public int


  1. Mining Operational Preconditions Andrzej Wasylkowski • Andreas Zeller Saarland University

  2. bug.aj @interface A {} aspect Test { declare @field : @A int var* : @A; declare @field : int var* : @A; interface Subject {} public int Subject.vara; public int Subject.varb; } class X implements Test.Subject {}

  3. ajc Stack Trace java.util.NoSuchElementException at java.util.AbstractList$Itr .next(AbstractList.java:427) at org.aspectj.weaver.bcel.BcelClassWeaver .weaveAtFieldRepeatedly (BcelClassWeaver.java:1016)

  4. ajc Stack Trace java.util.NoSuchElementException at java.util.AbstractList$Itr .next(AbstractList.java:427) at org.aspectj.weaver.bcel.BcelClassWeaver .weaveAtFieldRepeatedly (BcelClassWeaver.java:1016)

  5. weaveAtFieldRepeatedly for (Iterator iter = itdFields.iterator(); iter.hasNext();) { ... for (Iterator iter2 = worthRetrying.iterator(); iter.hasNext();) { ... } }

  6. weaveAtFieldRepeatedly for (Iterator iter = itdFields.iterator(); iter.hasNext();) { ... for (Iterator iter2 = worthRetrying.iterator(); iter.hasNext();) { ... should be iter2 } }

  7. weaveAtFieldRepeatedly for (Iterator iter = itdFields.iterator(); iter.hasNext();) { ... for (Iterator iter2 = worthRetrying.iterator(); iter.hasNext();) { ... should be iter2 } } • Invalid iterator usage: hasNext() should precede next()

  8. Preconditions

  9. Preconditions Invoking next() with no next element violates a precondition

  10. Preconditions Invoking next() with no next element violates a precondition Traditional preconditions are axiomatic – describing the state of the system

  11. Preconditions Invoking next() with no next element violates a precondition Traditional preconditions are axiomatic – describing the state of the system How do we reach this state?

  12. Preconditions

  13. Preconditions close(int fildes)

  14. Preconditions close(int fildes) • Axiomatic: fildes is a valid file descriptor

  15. Preconditions close(int fildes) • Axiomatic: fildes is a valid file descriptor • Operational: fildes stems from a call to open () with read() and write() calls in between

  16. Preconditions close(int fildes) • Axiomatic: fildes is a valid file descriptor • Operational: fildes stems from a call to open () with read() and write() calls in between • Can we check operational preconditions?

  17. OP-Miner

  18. OP-Miner Program

  19. OP-Miner Usage Models Program iter.hasNext () iter.next ()

  20. OP-Miner Usage Models Temporal Properties hasNext ≺ next Program hasNext ≺ hasNext iter.hasNext () iter.next () next ≺ hasNext next ≺ next

  21. OP-Miner Usage Models Temporal Properties hasNext ≺ next Program hasNext ≺ hasNext iter.hasNext () iter.next () next ≺ hasNext next ≺ next Patterns hasNext ≺ next hasNext ≺ hasNext

  22. OP-Miner Usage Models Temporal Properties hasNext ≺ next Program hasNext ≺ hasNext iter.hasNext () iter.next () next ≺ hasNext next ≺ next Anomalies Patterns hasNext ≺ next ✓ hasNext ≺ hasNext hasNext ≺ next hasNext ≺ hasNext hasNext ≺ next ✗ hasNext ≺ hasNext

  23. OP-Miner Usage Models Temporal Properties hasNext ≺ next Program hasNext ≺ hasNext iter.hasNext () iter.next () next ≺ hasNext next ≺ next Anomalies Patterns hasNext ≺ next ✓ hasNext ≺ hasNext hasNext ≺ next hasNext ≺ hasNext hasNext ≺ next ✗ hasNext ≺ hasNext

  24. Method Models public Stack createStack () { Random r = new Random (); int n = r.nextInt (); Stack s = new Stack (); int i = 0; while (i < n) { s.push (rand (r)); i++; } s.push (-1); return s; }

  25. Method Models public Stack createStack () { Random r = new Random (); int n = r.nextInt (); Stack s = new Stack (); int i = 0; while (i < n) { s.push (rand (r)); i++; } s.push (-1); return s; }

  26. Method Models Random r = new Random (); public Stack createStack () { Random r = new Random (); int n = r.nextInt (); Stack s = new Stack (); int i = 0; while (i < n) { s.push (rand (r)); i++; } s.push (-1); return s; }

  27. Method Models Random r = new Random (); public Stack createStack () { Random r = new Random (); int n = r.nextInt (); int n = r.nextInt (); Stack s = new Stack (); int i = 0; Stack s = new Stack (); while (i < n) { s.push (rand (r)); int i = 0; i++; } s.push (-1); return s; }

  28. Method Models Random r = new Random (); public Stack createStack () { Random r = new Random (); int n = r.nextInt (); int n = r.nextInt (); Stack s = new Stack (); int i = 0; Stack s = new Stack (); while (i < n) { s.push (rand (r)); int i = 0; i++; } s.push (-1); i < n return s; i++; } s.push (rand (r));

  29. Method Models Random r = new Random (); public Stack createStack () { Random r = new Random (); int n = r.nextInt (); int n = r.nextInt (); Stack s = new Stack (); int i = 0; Stack s = new Stack (); while (i < n) { s.push (rand (r)); int i = 0; i++; } s.push (-1); i < n i < n return s; i++; } s.push (-1); s.push (rand (r));

  30. Method Models Random r = new Random (); public Stack createStack () { Random r = new Random (); int n = r.nextInt (); int n = r.nextInt (); Stack s = new Stack (); int i = 0; Stack s = new Stack (); while (i < n) { s.push (rand (r)); int i = 0; i++; } s.push (-1); i < n i < n return s; i++; } s.push (-1); s.push (rand (r));

  31. Usage Models Random r = new Random (); int n = r.nextInt (); Stack s = new Stack (); int i = 0; i < n i < n i++; s.push (-1); s.push (rand (r));

  32. Usage Models Stack s = new Stack (); s.push (-1); s.push (rand (r));

  33. Usage Models s.<init>() s.push (_) s.push (_)

  34. Usage Models Random r = new Random (); int n = r.nextInt (); Stack s = new Stack (); int i = 0; i < n i < n i++; s.push (-1); s.push (rand (r));

  35. Usage Models Random r = new Random (); int n = r.nextInt (); s.push (rand (r));

  36. Usage Models r.<init> () r.nextInt () Utils.rand (r)

  37. JPanel.add() panel.<init> () panel.<init> (...) panel.setLayout (...) panel.add (..., ...) panel.add (..., ...)

  38. ASTNode.reapPropertyList() list.<init> ASTNode.createPropertyList (..., list) ASTNode.addProperty (..., list) ASTNode.reapPropertyList (list)

  39. Resource.getFlags() resource.getResourceInfo (..., ...) resource.getFlags (...)

  40. OP-Miner Usage Models Temporal Properties hasNext ≺ next Program hasNext ≺ hasNext iter.hasNext () iter.next () next ≺ hasNext next ≺ next Anomalies Patterns hasNext ≺ next ✓ hasNext ≺ hasNext hasNext ≺ next hasNext ≺ hasNext hasNext ≺ next ✗ hasNext ≺ hasNext

  41. OP-Miner Usage Models Temporal Properties hasNext ≺ next Program hasNext ≺ hasNext iter.hasNext () iter.next () next ≺ hasNext next ≺ next Anomalies Patterns hasNext ≺ next ✓ hasNext ≺ hasNext hasNext ≺ next hasNext ≺ hasNext hasNext ≺ next ✗ hasNext ≺ hasNext

  42. Methods vs. Properties Temporal Properties start ≺ lock ≺ eof ≺ stop unlock close Methods

  43. Methods vs. Properties Temporal Properties start ≺ lock ≺ eof ≺ stop unlock close get() Methods

  44. Methods vs. Properties Temporal Properties start ≺ lock ≺ eof ≺ stop unlock close get() Methods open()

  45. Methods vs. Properties Temporal Properties start ≺ lock ≺ eof ≺ stop unlock close get() Methods open() hello()

  46. Methods vs. Properties Temporal Properties start ≺ lock ≺ eof ≺ stop unlock close get() Methods open() hello() parse()

  47. Methods vs. Properties Temporal Properties start ≺ lock ≺ eof ≺ stop unlock close get() Methods open() hello() parse()

  48. Methods vs. Properties Temporal Properties start ≺ lock ≺ eof ≺ stop unlock close get() Methods open() hello() parse()

  49. Methods vs. Properties Temporal Properties start ≺ lock ≺ eof ≺ stop unlock close Pattern get() Methods open() hello() parse()

  50. Methods vs. Properties Temporal Properties start ≺ lock ≺ eof ≺ stop unlock close Pattern get() Methods open() hello() Support parse()

  51. Discovering Anomalies Temporal Properties start ≺ lock ≺ eof ≺ stop unlock close get() Methods open() hello() parse()

  52. Discovering Anomalies Temporal Properties start ≺ lock ≺ eof ≺ stop unlock close ✘ get() Methods open() hello() parse()

  53. Discovering Anomalies Temporal Properties start ≺ lock ≺ eof ≺ stop unlock close get() Methods open() hello() parse()

  54. Discovering Anomalies Temporal Properties start ≺ lock ≺ eof ≺ stop unlock close get() Methods open() hello() parse()

  55. Discovering Anomalies Temporal Properties start ≺ lock ≺ eof ≺ stop unlock close get() Methods open() hello() parse()

  56. Discovering Anomalies Temporal Properties start ≺ lock ≺ eof ≺ stop unlock close ✘ get() Methods open() hello() parse()

  57. Case Study: AspectJ

  58. Case Study: AspectJ • 2,954 classes

  59. Case Study: AspectJ • 2,954 classes • 36,045 methods

  60. Case Study: AspectJ • 2,954 classes • 36,045 methods • 1,154 methods with OP support ≥ 20

Recommend


More recommend