Mini Java Programming Project

CSE 401 Winter 2014

Robert R. Henry


This document is subject to change, especially early on in the quarter.  We’ll try our best to let you know via email the gist of the changes.

The master copy of this document is held in a document, so it may render a little funny after it is copied to the CSE course web.


The course project is to implement an extended version of the MiniJava language specified in the Appendix of Appel's Modern Compiler Implementation in Java, 2nd edition, with amendments and modifications given in this assignment, or in modifications to this assignment.

We will supply you with the Java and C source code for a seed for your project, which includes:

The basic grammar is described on the MiniJava web site. We will implement more than this grammar as we have additional extensions. MiniJava is a subset of Java and the meaning of a MiniJava program is given by its meaning as a Java program.

As compared to full Java, a MiniJava program consists of a single class containing a static main method followed by zero or more other classes.

The basic MiniJava grammar is given on the project web site and in the Appendix of Appel's Modern Compiler Implementation in Java (2nd ed). Look at the grammar carefully to see what is and is not included in the language subset.

You will have to implement several binary operators over and beyond what’s given in the basic MiniJava grammar, just because it will make programming real useful programs in MiniJava that much easier.

You should implement (or not implement…) the full MiniJava as described there, but with these changes:


Suggested General Implementation Order

This is merely a suggestion.  You may find that you bounce around the matrix of (extensions * compiler phases), based on what you are working on at the time, and what you know, or what’s fun at the moment.

Statement Counting Profiler

You must implement a statement counting profiler.  A collaboration between your compiler, your runtime system, and your post execution system must be able to print out the original source code of the compiled Mini Java program, with annotations showing how many times each statement was executed. It is OK to assume the Mini Java program has a maximum number of lines. If there is more than one statement per line, just show the counts for one of the statements on the line. (But who would write code like that anyway, since it violates the Java style guidelines here?)


The basic project requirements are small enough to be tractable in a one-quarter course project, but include enough to cover the core ideas of compiling an object-oriented (as well as procedural) language.

If you are feeling ambitious and have the time, you are invited to add additional parts of Java to the language.  While this sounds daunting now, once you figure out the basics of the compiler architecture, it becomes a simple matter of adding a handful of lines of Java code to your compiler in each of half a dozen places, emulating what’s already there.

Here are a few suggestions.

Some Simple Ideas for Extensions

Interesting and more Sophisticated ideas for Extensions

Of the suggested extensions, adding instanceof, type casts, and super are particularly instructive.

Some small amount of extra credit will be awarded to projects that go beyond the basic requirements.


Evaluating and grading the project will be done with a combination of code reading by the TAs; code walk throughs with the TAs and possibly the instructor; and end of quarter face to face discussions between the instructor, the TAs and members of each group.