Uma abordagem de apoio à extração da política de tratamento de exceções - Sena, Demóstenes Santos de (2017)
The Exception handling (EH) mechanism is a technique embedded in most of the mainstream programming languages to support the development of robust systems. The exception handling policy is composed by the set of exception handling design rules and which specify the elements (methods, classes and packages) or that contains the elements responsible for raising, propagating and catching of exceptions as well as the handling actions. Empirical studies have demonstrated that an inappropriate exception handling as consequence of undocumented exception handling policy is a source of bug hazards. On the other hand, due to the implicit nature of exception flows, the identification of exception handling code is a complex task. To address the problems resulting from the not-understood or inadequate exception handling, some approaches have been proposed languages to specify exception handling rules as well as a set of support tool to verify the constraints and checking the rules. However, historically, the exception handling policies are postponed or ignored in the software process development. Additionally, none of the proposed approaches provide support to the phase of exception policy definition. This work proposes an approach that helps the architect to extract the EH rules by performing an analysis on the existing code. Doing so, this approach fills the previous gap the EH policy definition. To support the proposed approach, a static tool suite was developed, which performs: (i) the discovery of exception flows and its handling actions; (ii) the definition of compartments; (iii) the semi-automatic rule extraction process; and (iv) the rule checking and identification of rule violation causes. This approach was assessed in two empirical studies. In the first study, 656 libraries from Maven central repository were analyzed. The main goal of this study was to reveal and to characterize the exception handling policy of the analyzed libraries. This study revealed that 80.9% of the analyzed libraries have exception flows that implement at least one exception handling anti-pattern. In the second study, we investigated the benefits of rule extraction process in the definition and checking of exception handling rules. Two web information systems (i.e., IProject and SIGAA) were analyzed in this second study. We found that all set of rules reported by the architects were extracted by our tool and the result of extraction process allowed that new rules were added to the policy. These added rules were not defined by architects and they corresponded to 57.1% (IProject) and 52.8% (SIGAA/Graduação) of the rules of analyzed systems. The checking process of defined rules supported by our approach verified that 35.6% (IProject) and 45.7% (SIGAA/Graduação) of exception flows violated some defined rule.