Week 4

Exercises on JOOS

The purpose of these exercises is to help you get comfortable with the JOOS development environment and to improve the quality of the JOOS benchmarks you write for Milestone 3.
  1. Write 3 tiny JOOS programs:

    1. The first simply prints "Hello World!".
    2. Another sorts a list of integers given on stdin and writes the sorted list to stdout.
    3. A final program sorts a list of words given on stdin by word frequency and writes the top 10 words and their frequencies to stdout. Consider only tokens matching [A-Za-z]+ as words and furthermore since we're Unix people (right?) assume case matters. What are the top 10 words and their frequencies in cs520/2007/public_html/index.html?

    Motivation: 1.1 and 1.2 are there to help you figure out how to do input and output in JOOS, and 1.3 is to help identify more problems you might have in writing Java and JOOS programs.

  2. Compile your 3 programs to Java bytecode with joosc and javac. Disassemble them to Jasmin assembler with d-java. How do the sizes of the .j files compare for each compiler? Use wc -l to measure them.

    Motivation: understand the process by which joosc works (joos + jasmin), and see how the bytecode generated by joos compares with that generated by javac. Presumably you'll be interested enough to summarily inspect the .j files as well.

  3. Summarize the class hierarchy and containment relationships for the AwtDemos/AllEvents.java program. Draw a (partial) call graph starting from main(). Consider inheritance, containment, and calls across library interfaces, but do not consider library implementation details. You are encouraged to use dot to draw the call graph, it is a powerful tool for drawing directed graphs quickly.

    Motivation: The objective here is to improve literacy and work on addressing any potential fear of "large"-ish programs; grep or Eclipse and Google will probably help you to navigate and understand the source code. If this question is taking too long, just give a partial answer addressing some interesting part of the AllEvents.java program.

Maintained by Christopher J. F. Pickett. [HOME]