SlideShare uma empresa Scribd logo
1 de 30
Automatic Documentation
Inference for ExceptionsRay Buse
Westley Weimer
ISSTA 2008
@slide 2
• Exception Handling & Why it’s hard
• A look at existing practice
• Our tool for Automatic Documentation
• Evaluation
• Conclusions
@slide 3
EXCEPTIONS
• Language construct for transferring control
to a place where an event can be handled
• 2 General Cases
 Legitimate environmental events
• e.g., the disk is full
 Checking invariants or preconditions
• e.g., argument must not be null
@slide 4
IMPORTANCE
• Mishandling or Not handling can lead to…
 Security vulnerabilities
• May disclose sensitive implementation details
 Breaches of API encapsulation
• Might want to change exceptions later
 Any number of minor to serious system
failures
@slide 5
• Solution 1: No exceptions. We write total
functions only.
• Solution 2: Pretend exceptions don’t
happen.
• Solution 3: Keep track of all exceptions and
handle them appropriately.
@slide 6
AN EXAMPLE
/**
* Moves this unit to america.
*
* @exception IllegalStateException If the move is illegal.
*/
public void moveToAmerica() {
if (!(getLocation() instanceof Europe)) {
throw new IllegalStateException("A unit can only be "
+ "moved to america from europe.");
}
setState(TO_AMERICA);
// Clear the alreadyOnHighSea flag
alreadyOnHighSea = false;
}
@slide 7
/**
* Moves this unit to america.
*
* @exception IllegalStateException If the move is illegal.
*/
public void moveToAmerica() {
if (!(getLocation() instanceof Europe)) {
throw new IllegalStateException("A unit can only be "
+ "moved to america from europe.");
}
setState(TO_AMERICA);
// Clear the alreadyOnHighSea flag
alreadyOnHighSea = false;
}
AN EXAMPLE
Here’s one spot
When does this throw
an exception?
@slide 8
/**
* Moves this unit to america.
*
* @exception IllegalStateException If the move is illegal.
*/
public void moveToAmerica() {
if (!(getLocation() instanceof Europe)) {
throw new IllegalStateException("A unit can only be "
+ "moved to america from europe.");
}
setState(TO_AMERICA);
// Clear the alreadyOnHighSea flag
alreadyOnHighSea = false;
}
AN EXAMPLE
Must check here
and here
When does this throw
an exception?
@slide 9
SO, IT’S HARD
• Need to check all the methods
that are reachable
• With subtyping and dynamic
dispatch there could be many
implementations of a method
• And what happens as the
system evolves?
@slide 10
DOCUMENTATION: WHY?
• For Developers
 Easier to keep track of what’s going on
• For Maintenance
 90% of the total cost of a typical software project
 40% - 60% of maintenance is spent studying existing
software
• For Users
 Easier to integrate existing software libraries
@slide 11
BENCHMARKS
Program Name Application Domain kLOC
Azureus Internet File Sharing 470
DrJava Development 131
FindBugs Program Analysis 142
FreeCol Game 103
hsqldb Database 154
jEdit Text Editor 138
jFreeChart Data Presentation 181
Risk Game 34
tvBrowser TV guide 155
Weka Machine Learning 436
Total 1944
@slide 12
SOME TERMS
• Exception Instance
 An Exception type and a method that can
propagate it
 Each exception instance is an opportunity for
a documentation
• Depth of an Exception Instance
 Minimum number of dynamic method
invocations between the Exception Instance
and a throw statement of its type
 Intuitively, greater depth implies harder to
