Mining Operational Preconditions
Andrzej Wasylkowski • Andreas Zeller Saarland University
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
Andrzej Wasylkowski • Andreas Zeller Saarland University
@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 {}
java.util.NoSuchElementException at java.util.AbstractList$Itr .next(AbstractList.java:427) at org.aspectj.weaver.bcel.BcelClassWeaver .weaveAtFieldRepeatedly (BcelClassWeaver.java:1016)
java.util.NoSuchElementException at java.util.AbstractList$Itr .next(AbstractList.java:427) at org.aspectj.weaver.bcel.BcelClassWeaver .weaveAtFieldRepeatedly (BcelClassWeaver.java:1016)
for (Iterator iter = itdFields.iterator(); iter.hasNext();) { ... for (Iterator iter2 = worthRetrying.iterator(); iter.hasNext();) { ... } }
for (Iterator iter = itdFields.iterator(); iter.hasNext();) { ... for (Iterator iter2 = worthRetrying.iterator(); iter.hasNext();) { ... } }
for (Iterator iter = itdFields.iterator(); iter.hasNext();) { ... for (Iterator iter2 = worthRetrying.iterator(); iter.hasNext();) { ... } }
with read() and write() calls in between
with read() and write() calls in between
Program
Program
iter.hasNext () iter.next ()
Usage Models
Program
iter.hasNext () iter.next ()
Usage Models
hasNext ≺ next hasNext ≺ hasNext next ≺ hasNext next ≺ next
Temporal Properties
Program
iter.hasNext () iter.next ()
Usage Models
hasNext ≺ next hasNext ≺ hasNext next ≺ hasNext next ≺ next
Temporal Properties
hasNext ≺ next hasNext ≺ hasNext
Patterns
Program
iter.hasNext () iter.next ()
Usage Models
hasNext ≺ next hasNext ≺ hasNext next ≺ hasNext next ≺ next
Temporal Properties
hasNext ≺ next hasNext ≺ hasNext
Patterns
hasNext ≺ next hasNext ≺ hasNext hasNext ≺ next hasNext ≺ hasNext
Anomalies
Program
iter.hasNext () iter.next ()
Usage Models
hasNext ≺ next hasNext ≺ hasNext next ≺ hasNext next ≺ next
Temporal Properties
hasNext ≺ next hasNext ≺ hasNext
Patterns
hasNext ≺ next hasNext ≺ hasNext hasNext ≺ next hasNext ≺ hasNext
Anomalies
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; }
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; }
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; } 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; } Random r = new Random (); int n = r.nextInt (); Stack s = new Stack (); int i = 0;
Random r = new Random (); int n = r.nextInt (); Stack s = new Stack (); int i = 0; i < n i++; s.push (rand (r));
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; }
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));
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; }
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));
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; }
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));
Stack s = new Stack (); s.push (-1); s.push (rand (r));
s.<init>() s.push (_) s.push (_)
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));
Random r = new Random (); int n = r.nextInt (); s.push (rand (r));
r.<init> () r.nextInt () Utils.rand (r)
panel.<init> (...) panel.add (..., ...)
panel.<init> () panel.setLayout (...) panel.add (..., ...)
list.<init> ASTNode.createPropertyList (..., list) ASTNode.addProperty (..., list) ASTNode.reapPropertyList (list)
resource.getResourceInfo (..., ...) resource.getFlags (...)
Program
iter.hasNext () iter.next ()
Usage Models
hasNext ≺ next hasNext ≺ hasNext next ≺ hasNext next ≺ next
Temporal Properties
hasNext ≺ next hasNext ≺ hasNext
Patterns
hasNext ≺ next hasNext ≺ hasNext hasNext ≺ next hasNext ≺ hasNext
Anomalies
Program
iter.hasNext () iter.next ()
Usage Models
hasNext ≺ next hasNext ≺ hasNext next ≺ hasNext next ≺ next
Temporal Properties
hasNext ≺ next hasNext ≺ hasNext
Patterns
hasNext ≺ next hasNext ≺ hasNext hasNext ≺ next hasNext ≺ hasNext
Anomalies
Temporal Properties Methods
start ≺ stop lock ≺ unlock eof ≺ close
get()
Temporal Properties Methods
start ≺ stop lock ≺ unlock eof ≺ close
get()
Temporal Properties Methods
start ≺ stop lock ≺ unlock eof ≺ close
hello() get()
Temporal Properties Methods
start ≺ stop lock ≺ unlock eof ≺ close
hello() parse() get()
Temporal Properties Methods
start ≺ stop lock ≺ unlock eof ≺ close
hello() parse() get()
Temporal Properties Methods
start ≺ stop lock ≺ unlock eof ≺ close
hello() parse() get()
Temporal Properties Methods
start ≺ stop lock ≺ unlock eof ≺ close
hello() parse() get()
Temporal Properties Methods
start ≺ stop lock ≺ unlock eof ≺ close
hello() parse() get()
Temporal Properties Methods
start ≺ stop lock ≺ unlock eof ≺ close
hello() parse() get()
Temporal Properties Methods
start ≺ stop lock ≺ unlock eof ≺ close
hello() parse() get()
Temporal Properties Methods
start ≺ stop lock ≺ unlock eof ≺ close
hello() parse() get()
Temporal Properties Methods
start ≺ stop lock ≺ unlock eof ≺ close
hello() parse() get()
Temporal Properties Methods
start ≺ stop lock ≺ unlock eof ≺ close
hello() parse() get()
Temporal Properties Methods
start ≺ stop lock ≺ unlock eof ≺ close
hello() parse() get()
Temporal Properties Methods
start ≺ stop lock ≺ unlock eof ≺ close
for (Iterator iter = itdFields.iterator(); iter.hasNext();) { ... for (Iterator iter2 = worthRetrying.iterator(); iter.hasNext();) { ... } }
for (Iterator iter = itdFields.iterator(); iter.hasNext();) { ... for (Iterator iter2 = worthRetrying.iterator(); iter.hasNext();) { ... } }
for (Iterator iter = itdFields.iterator(); iter.hasNext();) { ... for (Iterator iter2 = worthRetrying.iterator(); iter.hasNext();) { ... } }
public void visitNEWARRAY (NEWARRAY o) { byte t = o.getTypecode (); if (!((t == Constants.T_BOOLEAN) || (t == Constants.T_CHAR) || ... (t == Constants.T_LONG))) { constraintViolated (o, "(...) '+t+' (...)"); } }
public void visitNEWARRAY (NEWARRAY o) { byte t = o.getTypecode (); if (!((t == Constants.T_BOOLEAN) || (t == Constants.T_CHAR) || ... (t == Constants.T_LONG))) { constraintViolated (o, "(...) '+t+' (...)"); } }
Name internalNewName (String[] identifiers) ... for (int i = 1; i < count; i++) { SimpleName name = new SimpleName(this); name.internalSetIdentifier(identifiers[i]); ... } ... }
Name internalNewName (String[] identifiers) ... for (int i = 1; i < count; i++) { SimpleName name = new SimpleName(this); name.internalSetIdentifier(identifiers[i]); ... } ... }
public String getRetentionPolicy () { ... for (Iterator it = ...; it.hasNext();) { ... = it.next(); ... return retentionPolicy; } ... }
public String getRetentionPolicy () { ... for (Iterator it = ...; it.hasNext();) { ... = it.next(); ... return retentionPolicy; } ... }
Defects Code smells False positives
Defects Code smells False positives
Defects Code smells False positives
Defects Code smells False positives
# Violations Program Total Investigated # Defects # Code smells # False positives Efficiency A-R 0.8.2 25 25 2 13 10 60% A T 6.0.16 55 55 9 46 16% AUML 0.24 305 28 12 16 43% AJ 1.5.3 300 300 16 42 242 19% A 2.5.0.0 315 85 1 26 58 32% C 1.2 57 57 4 15 38 33% E 4.2 11 11 4 7 36% 1,068 562 23 121 417 26%
leveraging appropriate static analysis frameworks
leveraging appropriate static analysis frameworks
but does this make sense for learning usage?
leveraging appropriate static analysis frameworks
but does this make sense for learning usage?
in particular in presence of low support
leveraging appropriate static analysis frameworks
but does this make sense for learning usage?
in particular in presence of low support
in terms of recommendations and documentation
i.e., how to typically construct arguments
i.e., how to typically construct arguments
for specific projects or across projects
i.e., how to typically construct arguments
for specific projects or across projects
i.e., how to typically construct arguments
for specific projects or across projects