Abstract
We present a novel code search approach for answering queries focused on API-usage with code showing how the API should be used. To construct a search index, we develop new techniques for statically mining and consolidating temporal API specifications from code snippets. In contrast to existing semantic-based techniques, our approach handles partial programs in the form of code snippets. Handling snippets allows us to consume code from various sources such as parts of open source projects, educational resources (e.g. tutorials), and expert code sites. To handle code snippets, our approach (i) extracts a possibly partial temporal specification from each snippet using a relatively precise static analysis tracking a generalized notion of typestate, and (ii) consolidates the partial temporal specifications, combining consistent partial information to yield consolidated temporal specifications, each of which captures a full(er) usage scenario.
To answer a search query, we define a notion of relaxed inclusion matching a query against temporal specifications and their corresponding code snippets.
We have implemented our approach in a tool called PRIME and applied it to search for API usage of several challenging APIs. PRIME was able to analyze and consolidate thousands of snippets per tested API, and our results indicate that the combination of a relatively precise analysis and consolidation allowed PRIME to answer challenging queries effectively.
- ACHARYA, M., X IE , T., P EI, J., AND XU, J. Mining API patterns as partial orders from source code: from usage scenarios to specifications. In ESEC-FSE '07, pp. 25--34. Google Scholar
Digital Library
- ALNUSAIR, A., Z HAO, T., AND BODDEN, E. Effective API navigation and reuse. In IRI (aug. 2010), pp. 7--12.Google Scholar
- ALUR, R., C ERNY, P., M ADHUSUDAN, P., AND NAM, W. Synthesis of interface specifications for Java classes. In POPL (2005). Google Scholar
Digital Library
- AMMONS, G., B ODIK, R., AND LARUS, J. R. Mining specifications. In POPL'02, pp. 4--16. Google Scholar
Digital Library
- BAXTER, I. D., Y AHIN, A., MOURA, L., SANT'ANNA, M., AND BIER, L. Clone detection using abstract syntax trees. In ICSM '98. Google Scholar
Digital Library
- BECKMAN, N., K IM , D., AND ALDRICH, J. An empirical study of object protocols in the wild. In ECOOP'11. Google Scholar
Digital Library
- COOK, J. E., AND WOLF, A. L. Discovering models of software processes from event-based data. ACM Trans. Softw. Eng. Methodol. 7, 3 (1998), 215--249. Google Scholar
Digital Library
- COUSOT, P., AND COUSOT, R. Modular static program analysis, invited paper. April 6-14 2002.Google Scholar
- DAGENAIS, B., AND HENDREN, L. J. Enabling static analysis for partial Java programs. In OOPSLA'08, pp. 313--328. Google Scholar
Digital Library
- DALLMEIER, V., L INDIG, C., W ASYLKOWSKI, A., AND ZELLER, A. Mining object behavior with ADABU. In WODA '06. Google Scholar
Digital Library
- DUCASSE, S., R IEGER , M., AND DEMEYER, S. A language independent approach for detecting duplicated code. In ICSM '99. Google Scholar
Digital Library
- FINK, S., Y AHAV, E., D OR, N., R AMALINGAM, G., AND GEAY, E. Effective typestate verification in the presence of aliasing. In ISSTA'06, pp. 133--144. Google Scholar
Digital Library
- GABEL, M., J IANG , L., AND SU, Z. Scalable detection of semantic clones. In ICSE '08, pp. 321--330. Google Scholar
Digital Library
- GABEL, M., AND SU, Z. Javert: fully automatic mining of general temporal properties from dynamic traces. In FSE'08. Google Scholar
Digital Library
- github code search. https://github.com/search.Google Scholar
- GRUSKA, N., W ASYLKOWSKI, A., AND ZELLER, A. Learn-ing from 6,000 projects: Lightweight cross-project anomaly detection. In ISSTA '10. Google Scholar
Digital Library
- HOLMES, R., AND MURPHY, G. C. Using structural context to recommend source code examples. In ICSE '05. Google Scholar
Digital Library
- HOLMES, R., W ALKER, R. J., AND MURPHY, G. C. Strath-cona example recommendation tool. In FSE'05, pp. 237--240. Google Scholar
Digital Library
- J IANG, L., M ISHERGHI, G., S U, Z., AND GLONDU, S. Deckard: Scalable and accurate tree-based detection of code clones. IEEE Computer Society, pp. 96--105. Google Scholar
Digital Library
- KAMIYA, T., K USUMOTO, S., AND I NOUE, K. CCFinder: a multilinguistic token-based code clone detection system for large scale source code. IEEE Trans. Softw. Eng. 28, 7 (July 2002), 654--670. Google Scholar
Digital Library
- KIM , J., L EE, S., WON HWANG, S., AND KIM , S. Towards an intelligent code search engine. In AAAI'10.Google Scholar
- Koders. http://www.koders.com/.Google Scholar
- KOMONDOOR, R., AND HORWITZ, S. Using slicing to iden-tify duplication in source code. In SAS '01, pp. 40--56. Google Scholar
Digital Library
- KRINKE, J. Identifying similar code with program depen-dence graphs. In WCRE (2001), pp. 301--309. Google Scholar
Digital Library
- LIVIERI, S., H IGO, Y., M ATUSHITA, M., AND I NOUE, K. Very-large scale code clone analysis and visualization of open source programs using distributed CCFinder: D-CCFinder. In ICSE'07. Google Scholar
Digital Library
- LO, D., AND KHOO, S.-C. SMArTIC: towards building an accurate, robust and scalable specification miner. In FSE'06. Google Scholar
Digital Library
- MANDELIN, D., X U, L., B ODIK, R., AND KIMELMAN , D. Jungloid mining: helping to navigate the API jungle. In PLDI '05, pp. 48--61. Google Scholar
Digital Library
- MISHNE, A. Typestate-based semantic code search over partial programs. Master's thesis, Technion-Israel Institute of Technology, Haifa, Israel, 2012.Google Scholar
- MONPERRUS, M., B RUCH, M., AND MEZINI, M. Detecting missing method calls in object-oriented software. In ECOOP (2010), T. D'Hondt, Ed., vol. 6183 of Lecture Notes in Computer Science, Springer, pp. 2--25. Google Scholar
Digital Library
- REISS, S. P. Semantics-based code search. In ICSE'09. Google Scholar
Digital Library
- SAHAVECHAPHAN, N., AND CLAYPOOL, K. XSnippet: mining for sample code. In OOPSLA '06. Google Scholar
Digital Library
- SHOHAM, S., Y AHAV, E., F INK , S., AND PISTOIA , M. Static specification mining using automata-based abstractions. In ISSTA '07. Google Scholar
Digital Library
- SOLAR-L EZAMA, A., R ABBAH, R., B ODÍK, R., AND EBCIOGLU, K. Programming by sketching for bit-streaming programs. In PLDI '05.Google Scholar
- stackoverflow. http://stackoverflow.com/.Google Scholar
- STROM, R. E., AND YEMINI, S. Typestate: A programming language concept for enhancing software reliability. IEEE Trans. Software Eng. 12, 1 (1986), 157--171. Google Scholar
Digital Library
- THUMMALAPENTA, S., AND XIE , T. PARSEWeb: a programmer assistant for reusing open source code on the web. In ASE'07, pp. 204--213. Google Scholar
Digital Library
- VALLÉE-R AI, R., C O, P., G AGNON, E., H ENDREN, L., LAM, P., AND SUNDARESAN, V. Soot - a Java bytecode optimization framework. In CASCON '99, IBM Press, pp. 13--. Google Scholar
Digital Library
- WAHLER, V., S EIPEL, D., W OLFF, J., AND FISCHER, G. Clone detection in source code by frequent itemset techniques. In Source Code Analysis and Manipulation (2004). Google Scholar
Digital Library
- WASYLKOWSKI, A., AND ZELLER, A. Mining temporal specifications from object usage. In Autom. Softw. Eng. (2011), vol. 18. Google Scholar
Digital Library
- WASYLKOWSKI, A., Z ELLER, A., AND LINDIG , C. Detecting object usage anomalies. In FSE'07, pp. 35--44. Google Scholar
Digital Library
- WEIMER, W., AND NECULA, G. Mining temporal specifications for error detection. In TACAS (2005). Google Scholar
Digital Library
- WHALEY, J., M ARTIN, M. C., AND LAM, M. S. Automatic extraction of object-oriented component interfaces. In ISSTA'02. Google Scholar
Digital Library
- YANG, J., E VANS, D., B HARDWAJ, D., B HAT, T., AND DAS, M. Perracotta: mining temporal API rules from imperfect traces. In ICSE '06, pp. 282--291. Google Scholar
Digital Library
- ZHONG, H., X IE, T., Z HANG, L., P EI, J., AND MEI, H. MAPO: Mining and recommending API usage patterns. In ECOOP'09. Google Scholar
Digital Library
Index Terms
Typestate-based semantic code search over partial programs
Recommendations
Typestate-based semantic code search over partial programs
OOPSLA '12: Proceedings of the ACM international conference on Object oriented programming systems languages and applicationsWe present a novel code search approach for answering queries focused on API-usage with code showing how the API should be used. To construct a search index, we develop new techniques for statically mining and consolidating temporal API specifications ...
Typestate-like analysis of multiple interacting objects
OOPSLA '08: Proceedings of the 23rd ACM SIGPLAN conference on Object-oriented programming systems languages and applicationsThis paper presents a static analysis of typestate-like temporal specifications of groups of interacting objects, which are expressed using tracematches. Whereas typestate expresses a temporal specification of one object, a tracematch state may change ...
Typestate-like analysis of multiple interacting objects
This paper presents a static analysis of typestate-like temporal specifications of groups of interacting objects, which are expressed using tracematches. Whereas typestate expresses a temporal specification of one object, a tracematch state may change ...







Comments