Week 7/43

Exercises on type checking

  1. Give the type rules for:
    • for-statements;
    • arrays.
  2. Construct the type proof for the statement:
    Cons x,y; int z; x = new Cons(z+1,y)
    
  3. Consider a scenario, where we extend JOOS with a type float that also has a + operator. Furthermore, int values may be coerced into float values as needed. Explain the implications for the type checker.
  4. A radical extension of the JOOS type system allows a variable to be typed as:
    A,B,C x;
    
    which means that x may contain objects of either of the classes A, B, or C. Types are thus finite sets of classes, rather than just single classes. With the appropriate type rules, this will allow more programs to be accepted as statically type correct. Show examples of such type rules for the JOOS syntax. Show that they are strictly more powerful than the standard type system. Do you like this new language?
  5. Study the code for type checking JOOS programs.

Maintained by Laurie J. Hendren. Last modified Fri Sep 17 07:25:39 EDT 2004. [HOME]
Compiler research projects: Soot, a Java analysis, optimization and transformation toolkit ---- abc, an AspectJ compiler.