figure out
@slide 13
DOCUMENTATION: WHEN DOES IT
HAPPEN?
@slide 14
DOCUMENTATION:
CONSISTENCY
@slide 15
/**
* Moves this unit to america.
*
* @exception IllegalStateException If the move is illegal.
*/
public void moveToAmerica() {
if (!(getLocation() instanceof Europe)) {
throw new IllegalStateException("A unit can only be "
+ "moved to america from europe.");
}
setState(TO_AMERICA);
// Clear the alreadyOnHighSea flag
alreadyOnHighSea = false;
}
AN EXAMPLE
Can we do better?
@slide 16
/**
* Moves this unit to america.
*
* @exception IllegalStateException thrown when
* getLocation() is not a Europe
*/
public void moveToAmerica() {
if (!(getLocation() instanceof Europe)) {
throw new IllegalStateException("A unit can only be "
+ "moved to america from europe.");
}
setState(TO_AMERICA);
// Clear the alreadyOnHighSea flag
alreadyOnHighSea = false;
}
AN EXAMPLE
@slide 17
HYPOTHESIS
• We can create an automatic tool that
documents exceptions better than
developers have
 Better?
• More complete
• More precise
@slide 18
THE ALGORITHM
• A simple example: main()
{
if( x < 0 )
throw new Exception();
else
sub( x );
}
sub( int n )
{
if( n == 4 )
throw new Exception();
}
@slide 19
THE ALGORITHM
• Find the throw
statements
main()
{
if( x < 0 )
throw new Exception();
else
sub( x );
}
sub( int n )
{
if( n == 4 )
throw new Exception();
}
@slide 20
THE ALGORITHM
• Link method
invocations to
possible targets
 We use an off-the-
shelf call graph
generator
main()
{
if( x < 0 )
throw new Exception();
else
sub( x );
}
sub( int n )
{
if( n == 4 )
throw new Exception();
}
@slide 21
THE ALGORITHM
• Determine which
methods can throw
which exceptions
 Use a fixpoint
worklist to deal
with cycles
main() {Exception}
{
if( x < 0 )
throw new Exception();
else
sub( x );
}
sub( int n ) {Exception}
{
if( n == 4 )
throw new Exception();
}
@slide 22
sub( int n ) {Exception}
{
if( n == 4 )
throw new Exception();
}
main() {Exception}
{
if( x < 0 )
throw new Exception();
else
sub( x );
}
THE ALGORITHM
• Enumerate control
flow paths that can
lead to exceptions
 Work backward
from exception
throwing
statements
@slide 23
THE ALGORITHM
• Symbolically
execute paths,
record predicates
sub( int n ) {Exception}
{
if( n == 4 )
throw new Exception();
}
main() {Exception}
{
if( x < 0 )
throw new Exception();
else
sub( x );
}
@slide 24
THE ALGORITHM
• Predicates along
the path become
the documentation
@throws Exception if
x < 0 OR (x >= 0 AND x==4)
main()
{
if( x < 0 )
throw new Exception();
else
sub( x );
}
@throws Exception if
parameter:n == 4
sub( int n )
{
if( n == 4 )
throw new Exception();
}
@slide 25
EXPERIMENTAL SETUP
• Baseline: Existing JavaDocs
 10 Benchmarks from earlier
 ~950 documentations
• Run tool on each program and create pairs
 <tool doc, existing doc>
• Bin each in: Worse, Same, Better
@slide 26
EXAMPLES
• Sometimes we do better:
• Sometimes we do about the same:
• Sometimes we do worse:
@slide 27
RESULTS
@slide 28
LIMITATIONS
• Exceptions that seem possible aren’t really
 Better call graph
• Exceptions contexts are deep and complex
 Could be a symptom of bad design
 Might want to ignore certain types or threshold depth
• Same exception type stands for many error
conditions
 Increase granularity of exception type hierarchy
@slide 29
CONCLUSION
• Exceptions probably aren’t going away
• Many exception instances remain poorly or not
documented in practice
• On average, we do at least as well as humans 83%
of the time and are fully automatic
• We can scale to large programs
 Azureus has 470 kLOC, tool runs in ~25 min
@slide 30
throw new OutOfSlidesException();
Questions?

Mais conteúdo relacionado

Mais procurados

