Introduction to Compiler Construction in a Java World

If you come across a bug in the j-- compiler, please let us know about it at j--@cs.umb.edu. We appreciate your feedback.

Known Issues

Reported by Vy Thao Nguyen on Feb 17, 2013 - (fixed) The following snippet produces correct code (class file) but reports a code generation error. Fix: override the short-circut form of codegen() in JInstanceOfOp.

...
if ("Hello, world!" instanceof String) {
    System.out.println("True");
}
else {
    System.out.println("False");
}
...

Reported by Sascha Van Cauwelaert on Feb 14, 2013 - (fixed) A non-void method without a return statement does not result in a compilation error. Fix: use a predicate in JMethodDeclaration to check if a non-void method is missing a return statement, and if so report an error.

Reported by Sascha Van Cauwelaert on Feb 14, 2013 - (fixed) The code generated for boolean arrays is incorrect. Fix: for boolean arrays, use baload/bastore instructions in JArrayExpression and JArrayInitializer instead of iaload/iastore instructions.

Reported by Olivier Tilmans on Feb 11, 2013 - (fixed) The JavaCC parser for j-- does not parse a statement such as int a = new int[10] correctly. The problem is in the implementation of the creator() method in the j--.jj file. Here is the fix:

private JExpression creator(): {
    int line = 0;
    Type type = null;
    ArrayList<JExpression> args = null;
    ArrayList<JExpression> dims = null;
    JArrayInitializer init =  null;
    JExpression expr = null;
    Type expected = null;
}
{
    try {
        ( type = basicType() |
          type = qualifiedIdentifier() )
        { line = token.beginLine; expected = type; }
        (
            args = arguments()
            { expr = new JNewOp( line, type, args ); } |
            LOOKAHEAD( <LBRACK> expression() <RBRACK> )
            expr = newArrayDeclarator( type ) |
            <LBRACK> <RBRACK> { expected = new ArrayTypeName( expected ); }
            (
                LOOKAHEAD( <LBRACK> <RBRACK> )
                <LBRACK> <RBRACK>
                { expected = new ArrayTypeName( expected ); }
            )*
            [
               expr = arrayInitializer( expected )
            ]
        )
    }
    catch ( ParseException e ) {
        expr = new JWildExpression( token.beginLine );
        recoverFromError( new int[] { SEMI, EOF }, e );
    }
    { return expr; }
}

Reported by Dzu Nguyen on Jan 31, 2013 - (fixed) Non-static calls to TestCase.assertEquals() method in the test files under $j/j--/tests/junit result in compiler warnings if you use Java 7.