Arxiv:1702.08008V1 [Cs.SE] 26 Feb 2017
Total Page:16
File Type:pdf, Size:1020Kb
JETracer - A Framework for Java GUI Event Tracing Arthur-Jozsef Molnar Faculty of Mathematics and Computer Science, Babes¸-Bolyai University, Cluj-Napoca, Romania [email protected] Keywords: GUI, event, tracing, analysis, instrumentation, Java. Abstract: The present paper introduces the open-source Java Event Tracer (JETracer) framework for real-time tracing of GUI events within applications based on the AWT, Swing or SWT graphical toolkits. Our framework pro- vides a common event model for supported toolkits, the possibility of receiving GUI events in real-time, good performance in the case of complex target applications and the possibility of deployment over a network. The present paper provides the rationale for JETracer, presents related research and details its technical implemen- tation. An empirical evaluation where JETracer is used to trace GUI events within five popular, open-source applications is also presented. 1 INTRODUCTION 1400 professional developers regarding the strate- gies, tools and problems encountered by professionals The graphical user interface (GUI) is currently the when comprehending software. Among the most sig- most pervasive paradigm for human-computer inter- nificant findings are that developers usually interact action. With the continued proliferation of mobile with the target application’s GUI for finding the start- devices, GUI-driven applications remain the norm in ing point of further interaction as well as the use of today’s landscape of pervasive computing. Given IDE’s in parallel with more specialized tools. Of par- their virtual omnipresence and increasing complex- ticular note was the finding that ”industry developers ity across different platforms, it stands to reason that do not use dedicated program comprehension tools tools supporting their lifecycle must keep pace. This developed by the research community” (Maalej et al., is especially evident for many applications where 2014). Another important issue regards open access GUI-related code takes up as much as 50% of all ap- to state of the art tooling. As we show in the follow- plication code (Memon, 2001). ing section, there exist commercial tools that incorpo- rate some of the functionalities of JETracer. However, Therefore we believe that software tooling that as they are closed-source and available against signif- supports the GUI application development lifecycle icant licensing fees, they have limited impact within will take on an increasing importance in practition- the academia. ers’ toolboxes. Such software can assist with many activities, starting with analysis and design, as well Our motivation for developing JETracer is the as coding, program comprehension, software visual- lack of open-source software tools providing multi- ization and testing. This is confirmed when studying platform GUI event tracing. We believe GUI event the evolution of a widely used IDE such as Eclipse tracing supports the development of further innova- (Hou and Wang, 2009), where each new version ships tive tools. These may target program comprehension arXiv:1702.08008v1 [cs.SE] 26 Feb 2017 with more advanced features which are aimed at help- or visualization by creating runtime traces or software ing professionals create higher quality software faster. testing by providing real-time information about exe- Furthermore, the creation of innovative tools is nowa- cuted code. days aided by the prevalence of managed, flexible The present paper is structured as follows: the platforms such as Java and .NET, which enable novel next section presents related work, while the third sec- tool approaches via techniques such as reflection, tion details JETracer’s technical implementation. The code instrumentation and the use of annotations. fourth section is dedicated to an evaluation using 5 The supportive role of tooling is already well es- popular open-source applications. The final section tablished in the literature. In (Maalej et al., 2014), presents our conclusions together with plans for fu- the authors conduct an industry survey covering over ture work. 2 RELATED WORK large-scale industrial evaluation with encouraging re- sults (Aho et al., 2014). A representative approach is The first important work is the Valgrind1 multi- the GUISurfer tool, which builds a language indepen- platform dynamic binary instrumentation framework. dent model of the targeted GUI using static analysis Valgrind loads the target into memory and instru- (Silva et al., 2010). ments it (Nethercote and Seward, 2007) in a man- Another active area of research relevant to JE- ner that is similar with our approach. Among Val- Tracer is GUI application testing, an area with notable grind’s users we mention the DAIKON invariant de- results both from commercial as well as academic or- tection system (Perkins and Ernst, 2004) as well as the ganizations. The first wave of tools enabling auto- TaintCheck system (Newsome, 2005). An approach mated testing for GUI applications are represented by related to Valgrind is the DTrace2 tool. Described as capture-replay implementations such as Pounder or an ”observability technology” by its authors (Cooper, Marathon, which enable recording a user’s interaction 2012), DTrace allows observing what system compo- with the application (Nedyalkova and Bernardino, nents are doing during program execution 2013). The recorded actions are then replayed auto- While the first efforts targeted natively-compiled matically and any change in the response of the tar- languages from the C family, the prevalence of get application, such as an uncaught exception or an instrumentation-friendly and object oriented plat- unexpected window being displayed are interpreted forms such as Java and .NET spearheaded the cre- as errors. The main limitation of such tools lays ation of supportive tooling from platform developers in limitations when identifying graphical widgets, as and third parties alike. In this regard we mention Or- changes to the target application can easily break test acle’s Java Mission Control and Flight Recorder tools case replayability. More advanced tools integrate (Oracle, 2013) that provide monitoring for Java sys- scripting engines facilitating quick test suite creation tems. Another important contribution is Javaassist, such as Abbot and TestNG (Ruiz and Price, 2007). a tool which facilitates instrumentation of Java class However, existing open-source tools are limited to files, including core classes during JVM class load- a single GUI toolkit (Nedyalkova and Bernardino, ing (Chiba, 2004). Its capabilities and ease of use led 2013). Even more so, some of these tools such as to its widespread use in dynamic analysis and tracing Abbot and Pounder are no longer in active develop- (van der Merwe et al., 2014). As discussed in more ment, and using them with the latest version of Java detail within the following sections, JETracer uses yields runtime errors. Javaassist for instrumenting key classes responsible These projects paved the way for commercial im- for firing events within targeted GUI frameworks. plementations such as MarathonITE3, a fully-featured The previously detailed frameworks and tools and commercial implementation of Marathon or the have facilitated the implementation of novel soft- Squish4 toolkit. When compared with their open- ware used both in research and industry targeting pro- source alternatives, these applications provide greater gram comprehension, software visualization and test- flexibility by supporting many GUI toolkits such as ing. A first effort in this direction was the JOVE tool AWT/Swing, SWT, Qt, Web as well as mobile plat- for software visualization (Reiss and Renieris, 2005). forms. In addition, they provide more precise wid- JOVE uses code instrumentation to capture snapshots get recognition algorithms which helps with test case of each working thread and create a program trace playback. GUI interactions can be recorded as scripts which can then be displayed using several visualiza- using non-proprietary languages such as Python or tions (Reiss and Renieris, 2005). A different approach JavaScript, making it easier to modify or update test is taken within Whyline, which proposes a number cases. As part of our research we employed the of ”Why/Why not” type of questions about the target Squish tool for recording consistently replayable user program’s textual or graphical output (Ko and Myers, interaction scenarios which are described in detail 2010). Whyline uses bytecode instrumentation to cre- within the evaluation section. From the related work ate program traces and record the program’s graphical surveyed, we found the Squish implementation to be output, with the execution history used for providing the closest one to JETracer. The Squish tool con- answers to the selected questions. sists of a server component that is contained within An important area of research where JETracer the IDE and a hook component deployed within the is expected to contribute targets the visualization of AUT (Froglogic, 2015). The Java implementation of GUI-driven applications. This is of particular interest Squish uses a Java agent and employs a similar ar- as an area where research results recently underwent chitecture to our own framework, which is detailed 1http://valgrind.org/ 3http://marathontesting.com/ 2http://dtrace.org/blogs 4http://www.froglogic.com/squish within the following section. In contrast to commercial implementations en- cumbered by restrictive and pricey licensing agree- ments, we designed JETracer as an open framework to