Statically safe program generation with safegen

SafeGen is a meta-programming language for writing statically safe generators of Java programs. If a program generator written in SafeGen passes the checks of the SafeGen compiler, then the generator will only generate well-formed Java programs, for any generator input. In other words, statically checking the generator guarantees the correctness of any generated program, with respect to static checks commonly performed by a conventional compiler (including type safety, existence of a superclass, etc.). To achieve this guarantee, SafeGen supports only language primitives for reflection over an existing well-formed Java program, primitives for creating program fragments, and a restricted set of constructs for iteration, conditional actions, and name generation. SafeGen's static checking algorithm is a combination of traditional type checking for Java, and a series of calls to a theorem prover to check the validity of first-order logical sentences constructed to represent well-formedness properties of the generated program under all inputs. The approach has worked quite well in our tests, providing proofs for correct generators or pointing out interesting bugs.

[1]  James R. Larus,et al.  Reflective program generation with patterns , 2006, GPCE '06.

[2]  Dirk Draheim,et al.  A type system for reflective program generators , 2005, GPCE'05.

[3]  Robert Glück,et al.  Efficient Multi-level Generating Extensions for Program Specialization , 1995, PLILP.

[4]  Jonathan Bachrach,et al.  The Java syntactic extender (JSE) , 2001, OOPSLA '01.

[5]  Gregor Kiczales,et al.  Aspect-oriented programming , 2001, ESEC/FSE-9.

[6]  Johan van Benthem,et al.  Modal Languages and Bounded Fragments of Predicate Logic , 1998, J. Philos. Log..

[7]  Simon L. Peyton Jones,et al.  Template meta-programming for Haskell , 2002, Haskell '02.

[8]  Markus Mohnen Interfaces with default implementations in Java , 2002, PPPJ/IRE.

[9]  Shan Shan Huang,et al.  Easy language extension with meta-aspectJ , 2006, ICSE.

[10]  Greg Nelson,et al.  Extended static checking for Java , 2002, PLDI '02.

[11]  William G. Griswold,et al.  An Overview of AspectJ , 2001, ECOOP.

[12]  Shan Shan Huang,et al.  Morphing: Safely Shaping a Class in the Image of Others , 2007, ECOOP.

[13]  Shan Shan Huang,et al.  Generating AspectJ Programs with Meta-AspectJ , 2004, GPCE.

[14]  G. G. Stokes "J." , 1890, The New Yale Book of Quotations.

[15]  Daniel Weise,et al.  Programmable syntax macros , 1993, PLDI '93.

[16]  Walid Taha,et al.  Multi-stage programming with explicit annotations , 1997 .

[17]  Harald Ganzinger,et al.  A superposition decision procedure for the guarded fragment with equality , 1999, Proceedings. 14th Symposium on Logic in Computer Science (Cat. No. PR00158).

[18]  Walid Taha,et al.  Implementing Multi-stage Languages Using ASTs, Gensym, and Reflection , 2003, GPCE.

[19]  Yannis Smaragdakis,et al.  JTS: tools for implementing domain-specific languages , 1998, Proceedings. Fifth International Conference on Software Reuse (Cat. No.98TB100203).

[20]  Gail C. Murphy,et al.  Explicit programming , 2002, AOSD '02.

[21]  Robert Gliick Efficient Multi-level Generating Extensions for Program Specialization , 2005 .

[22]  Wilson C. Hsieh,et al.  Maya: multiple-dispatch syntax extension in Java , 2002, PLDI '02.

[23]  Shan Shan Huang,et al.  cJ: enhancing java with safe type conditions , 2007, AOSD.

[24]  Eelco Visser,et al.  Meta-programming with Concrete Object Syntax , 2002, GPCE.

[25]  Yannis Smaragdakis,et al.  Aspectizing server-side distribution , 2003, 18th IEEE International Conference on Automated Software Engineering, 2003. Proceedings..

[26]  Walid Taha,et al.  Tagless staged interpreters for typed languages , 2002, ICFP '02.

[27]  Don Batory,et al.  Scaling Step-Wise Refinement , 2004, IEEE Trans. Software Eng..

[28]  Christoph Weidenbach,et al.  SPASS: Combining Superposition, Sorts and Splitting , 2000 .

[29]  Todd D. Millstein,et al.  Statically scoped object adaptation with expanders , 2006, OOPSLA '06.

[30]  Christopher G. Lasater,et al.  Design Patterns , 2008, Wiley Encyclopedia of Computer Science and Engineering.