Reactive programming in PHP
Reactive programming in PHPReactive programming in PHP
Reactive programming in PHPJohney Park
 
Functional tests for dummies
Functional tests for dummiesFunctional tests for dummies
Functional tests for dummiescpsitgmbh
 
Reactive computing
Reactive computingReactive computing
Reactive computingStan Lea
 
[Bucharest] Reversing the Apple Sandbox
[Bucharest] Reversing the Apple Sandbox[Bucharest] Reversing the Apple Sandbox
[Bucharest] Reversing the Apple SandboxOWASP EEE
 
What's new in ECMAScript 6
What's new in ECMAScript 6What's new in ECMAScript 6
What's new in ECMAScript 6Ran Wahle
 
Extending C# with Roslyn and Code Aware Libraries
Extending C# with Roslyn and Code Aware LibrariesExtending C# with Roslyn and Code Aware Libraries
Extending C# with Roslyn and Code Aware LibrariesCarlo Pescio
 
Improving code quality with Roslyn analyzers
Improving code quality with Roslyn analyzersImproving code quality with Roslyn analyzers
Improving code quality with Roslyn analyzersJim Wooley
 

Mais procurados (8)

Reactive programming in PHP
Reactive programming in PHPReactive programming in PHP
Reactive programming in PHP
 
Functional tests for dummies
Functional tests for dummiesFunctional tests for dummies
Functional tests for dummies
 
Reactive computing
Reactive computingReactive computing
Reactive computing
 
[Bucharest] Reversing the Apple Sandbox
[Bucharest] Reversing the Apple Sandbox[Bucharest] Reversing the Apple Sandbox
[Bucharest] Reversing the Apple Sandbox
 
What's new in ECMAScript 6
What's new in ECMAScript 6What's new in ECMAScript 6
What's new in ECMAScript 6
 
Extending C# with Roslyn and Code Aware Libraries
Extending C# with Roslyn and Code Aware LibrariesExtending C# with Roslyn and Code Aware Libraries
Extending C# with Roslyn and Code Aware Libraries
 
Improving code quality with Roslyn analyzers
Improving code quality with Roslyn analyzersImproving code quality with Roslyn analyzers
Improving code quality with Roslyn analyzers
 
How we're building Wercker
How we're building WerckerHow we're building Wercker
How we're building Wercker
 

Destaque

PhD Proposal talk
PhD Proposal talkPhD Proposal talk
PhD Proposal talkRay Buse
 
Synthesizing API Usage Examples
Synthesizing API Usage Examples Synthesizing API Usage Examples
Synthesizing API Usage Examples Ray Buse
 
A Metric for Code Readability
A Metric for Code ReadabilityA Metric for Code Readability
A Metric for Code ReadabilityRay Buse
 
The Road Not Taken: Estimating Path Execution Frequency Statically
The Road Not Taken: Estimating Path Execution Frequency StaticallyThe Road Not Taken: Estimating Path Execution Frequency Statically
The Road Not Taken: Estimating Path Execution Frequency StaticallyRay Buse
 
Automatically Documenting Program Changes
Automatically Documenting Program ChangesAutomatically Documenting Program Changes
Automatically Documenting Program ChangesRay Buse
 
MSR End of Internship Talk
MSR End of Internship TalkMSR End of Internship Talk
MSR End of Internship TalkRay Buse
 
Information Needs for Software Development Analytics
Information Needs for Software Development AnalyticsInformation Needs for Software Development Analytics
Information Needs for Software Development AnalyticsRay Buse
 
Automatically Describing Program Structure and Behavior (PhD Defense)
Automatically Describing Program Structure and Behavior (PhD Defense)Automatically Describing Program Structure and Behavior (PhD Defense)
Automatically Describing Program Structure and Behavior (PhD Defense)Ray Buse
 
Analytics for Software Development
Analytics for Software DevelopmentAnalytics for Software Development
Analytics for Software DevelopmentRay Buse
 

