CS712/CS812
Programming Project Part 2
Spring 1997


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, but without inheritance (i.e. no "extends" clause) and without the overloading or overriding of methods. This level should support the use of "modifiers" with classes, fields and methods.

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 inheritance (only of classes, not interfaces), overloading and overriding.

At the 100% level, your compiler should support interfaces. This includes the definition of interfaces as well as classes that implement interfaces. Remember: a class can implement more than one interface. Since we are not doing initializers, you may assume that interfaces being defined will have no fields.

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. (Bonus points will be awarded if you are the first student to find a bug in javac concerning the processing of declarations: 3% per bug, up to a maximum of 15%. Bug reports should be e-mailed to pjh@cs.unh.edu.)

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.

Your programs will be graded using an Alpha machine (e.g. hopper and christa) so be sure to test in that environment.

You should start with the C++ code we are providing (in ~cs712/public/javac712). This code includes "skeleton" lex and yacc specifications, 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. You should also submit all source files, both the files you created and the ones that were provided to you (even if you have not modified them). Your executable program should be called "javac712". Your programs should be submitted for grading from either hopper or christa. 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

To receive full credit for the assignment, you must turn in your files prior to 8am on Monday March 3. 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 11, 1997.

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