Lightweight precise automatic extraction of exception preconditions in java methods
When a method throws an exception— its exception precondition —is a crucial element of the method’s documentation that clients should know to properly use it. Unfortunately, exceptional behavior is often poorly documented, and sensitive to changes in a project’s implementation details that can be on...
Gespeichert in:
| Veröffentlicht in: | Empirical software engineering : an international journal Jg. 29; H. 1; S. 30 |
|---|---|
| Hauptverfasser: | , |
| Format: | Journal Article |
| Sprache: | Englisch |
| Veröffentlicht: |
New York
Springer US
01.02.2024
Springer Nature B.V |
| Schlagworte: | |
| ISSN: | 1382-3256, 1573-7616, 1573-7616 |
| Online-Zugang: | Volltext |
| Tags: |
Tag hinzufügen
Keine Tags, Fügen Sie den ersten Tag hinzu!
|
| Zusammenfassung: | When a method throws an exception— its
exception precondition
—is a crucial element of the method’s documentation that clients should know to properly use it. Unfortunately, exceptional behavior is often poorly documented, and sensitive to changes in a project’s implementation details that can be onerous to keep synchronized with the documentation. We present
wit
, an automated technique that extracts the exception preconditions of Java methods and constructors.
wit
uses static analysis to analyze the paths in a method’s implementation that lead to throwing an exception.
wit
’s analysis is precise, in that it only reports exception preconditions that are correct and correspond to feasible exceptional behavior. It is also lightweight: it only needs the source code of the class (or classes) to be analyzed— without building or running the whole project. To this end, its design uses heuristics that give up some completeness (
wit
cannot infer all exception preconditions) in exchange for precision and ease of applicability. We ran
wit
on the JDK and 46 Java projects, where it discovered 30 487 exception preconditions in 24 461 methods, taking less than two seconds per analyzed public method on average. A manual analysis of a significant sample of these exception preconditions confirmed that
wit
is 100% precise, and demonstrated that it can document the exceptional behavior of Java methods. |
|---|---|
| Bibliographie: | ObjectType-Article-1 SourceType-Scholarly Journals-1 ObjectType-Feature-2 content type line 14 content type line 23 Communicated by: Paris Avgeriou and Dave Binkley |
| ISSN: | 1382-3256 1573-7616 1573-7616 |
| DOI: | 10.1007/s10664-023-10392-x |