skip to main content
10.1145/2338965.2336785acmconferencesArticle/Chapter ViewAbstractPublication PagesisstaConference Proceedingsconference-collections
Article

Static detection of brittle parameter typing

Published:15 July 2012Publication History

ABSTRACT

To avoid receiving incorrect arguments, a method specifies the expected type of each formal parameter. However, some parameter types are too general and have subtypes that the method does not expect as actual argument types. For example, this may happen if there is no common supertype that precisely describes all expected types. As a result of such brittle parameter typing, a caller may accidentally pass arguments unexpected by the callee without any warnings from the type system. This paper presents a fully automatic, static analysis to find brittle parameter typing and unexpected arguments given to brittle parameters. First, the analysis infers from callers of a method the types that arguments commonly have. Then, the analysis reports potentially unexpected arguments that stand out by having an unusual type. We apply the approach to 21 real-world Java programs that use the Swing API, an API providing various methods with brittle parameters. The analysis reveals 15 previously unknown bugs and code smells where programmers pass arguments that are compatible with the declared parameter type but nevertheless unexpected by the callee. The warnings reported by the analysis have 47% precision and 83% recall.

References

  1. J. Bloch. Effective Java (Second Edition). Addison-Wesley, 2008. Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. R.-Y. Chang, A. Podgurski, and J. Yang. Finding what's not there: a new approach to revealing neglected conditions in software. In ISSTA, pages 163-173, 2007. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. D. Engler, D. Y. Chen, S. Hallem, A. Chou, and B. Chelf. Bugs as deviant behavior: A general approach to inferring errors in systems code. In SOSP, pages 57-72, 2001. Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. M. D. Ernst, J. Cockrell, W. G. Griswold, and D. Notkin. Dynamically discovering likely program invariants to support program evolution. IEEE T Software Eng, 27(2):213-224, 2001. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. M. Fowler. Refactoring: Improving the Design of Existing Code. Addison-Wesley, 1999. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. M. Gabel and Z. Su. Online inference and enforcement of temporal properties. In ICSE, pages 15-24, 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. N. Gruska, A. Wasylkowski, and A. Zeller. Learning from 6,000 projects: Lightweight cross-project anomaly detection. In ISSTA, pages 119-130, 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. S. Hangal and M. S. Lam. Tracking down software bugs using automatic anomaly detection. In ICSE, pages 291-301, 2002. Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. O. Lhoták and L. J. Hendren. Evaluating the benefits of context-sensitive points-to analysis using a BDD-based implementation. ACM T Softw Eng Meth, 18(1), 2008. Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. Z. Li and Y. Zhou. PR-Miner: Automatically extracting implicit programming rules and detecting violations in large software code. In ESEC/FSE, pages 306-315, 2005. Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. B. Liskov. Data abstraction and hierarchy. In OOPSLA, 1987. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. S. Lu, S. Park, C. Hu, X. Ma, W. Jiang, Z. Li, R. A. Popa, and Y. Zhou. MUVI: Automatically inferring multi-variable access correlations and detecting related semantic and concurrency bugs. In SOSP, pages 103-116, 2007. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. S. Lu, J. Tucek, F. Qin, and Y. Zhou. AVIO: detecting atomicity violations via access interleaving invariants. In ASPLOS, pages 37-48, 2006. Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. M. Monperrus, M. Bruch, and M. Mezini. Detecting missing method calls in object-oriented software. In ECOOP, pages 2-25, 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. T. T. Nguyen, H. A. Nguyen, N. H. Pham, J. M. Al-Kofahi, and T. N. Nguyen. Graph-based mining of multiple object usage patterns. In ESEC/FSE, pages 383-392, 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. M. Pradel and T. R. Gross. Detecting anomalies in the order of equally-typed method arguments. In ISSTA, pages 232-242, 2011. Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. M. Pradel and T. R. Gross. Leveraging test generation and specification mining for automated bug detection without false positives. In ICSE, 2012. Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. M. Pradel, C. Jaspan, J. Aldrich, and T. R. Gross. Statically checking API protocol conformance with mined multi-object specifications. In ICSE, 2012. Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. S. Thummalapenta and T. Xie. Alattin: Mining alternative patterns for detecting neglected conditions. In ASE, pages 283-294, 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. S. Thummalapenta and T. Xie. Mining exception-handling rules as sequence association rules. In ICSE, pages 496-506, 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  21. F. Tip, A. Kiezun, and D. Bäumer. Refactoring for generalization using type constraints. In OOPSLA, pages 13-26, 2003. Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. R. Vallée-Rai, P. Co, E. Gagnon, L. J. Hendren, P. Lam, and V. Sundaresan. Soot - a Java bytecode optimization framework. In CASCON, pages 125-135, 1999. Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. A. Wasylkowski and A. Zeller. Mining temporal specifications from object usage. In ASE, pages 295-306, 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  24. J. Winther and M. I. Schwartzbach. Related types. In ECOOP, pages 434-458. Springer, 2011. Google ScholarGoogle ScholarDigital LibraryDigital Library
  25. H. Zhong, T. Xie, L. Zhang, J. Pei, and H. Mei. MAPO: Mining and recommending API usage patterns. In ECOOP, pages 318-343, 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Static detection of brittle parameter typing

    Recommendations

    Comments

    Login options

    Check if you have access through your login credentials or your institution to get full access on this article.

    Sign in
    • Published in

      cover image ACM Conferences
      ISSTA 2012: Proceedings of the 2012 International Symposium on Software Testing and Analysis
      July 2012
      341 pages
      ISBN:9781450314541
      DOI:10.1145/2338965

      Copyright © 2012 ACM

      Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than ACM must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected]

      Publisher

      Association for Computing Machinery

      New York, NY, United States

      Publication History

      • Published: 15 July 2012

      Permissions

      Request permissions about this article.

      Request Permissions

      Check for updates

      Qualifiers

      • Article

      Acceptance Rates

      Overall Acceptance Rate58of213submissions,27%

      Upcoming Conference

      ISSTA '24

    PDF Format

    View or Download as a PDF file.

    PDF

    eReader

    View online with eReader.

    eReader