Destaque (9)

PhD Proposal talk
PhD Proposal talkPhD Proposal talk
PhD Proposal talk
 
Synthesizing API Usage Examples
Synthesizing API Usage Examples Synthesizing API Usage Examples
Synthesizing API Usage Examples
 
A Metric for Code Readability
A Metric for Code ReadabilityA Metric for Code Readability
A Metric for Code Readability
 
The Road Not Taken: Estimating Path Execution Frequency Statically
The Road Not Taken: Estimating Path Execution Frequency StaticallyThe Road Not Taken: Estimating Path Execution Frequency Statically
The Road Not Taken: Estimating Path Execution Frequency Statically
 
Automatically Documenting Program Changes
Automatically Documenting Program ChangesAutomatically Documenting Program Changes
Automatically Documenting Program Changes
 
MSR End of Internship Talk
MSR End of Internship TalkMSR End of Internship Talk
MSR End of Internship Talk
 
Information Needs for Software Development Analytics
Information Needs for Software Development AnalyticsInformation Needs for Software Development Analytics
Information Needs for Software Development Analytics
 
Automatically Describing Program Structure and Behavior (PhD Defense)
Automatically Describing Program Structure and Behavior (PhD Defense)Automatically Describing Program Structure and Behavior (PhD Defense)
Automatically Describing Program Structure and Behavior (PhD Defense)
 
Analytics for Software Development
Analytics for Software DevelopmentAnalytics for Software Development
Analytics for Software Development
 

Semelhante a Documentation Inference for Exceptions

10 Typical Enterprise Java Problems
10 Typical Enterprise Java Problems10 Typical Enterprise Java Problems
10 Typical Enterprise Java ProblemsEberhard Wolff
 
55 new things in Java 7 - Devoxx France
55 new things in Java 7 - Devoxx France55 new things in Java 7 - Devoxx France
55 new things in Java 7 - Devoxx FranceDavid Delabassee
 
Java-Exception Handling Presentation. 2024
Java-Exception Handling Presentation. 2024Java-Exception Handling Presentation. 2024
Java-Exception Handling Presentation. 2024nehakumari0xf
 
Exception Handling In Java Presentation. 2024
Exception Handling In Java Presentation. 2024Exception Handling In Java Presentation. 2024
Exception Handling In Java Presentation. 2024kashyapneha2809
 
A exception ekon16
A exception ekon16A exception ekon16
A exception ekon16Max Kleiner
 
Modern Java Workshop
Modern Java WorkshopModern Java Workshop
Modern Java WorkshopSimon Ritter
 
From Legacy to Hexagonal (An Unexpected Android Journey)
From Legacy to Hexagonal (An Unexpected Android Journey)From Legacy to Hexagonal (An Unexpected Android Journey)
From Legacy to Hexagonal (An Unexpected Android Journey)Jose Manuel Pereira Garcia
 
Exception handling in java
Exception handling in javaException handling in java
Exception handling in javagopalrajput11
 
2012 JDays Bad Tests Good Tests
2012 JDays Bad Tests Good Tests2012 JDays Bad Tests Good Tests
2012 JDays Bad Tests Good TestsTomek Kaczanowski
 
10 Typical Problems in Enterprise Java Applications
10 Typical Problems in Enterprise Java Applications10 Typical Problems in Enterprise Java Applications
10 Typical Problems in Enterprise Java ApplicationsEberhard Wolff
 
Exceptions overview
Exceptions overviewExceptions overview
Exceptions overviewBharath K
 
33rd Degree 2013, Bad Tests, Good Tests
33rd Degree 2013, Bad Tests, Good Tests33rd Degree 2013, Bad Tests, Good Tests
33rd Degree 2013, Bad Tests, Good TestsTomek Kaczanowski
 
