Insert parentheses

Lets you insert superfluous parentheses automatically to avoid any doubts about how an expression is evaluated.

Multiple expressions

When enabled, Jalopy inserts parentheses around expressions that involve more than two terms in order to clarify their precedence. It is always good advise to use more parentheses than you think you need. They may not be required, but they add clarity and don’t cost anything.

Example 2.20. How is this expression evaluated?

int result = 12 + 4 % 3 * 7 / 8;

Example 2.21. How is this expression evaluated? (continued)

int result = 12 + (4 % 3 * 7 / 8);

throw expression

Lets you insert parentheses around the throw expression to treat the statement like a function call.

Since 1.6

Example 2.22. Throw statement

if ( condition )
    throw new IllegalStateException();

Example 2.23. Throw statement with parentheses

if ( condition )
    throw ( new IllegalStateException() );

return expression

Lets you insert parentheses around the return expression to treat the statement like a function call.

Since 1.6

Example 2.24. return statement

if ( condition)
    return true;

Example 2.25. return statement with parentheses

if ( condition)
    return ( true );