Fjavac: a functional Java compiler

Stephen Tse and Steve Zdancewic, University of Pennsylvania

Fjavac is a Java 5 compiler implemented in the functional language OCaml. Currently the compiler can parse and pretty-print all JDK 1.5 files (including generics and wildcards). Basic type checking and bytecode compilation are implemented, but supports for generics (type inference and capture conversion) are still underway.

Our long term goal is to produce a complete and formal specification of Java compilation. To be complete, all language features and rules that are informally described in Sun's Java language specification will be included. To be formal, the specification will be written in a machine-checkable language of a logical framework (Twelf), using only axioms and inference rules. Fjava is written in a functional style to make such a formalization possible.

The compiler also includes a new parser generator based on Generalized LR (GLR) parsing. GLR allows syntax specification in the full context-free grammar, eliminating shift or reduce conflicts in LR/LALR parsing. High efficiency is achieved using a graph-structured parse stack. Ordered CFG [see the paper Concise concrete syntax below] specifies the datatype tags together with associativity and precedence per production rule, making it possibly to generate abstract syntax trees from a concise specification of concrete syntax.

(2006-0212): Both fjavac and ocfgc now run with F# on Mono!