A New Eclipse-Based JML Compiler Built Using AST Merging Amritam Sarcar

A New Eclipse-Based JML Compiler Built Using AST Merging Amritam Sarcar

University of Texas at El Paso DigitalCommons@UTEP Departmental Technical Reports (CS) Department of Computer Science 3-1-2010 A New Eclipse-Based JML Compiler Built Using AST Merging Amritam Sarcar Yoonsik Cheon University of Texas at El Paso, [email protected] Follow this and additional works at: http://digitalcommons.utep.edu/cs_techrep Part of the Computer Engineering Commons Comments: Technical Report: UTEP-CS-10-08 Recommended Citation Sarcar, Amritam and Cheon, Yoonsik, "A New Eclipse-Based JML Compiler Built Using AST Merging" (2010). Departmental Technical Reports (CS). Paper 8. http://digitalcommons.utep.edu/cs_techrep/8 This Article is brought to you for free and open access by the Department of Computer Science at DigitalCommons@UTEP. It has been accepted for inclusion in Departmental Technical Reports (CS) by an authorized administrator of DigitalCommons@UTEP. For more information, please contact [email protected]. A New Eclipse-Based JML Compiler Built Using AST Merging Amritam Sarcar and Yoonsik Cheon TR #10-08 March 2010 Keywords: incremental compilation; pre and postconditions; runtime assertion checking; AST merging; Eclipse; JML 1998 CR Categories: D.2.4 [Software Engineering] Software/Program Verification — Assertion checkers, class invariants, formal methods, programming by contract; D.3.2 [Programming Languages] Language Classifications — Object-oriented languages; D.3.4 [Programming Languages] Processors — Compilers, incremental compilers; F.3.1 [Logics and Meanings of Programs] Specifying and Verifying and Reasoning about Programs — Assertions, invariants, pre- and post-conditions, specification techniques. To appear in the Second World Congress on Software Engineering, December 19-20, 2010, Wuhan, China. Department of Computer Science The University of Texas at El Paso 500 West University Avenue El Paso, Texas 79968-0518, U.S.A. A New Eclipse-Based JML Compiler Built Using AST Merging Amritam Sarcar Yoonsik Cheon Microsoft Corporation Department of Computer Science One Microsoft Way The University of Texas at El Paso Redmond, WA 98052 El Paso, TX 79968 [email protected] [email protected] Abstract—The Java Modeling Language (JML) is a formal that parses a source code file twice (see Section IV for interface specification language to document the behavior of details). We observed that the AST merging technique is Java program modules and has been used in many research on average 1.4 times faster than the double-round strategy, and industrial projects. However, its inability to support Java 5 features such as generics is reducing its user base significantly. and overall the new compiler is 3 to 4.5 times faster than the Besides, the JML compiler is on average 8.5 times slower than jmlc compiler. We also learned that the speedup increases the javac Java compiler. In this paper, we present a new JML as the code size increases, and thus we believe that new compiler built on the Eclipse Java compiler to support Java 5 compiler will be better suitable for an industrial use. features. We used a technique called AST merging to implement The rest of this paper is organized as follows. In Section II coarse-grained incremental compilation. In our experiments we observed a significant improvement in compilation speed; the below we give the necessary background information on new compiler is 3 to 4.5 times faster than the current one. JML, runtime assertion checking, and the Eclipse platform. In Section III we describe the problem of the current JML Keywords-incremental compilation; pre and postconditions; runtime assertion checking; AST merging; Eclipse; JML compiler focusing on its compilation speed. In Sections IV and V we explain in detail the designs of the current and the new JML compilers, respectively, by focusing on the I. INTRODUCTION double-round strategy and the AST merging. In Section VI The Java Modeling Language (JML) is a formal be- we compare the two compilers through experiments, and in havioral interface specification language for Java [1]. It Section VII we review some of the most related work. In is used for detail design documentation of Java program Section VIII we close this paper with a concluding remark. modules such as classes and interfaces. JML has been used II. BACKGROUND extensively by many researchers and practitioners across various projects. It has a large and varied spectrum of A. JML and Runtime Assertion Checking tool support, extending from runtime assertion checking to JML is a formal behavioral interface specification lan- theorem proving [2] [3]. Amongst these tools, the runtime guage tailored for specifying both the runtime behavior assertion checking compiler, known as the JML compiler and the syntactic interface of Java program modules [1]. (jmlc) [4], is one of the most widely used tools by Java de- It uses Hoare-style pre and postconditions to specify the velopers. However, there has been problems for tool support. behavior of a program module, and JML specifications are One problem is its inability to keep up with new features commonly written in a source code file as special comments. such as generics being introduced by Java. Another problem Figure 1 shows an example JML specification. The keyword especially with the JML compiler is its slow compilation spec public indicates a private field, courses, is treated speed. These problems are recognized as a barrier to a as public for specification purpose; for example, it can be practical use of JML in an industrial setting [5]. used in the specification of a public method such as the In this paper, we present a new JML compiler built by addCourse method. As shown, a JML specification pre- extending the Eclipse Java compiler. The new JML compiler cedes the Java declaration such as a method declaration that supports Java 5 features such as generics. Building the new it annotates. The requires clause specifies the precondition, compiler on a well-maintained, successful open-source code and the ensures clause specifies the postcondition. In the base will facilitate accommodating future language changes postcondition, an old expression denotes the value of an in Java easily. To address the runtime performance problem expression in the pre-state. It is commonly used to specify of the JML compiler, we introduced a technique called the behavior of a mutation method. an AST merging. In essence, AST merging eliminates the JML can be used as a design-by-contract language for need for parsing source code twice, as parsing (including Java, as a significant subset of it can be translated to runtime scanning) is one of the most costly tasks during compilation; checks by the JML compiler. For example, if the sample the jmlc compiler uses a double-round compilation scheme code is compiled with the JML compiler, every execution Table I public class CourseManager { COMPLEXITY OF SAMPLE PROGRAMS private /*@ spec_public @*/ Set<Course> courses; /*@ requires !courses.contains(nc); Program Types Methods Fields Lines @ ensures courses.contains(nc) && AlarmClock 4 17 11 389 @ (\forall Course c; \old(courses.contains(c)); Purse 3 8 6 192 @ courses.contains(c)) && Digraph 9 64 14 900 @ (\forall Course c; courses.contains(c); DirObserver 5 13 3 189 @ \old(courses.contains(c)) || c == nc); PriorityQueue 3 13 3 101 @*/ DLList 8 66 14 1228 public void addCourse(Course nc) { courses.add(nc); TwoWayNode 8 70 10 1272 } Counter 3 6 3 103 // other fields and methods LinearSearch 4 14 1 221 } Proof 1 4 2 241 Reader 4 11 11 257 SetInterface 3 23 7 782 Figure 1. A Sample JML specification BoundedStack 5 33 11 573 UnboundedStack 5 21 5 223 Entry 4 22 6 299 of the addCourse method will be checked against its pre and postconditions. There are also tools based on the JML 9 compiler that turn JML specifications into test oracles and javac perform automated testing [2]. 8 jmlc B. Eclipse 7 Eclipse is a plug-in based application platform. All 6 Eclipse features are supported through plug-ins. Java support 5 is also provided through a collection of plug-ins, called the Eclipse Java Development Tooling (JDT), that offers among Time(sec) 4 other things a built-in standard Java compiler and debugger [6]. The Eclipse JDT code base is well maintained and 3 relatively kept up to date with respect to language changes 2 in Java. One arching rule of Eclipse development is that pub- 1 lic APIs must be maintained forever. This API stability 0 t e h r e s e r h helps avoid breaking client code. Because of this rule, p e u i d te rc urs ra rv e L n a P g e u u e Proof tack Entry s DL yNo S Reader terface S Stack rmClock Di tyQ Co ed d however, there are two different packages concerned about la rOb Wa A iori inear SetIn Di r wo L ound P T B abstract syntax trees (ASTs) for the Java programming Unbounde Sample Programs language. The classes for the JDT internal ASTs are found in org.eclipse.jdt.internal.compiler.ast package, whereas the Figure 2. Compilation times of jmlc and javac public version of the AST is partly reproduced in the org.eclipse.jdt.core.dom package. numbers of types, methods, fields, and source code lines. III. PROBLEMS WITH THE JML COMPILER All programs are heavily annotated with JML specifications. The JML compiler (jmlc) is a key component of We compiled each of the sample programs with the JML compiler and the javac Java compiler (version 1.6.0.05) the Common JML tools available from the JML website 1 (http://www.jmlspecs.org). It is one of the most and measured its compilation time . We used the Java widely used JML tools among Java developers. However, hotspot Client VM version 1.6.0.05-b13.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    8 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us