Breaking Parser Logic: Take Your Path Normalization Off and Pop 0days Out!
Breaking Parser Logic: Take Your Path Normalization Off and Pop 0days Out!Breaking Parser Logic: Take Your Path Normalization Off and Pop 0days Out!
Breaking Parser Logic: Take Your Path Normalization Off and Pop 0days Out!Priyanka Aash
 
Pi j4.2 software-reliability
Pi j4.2 software-reliabilityPi j4.2 software-reliability
Pi j4.2 software-reliabilitymcollison
 
Unit testing in iOS featuring OCUnit, GHUnit & OCMock
Unit testing in iOS featuring OCUnit, GHUnit & OCMockUnit testing in iOS featuring OCUnit, GHUnit & OCMock
Unit testing in iOS featuring OCUnit, GHUnit & OCMockRobot Media
 
Md07 exceptions&assertion
Md07 exceptions&assertionMd07 exceptions&assertion
Md07 exceptions&assertionRakesh Madugula
 
2. Design patterns. part #2
2. Design patterns. part #22. Design patterns. part #2
2. Design patterns. part #2Leonid Maslov
 

Semelhante a Documentation Inference for Exceptions (20)

10 Typical Enterprise Java Problems
10 Typical Enterprise Java Problems10 Typical Enterprise Java Problems
10 Typical Enterprise Java Problems
 
55 new things in Java 7 - Devoxx France
55 new things in Java 7 - Devoxx France55 new things in Java 7 - Devoxx France
55 new things in Java 7 - Devoxx France
 
Java-Exception Handling Presentation. 2024
Java-Exception Handling Presentation. 2024Java-Exception Handling Presentation. 2024
Java-Exception Handling Presentation. 2024
 
Exception Handling In Java Presentation. 2024
Exception Handling In Java Presentation. 2024Exception Handling In Java Presentation. 2024
Exception Handling In Java Presentation. 2024
 
A exception ekon16
A exception ekon16A exception ekon16
A exception ekon16
 
Exception hierarchy
Exception hierarchyException hierarchy
Exception hierarchy
 
Modern Java Workshop
Modern Java WorkshopModern Java Workshop
Modern Java Workshop
 
From Legacy to Hexagonal (An Unexpected Android Journey)
From Legacy to Hexagonal (An Unexpected Android Journey)From Legacy to Hexagonal (An Unexpected Android Journey)
From Legacy to Hexagonal (An Unexpected Android Journey)
 
Exception handling in java
Exception handling in javaException handling in java
Exception handling in java
 
2012 JDays Bad Tests Good Tests
2012 JDays Bad Tests Good Tests2012 JDays Bad Tests Good Tests
2012 JDays Bad Tests Good Tests
 
10 Typical Problems in Enterprise Java Applications
10 Typical Problems in Enterprise Java Applications10 Typical Problems in Enterprise Java Applications
10 Typical Problems in Enterprise Java Applications
 
Exceptions overview
Exceptions overviewExceptions overview
Exceptions overview
 
33rd Degree 2013, Bad Tests, Good Tests
33rd Degree 2013, Bad Tests, Good Tests33rd Degree 2013, Bad Tests, Good Tests
33rd Degree 2013, Bad Tests, Good Tests
 
JDK Power Tools
JDK Power ToolsJDK Power Tools
JDK Power Tools
 
Breaking Parser Logic: Take Your Path Normalization Off and Pop 0days Out!
Breaking Parser Logic: Take Your Path Normalization Off and Pop 0days Out!Breaking Parser Logic: Take Your Path Normalization Off and Pop 0days Out!
Breaking Parser Logic: Take Your Path Normalization Off and Pop 0days Out!
 
Pi j4.2 software-reliability
Pi j4.2 software-reliabilityPi j4.2 software-reliability
Pi j4.2 software-reliability
 
Twins: OOP and FP
Twins: OOP and FPTwins: OOP and FP
Twins: OOP and FP
 
