CS712/CS812
Programming Project Part 2
Spring 1998


This project part concerns the compilation of Java declarations. The goal is to compile Java declarations into the appropriate entries in a Java class file. You should use the Java class file dump utility (javap) to check your work.

At the 75% level, your compiler should support Java class declarations that include field and method declarations. You should also support inheritance of classes, but without the overloading or overriding of methods. In addition, this level should support the use of "modifiers" with classes, fields and methods. However, at this level you are not responsible for doing any semantic checks for modifiers. (You can assume any modifiers given in the input will be error free.)

You may assume there will be no initializers (including static initializers) and the method bodies will simply be empty blocks.

At the 85% level, your compiler should support, in addition to all the 75% level functionality, method overriding and the semantic checks for the "protected" and "final" modifiers.

At the 100% level, your compiler should support, in addition to all the 75% level and 85% level functionality, method overloading and the semantic checks for all modifiers.

A large part of your effort will be to determine and make the necessary semantic checks (e.g. illegal modifier combinations, duplicate field name, etc.). You may need to consult the Gosling, Joy and Steele book. Also you may want to use the Sun Java compiler, javac, to explore test cases.

It is also strongly recommended that you read Chapter 4 of the Lindhom and Yellin book before you begin the process of generating a class file.

Syntactic error recovery is not required for this assignment, but you may find it convenient to add error productions to synchronize at semicolons and closing curly brackets.

Your program will be graded primarily by testing it for correct functionality. However, you may lose points if your program is not properly structured or adequately documented.

Because most of us are Java novices, all test files used for grading will be publicly available prior to the due date. When ready, the test files will be in ~cs712/public/proj2 on alberti.unh.edu.

Your programs will be graded using alberti.unh.edu so be sure to test in that environment.

You should start with the C++ code we are providing (in ~cs712/public/javac712.tar.gz on alberti.unh.edu). This code includes "skeleton" lex and yacc specifications. The code also includes two libraries jlib and vlib. These libraries provide code for representing Java types, code for generating class files, and other useful tools.

You must submit a Makefile (called "Makefile") so that we can conveniently build your compiler. This Makefile should be for local use, linking vlib and jlib from the public cs712 area. You should also submit all source files, except for the jlib and vlib source. Your executable program should be called "javac712".

Your compiler should read from stdin. Error messages should be written to stdout.

Your programs should be submitted for grading from alberti.unh.edu. To turn in this assignment, type:
~cs712/bin/submit proj2 list of files to submit

Do not turn in any non-Ascii files (i.e. no object files, no executable files, etc.).

Submissions can be checked by typing:
~cs712/bin/scheck proj2 on alberti.unh.edu.

To receive full credit for the assignment, you must turn in your files prior to 8am on Monday March 2. Late submissions will be accepted at the penalty of 5% per day up to one week late.

Remember: as always you are expected to do your own work on this assignment.


Last modified on February 5, 1998.

Comments and questions should be directed to pjh@cs.unh.edu