Unit testing in iOS featuring OCUnit, GHUnit & OCMock
Unit testing in iOS featuring OCUnit, GHUnit & OCMockUnit testing in iOS featuring OCUnit, GHUnit & OCMock
Unit testing in iOS featuring OCUnit, GHUnit & OCMock
 
Md07 exceptions&assertion
Md07 exceptions&assertionMd07 exceptions&assertion
Md07 exceptions&assertion
 
2. Design patterns. part #2
2. Design patterns. part #22. Design patterns. part #2
2. Design patterns. part #2
 

Documentation Inference for Exceptions

  • 1. Automatic Documentation Inference for ExceptionsRay Buse Westley Weimer ISSTA 2008
  • 2. @slide 2 • Exception Handling & Why it’s hard • A look at existing practice • Our tool for Automatic Documentation • Evaluation • Conclusions
  • 3. @slide 3 EXCEPTIONS • Language construct for transferring control to a place where an event can be handled • 2 General Cases  Legitimate environmental events • e.g., the disk is full  Checking invariants or preconditions • e.g., argument must not be null
  • 4. @slide 4 IMPORTANCE • Mishandling or Not handling can lead to…  Security vulnerabilities • May disclose sensitive implementation details  Breaches of API encapsulation • Might want to change exceptions later  Any number of minor to serious system failures
  • 5. @slide 5 • Solution 1: No exceptions. We write total functions only. • Solution 2: Pretend exceptions don’t happen. • Solution 3: Keep track of all exceptions and handle them appropriately.
  • 6. @slide 6 AN EXAMPLE /** * Moves this unit to america. * * @exception IllegalStateException If the move is illegal. */ public void moveToAmerica() { if (!(getLocation() instanceof Europe)) { throw new IllegalStateException("A unit can only be " + "moved to america from europe."); } setState(TO_AMERICA); // Clear the alreadyOnHighSea flag alreadyOnHighSea = false; }
  • 7. @slide 7 /** * Moves this unit to america. * * @exception IllegalStateException If the move is illegal. */ public void moveToAmerica() { if (!(getLocation() instanceof Europe)) { throw new IllegalStateException("A unit can only be " + "moved to america from europe."); } setState(TO_AMERICA); // Clear the alreadyOnHighSea flag alreadyOnHighSea = false; } AN EXAMPLE Here’s one spot When does this throw an exception?
  • 8. @slide 8 /** * Moves this unit to america. * * @exception IllegalStateException If the move is illegal. */ public void moveToAmerica() { if (!(getLocation() instanceof Europe)) { throw new IllegalStateException("A unit can only be " + "moved to america from europe."); } setState(TO_AMERICA); // Clear the alreadyOnHighSea flag alreadyOnHighSea = false; } AN EXAMPLE Must check here and here When does this throw an exception?
  • 9. @slide 9 SO, IT’S HARD • Need to check all the methods that are reachable • With subtyping and dynamic dispatch there could be many implementations of a method • And what happens as the system evolves?
  • 10. @slide 10 DOCUMENTATION: WHY? • For Developers  Easier to keep track of what’s going on • For Maintenance  90% of the total cost of a typical software project  40% - 60% of maintenance is spent studying existing software • For Users  Easier to integrate existing software libraries
  • 11. @slide 11 BENCHMARKS Program Name Application Domain kLOC Azureus Internet File Sharing 470 DrJava Development 131 FindBugs Program Analysis 142 FreeCol Game 103 hsqldb Database 154 jEdit Text Editor 138 jFreeChart Data Presentation 181 Risk Game 34 tvBrowser TV guide 155 Weka Machine Learning 436 Total 1944
  • 12. @slide 12 SOME TERMS • Exception Instance  An Exception type and a method that can propagate it  Each exception instance is an opportunity for a documentation • Depth of an Exception Instance  Minimum number of dynamic method invocations between the Exception Instance and a throw statement of its type  Intuitively, greater depth implies harder to figure out
  • 13. @slide 13 DOCUMENTATION: WHEN DOES IT HAPPEN?
  • 15. @slide 15 /** * Moves this unit to america. * * @exception IllegalStateException If the move is illegal. */ public void moveToAmerica() { if (!(getLocation() instanceof Europe)) { throw new IllegalStateException("A unit can only be " + "moved to america from europe."); } setState(TO_AMERICA); // Clear the alreadyOnHighSea flag alreadyOnHighSea = false; } AN EXAMPLE Can we do better?
  • 16. @slide 16 /** * Moves this unit to america. * * @exception IllegalStateException thrown when * getLocation() is not a Europe */ public void moveToAmerica() { if (!(getLocation() instanceof Europe)) { throw new IllegalStateException("A unit can only be " + "moved to america from europe."); } setState(TO_AMERICA); // Clear the alreadyOnHighSea flag alreadyOnHighSea = false; } AN EXAMPLE
  • 17. @slide 17 HYPOTHESIS • We can create an automatic tool that documents exceptions better than developers have  Better? • More complete • More precise
  • 18. @slide 18 THE ALGORITHM • A simple example: main() { if( x < 0 ) throw new Exception(); else sub( x ); } sub( int n ) { if( n == 4 ) throw new Exception(); }
  • 19. @slide 19 THE ALGORITHM • Find the throw statements main() { if( x < 0 ) throw new Exception(); else sub( x ); } sub( int n ) { if( n == 4 ) throw new Exception(); }
  • 20. @slide 20 THE ALGORITHM • Link method invocations to possible targets  We use an off-the- shelf call graph generator main() { if( x < 0 ) throw new Exception(); else sub( x ); } sub( int n ) { if( n == 4 ) throw new Exception(); }
  • 21. @slide 21 THE ALGORITHM • Determine which methods can throw which exceptions  Use a fixpoint worklist to deal with cycles main() {Exception} { if( x < 0 ) throw new Exception(); else sub( x ); } sub( int n ) {Exception} { if( n == 4 ) throw new Exception(); }
  • 22. @slide 22 sub( int n ) {Exception} { if( n == 4 ) throw new Exception(); } main() {Exception} { if( x < 0 ) throw new Exception(); else sub( x ); } THE ALGORITHM • Enumerate control flow paths that can lead to exceptions  Work backward from exception throwing statements
  • 23. @slide 23 THE ALGORITHM • Symbolically execute paths, record predicates sub( int n ) {Exception} { if( n == 4 ) throw new Exception(); } main() {Exception} { if( x < 0 ) throw new Exception(); else sub( x ); }
  • 24. @slide 24 THE ALGORITHM • Predicates along the path become the documentation @throws Exception if x < 0 OR (x >= 0 AND x==4) main() { if( x < 0 ) throw new Exception(); else sub( x ); } @throws Exception if parameter:n == 4 sub( int n ) { if( n == 4 ) throw new Exception(); }
  • 25. @slide 25 EXPERIMENTAL SETUP • Baseline: Existing JavaDocs  10 Benchmarks from earlier  ~950 documentations • Run tool on each program and create pairs  <tool doc, existing doc> • Bin each in: Worse, Same, Better
  • 26. @slide 26 EXAMPLES • Sometimes we do better: • Sometimes we do about the same: • Sometimes we do worse:
  • 28. @slide 28 LIMITATIONS • Exceptions that seem possible aren’t really  Better call graph • Exceptions contexts are deep and complex  Could be a symptom of bad design  Might want to ignore certain types or threshold depth • Same exception type stands for many error conditions  Increase granularity of exception type hierarchy
  • 29. @slide 29 CONCLUSION • Exceptions probably aren’t going away • Many exception instances remain poorly or not documented in practice • On average, we do at least as well as humans 83% of the time and are fully automatic • We can scale to large programs  Azureus has 470 kLOC, tool runs in ~25 min
  • 30. @slide 30 throw new OutOfSlidesException(); Questions?