[Skip to content]

Changes

This document describes the changes in the Java formatter engine of Jalopy 1.5 that may have an impact on formatting style (depending on your code convention).

Line length exceeded for type parameters

The maximal line length could be exceeded for certain parameterized assignment expressions when using Standard indentation and with "Type parameter wrapping" disabled

                                                                           |
private final HashMap<String, String valess = new HashMap<String, String();
                                                                           |

was wrongly formatted as (depending on your settings)

                                                                           |
private final HashMap<String, String> valess = new HashMap<String, String();
                                                                           |

Now it will be printed (depending on your settings)

                                                                           |
private final HashMap<String, String valess =                             |
        new HashMap<String, String();                                     |
                                                                           |

Line length exceeded for "for" statements

for statements without an update part could exceed the maximal line length when using Sun brace style.

                                                                   |
for (Iterator i = updateKeyMap.entrySet().iterator(); i.hasNext();)|{
}                                                                  |

was wrongly formatted as (depending on your settings)

                                                                   |
for (Iterator i = updateKeyMap.entrySet().iterator(); i.hasNext();)|{
}                                                                  |

Now it will be printed (depending on your settings)

                                                                   |
for (Iterator i = updateKeyMap.entrySet().iterator();              |
        i.hasNext();) |                                            |
}                                                                  |

Line length exceeded for dotted expressions

Some dotted expressions were not wrapped even when the maximal line length was exceeded.

                                                                   |
return ((NativeLibrary) (ClassLoader.nativeLibraryContext.peek())) |
    .fromClass;                                                    |

was wrongly formatted as (depending on your settings)

                                                                   |
return ((NativeLibrary) (ClassLoader.nativeLibraryContext.peek())).fromClass;
}                                                                  |

Now it will be printed (depending on your settings)

                                                                   |
return ((NativeLibrary) (ClassLoader.nativeLibraryContext.peek())) |
    .fromClass;                                                    |

Line length exceeded for "for" statements

With Sun brace style enabled, for statements could exceed the maximal line length.

                                                                        |
for (Iterator iter = metadata.markerSequence.iterator(); iter.hasNext();) {
  ...                                                                   |
}                                                                       |

was wrongly formatted as (depending on your settings)

                                                                        |
for (Iterator iter = metadata.markerSequence.iterator(); iter.hasNext();) {
  ...                                                                   |
}                                                                       |

Now it will be printed (depending on your settings)

                                                                   |
for (Iterator iter = metadata.markerSequence.iterator();           |
        iter.hasNext();) {                                         |
    ...                                                            |
}                                                                  |

Method calls wrapped too early within anonymous inner class

Line wrapping happened too early for method calls within anonymous inner classes defined as nested method call arguments.

Thread t = new Thread(new Runnable()                                |
    {                                                               |
        public void run()                                           |
        {                                                           |
            System.out.out.println(String.format("12345678901", d));|
        }                                                           |
    });                                                             |

was wrongly formatted as (depending on your settings)

Thread t = new Thread(new Runnable()                                |
    {                                                               |
        public void run()                                           |
        {                                                           |
            System.out.out.println(String.format("12345678901",     |
                                                 d));               |
        }                                                           |
    });                                                             |

Now it will be printed (depending on your settings)

Thread t = new Thread(new Runnable()                                |
    {                                                               |
        public void run()                                           |
        {                                                           |
            System.out.out.println(String.format("12345678901", d));|
        }                                                           |
    });                                                             |

Infix operators were wrapped too early

Infix operators were wrapped too early in some rare cases.

                                                                        |
if (!isInitialized || !(realType().kind().value() == TCKind._tk_ushort))|
    break;                                                              |

was wrongly formatted as (depending on your settings)

                                                                        |
if (!isInitialized || !(realType().kind().value() ==                    |
        TCKind._tk_ushort))                                             |
    break;                                                              |

Now it will be printed (depending on your settings)

                                                                        |
if (!isInitialized || !(realType().kind().value() == TCKind._tk_ushort))|
    break;                                                              |

Javadoc @param tag order not corrected

The order of Javadoc @param tags was not corrected when "Correct tag section" was enabled, but "Sort standalone tags" disabled.

/**
 * @param c c
 * @param a a
 * @param d d
 * @param b b
 */
public void test(int a, String b, Object c, float d) {
}

was wrongly formatted as (depending on your settings)

/**
 * @param  c c
 * @param  a a
 * @param  d d
 * @param  b b
 */
public void test(int a, String b, Object c, float d) {
}

Now it will be printed (depending on your settings)

/**
 * @param  a a
 * @param  b b
 * @param  c c
 * @param  d d
 */
public void test(int a, String b, Object c, float d) {
}

Wrong aligning of variable declarations in case blocks

With "Align identifiers" and/or "Align assignments" enabled, multiple variable declarations appearing at the top of case blocks could lead to wrong indentation when "Detect chunks by blank lines" was enabled and some blank lines between first and successive declarations.

switch (c) {
case '#':

    UserInterfaceContext rContext = rElement.getContext();

    ClassLoader loader = getClass().getClassLoader();
    InputStream is = loader.getResourceAsStream(sText);
}

was wrongly formatted as (depending on your settings)

switch (c) {
case '#':

    UserInterfaceContext rContext = rElement.getContext();

    ClassLoader          loader   = getClass().getClassLoader();
    InputStream          is       = loader.getResourceAsStream(sText);
}

Now it will be printed (depending on your settings)

switch (c) {
case '#':

    UserInterfaceContext rContext = rElement.getContext();

    ClassLoader loader = getClass().getClassLoader();
    InputStream is     = loader.getResourceAsStream(sText);
}

Wrong aligning of declaration parameters

With "Align declaration parameters" and endline indentation enabled, parameters could be wrongly aligned when the parameter type contained a type argument.

                                                |
public <T, R Collection<Abc<T, R getXyz(Xyz<T,R rXyz)
                                                |

was wrongly formatted as (depending on your settings)

                                                |
public <T, R Collection<Abc<T, R getXyz(Xyz<T,
                                               R   rXyz)
                                                |

Now it will be printed (depending on your settings)

                                                |
public <T, R Collection<Abc<T, R getXyz(Xyz<T,R rXyz)
                                                |

Missing aligning of variable declaration assignments

With "Align assignments" enabled, aligment was not performed for a specific variable declaration/other statement order.

boolean variableSet = false;
VMCObject object;

if ((object = (VMCObject) objectMap.get(objectKey)) == null) {
    return false;
}

ObjectAlarmStateEnum alarmState = object.getAlarmState();
ObjectControlStateEnum controlState = object.getControlState();
int audioControlStateBM = object.getAudioControlStateBM();
VRObjectStateEnum vrState = object.getVRState();

was wrongly formatted as (depending on your settings)

boolean variableSet = false;
VMCObject object;

if ((object = (VMCObject) objectMap.get(objectKey)) == null) {
    return false;
}

ObjectAlarmStateEnum alarmState = object.getAlarmState();
ObjectControlStateEnum controlState = object.getControlState();
int audioControlStateBM = object.getAudioControlStateBM();
VRObjectStateEnum vrState = object.getVRState();

Now it will be printed (depending on your settings)

boolean variableSet = false;
VMCObject object;

if ((object = (VMCObject) objectMap.get(objectKey)) == null) {
    return false;
}

ObjectAlarmStateEnum alarmState     = object.getAlarmState();
ObjectControlStateEnum controlState = object.getControlState();
int audioControlStateBM             = object.getAudioControlStateBM();
VRObjectStateEnum vrState           = object.getVRState();

Wrong aligning of assignments

With "Align assignments" and "Wrap on-demand after assignments" enabled, but "Detect chunks by line wrap" disabled, assignment expressions that exceeded the maximal line length were not aligned.

aaaaaaaa = 234;                                                         |
bbbbb = "xxxxxxxxx" + "xxxxxxxxx" + "xxxxxxxxx" + "xxxxxxxxxxxxxxxxxxxx";
cccccccccccc = 345;                                                     |

was wrongly formatted as (depending on your settings)

aaaaaaaa     = 234;                                                     |
bbbbb =                                                                 |
    "xxxxxxxxx" + "xxxxxxxxx" + "xxxxxxxxx" + "xxxxxxxxxxxxxxxxxxxx";   |
cccccccccccc = 345;                                                     |

Now it will be printed (depending on your settings)

aaaaaaaa     = 234;                                                     |
bbbbb        =                                                          |
    "xxxxxxxxx" + "xxxxxxxxx" + "xxxxxxxxx" + "xxxxxxxxxxxxxxxxxxxx";   |
cccccccccccc = 345;                                                     |

Wrong aligning of assignments

With "Align assignments" enabled, assignments could be wrongly indented when followed by a method call.

sqlCmd = "insert into my_table" +
         " (my_user, my_password) " +
         " values " +
         " (?,?)";
stmt   = con.prepareStatement(sqlCmd);
stmt.setString(1, user_id);

was wrongly formatted as (depending on your settings)

sqlCmd         = "insert into my_table" +
                 " (my_user, my_password) " +
                 " values " +
                 " (?,?)";
stmt           = con.prepareStatement(sqlCmd);
stmt.setString(1, user_id);

Now it will be printed (depending on your settings)

sqlCmd = "insert into my_table" +
         " (my_user, my_password) " +
         " values " +
         " (?,?)";
stmt   = con.prepareStatement(sqlCmd);
stmt.setString(1, user_id);

Wrong aligning of assignment expressions

With "Align assignments" enabled, but all chunk detection options disabled, assignments could be wrongly indented after a variable declaration without an assignment expression.

private int dasdasdasdasdsadasdasd = 1;

private int y;
private int abc;

{
    y = 3;
    abc = 4;
}

was wrongly formatted as (depending on your settings)

private int dasdasdasdasdsadasdasd = 1;

private int y;
private int abc;

{
    y                              = 3;
    abc                            = 4;
}

Now it will be printed (depending on your settings)

private int dasdasdasdasdsadasdasd = 1;

private int y;
private int abc;

{
    y   = 3;
    abc = 4;
}

Wrong aligning of inner class as call argument

Unexpected alignment of anonymous inner class used as call parameter when both Endline indentation and "Wrap always after call arguments if nested" were enabled.

return new B(new A() {
            public void foo() {
            }
        }, c);

was wrongly formatted as (depending on your settings)

return new B(new A() {
            public void foo() {
            }
        },
             c);

Now it will be printed (depending on your settings)

return new B(new A() {
            public void foo() {
            }
        },
        c);

Wrong line wrap for operator expressions

With "Insert expression parentheses" disabled, line breaks could be printed even though an expression would fit into the maximal line length.

if (rHandler.getLogWriter() == null || rHandler.getLogFilter() == null)|
{                                                                      |
}                                                                      |

was wrongly formatted as (depending on your settings)

if (rHandler.getLogWriter() == null || rHandler.getLogFilter()         |
        == null)                                                       |
{                                                                      |
}                                                                      |

Now it will be printed (depending on your settings)

if (rHandler.getLogWriter() == null || rHandler.getLogFilter() == null)|
{                                                                      |
}                                                                      |

Missing line break after left parenthesis for nested normal annotations

Nested annotations were missing a line break after the left paren.

@Author(@Name(first = "Joe", last = "Hacker"))

was wrongly formatted as (depending on your settings)

@Author(@Name(
        first = "Joe",
        last = "Hacker"
    )
)

Now it will be printed (depending on your settings)

@Author(
    @Name(
        first = "Joe",
        last = "Hacker"
    )
)

Please note that a style like in the first example is possible by disabling the " Wrap alwaysy after annotation members" option

Wrong line break after return when creator call

With C brace style, a wrong line break was printed after return keywords when a creator call followed that did not fit into the line.

return new Object[]
    {
        file, new Integer(message.getLine() - 1),
        new Integer(message.getStartOffset() - 1)
    };

was wrongly formatted as (depending on your settings)

return
    new Object[]
    {
        file, new Integer(message.getLine() - 1),
        new Integer(message.getStartOffset() - 1)
    };

Now it will be printed (depending on your settings)

return new Object[]
    {
        file, new Integer(message.getLine() - 1),
        new Integer(message.getStartOffset() - 1)
    };

Missing line break after left curly for array initializers

Missing line break after left curly brace of array initializers when a comment after an element caused the the elements to printed on more than one line.

String[] array = {
    "", ""
    // test
};

was wrongly formatted as (depending on your settings)

String[] array = { "", ""
    // test
};

Now it will be printed (depending on your settings)

String[] array = {
    "", ""
    // test
};

Missing line break after operators when the rhs was an unary minus expression

With "Wrap lines " and "Wrap after operators" enabled, no line wrap was printed after operators when an unary minus expression followed.

                       |
boolean test = index != -1;
                       |

was wrongly formatted as (depending on your settings)

                       |
boolean test = index != -1;
                       |

Now it will be printed (depending on your settings)

                       |
boolean test = index !=|
    -1;                |

Adjusted type parameter wrapping for endline indent

The behavior of the "Wrap on-demand type parameters" option changed slightly when using endline indent: Wrapping after the comma now only happens when both parameter names consist of several letters and/or contain bounds.

                              |
public final class Test<A, B extends Comparable<B & Cloneable { 
}                             |

was formatted as (depending on your settings)

                              |
public final class Test<A,    |
                        B extends Comparable<B & Cloneable { 
}                             |

Now it will be printed (depending on your settings)

                              |
public final class Test<A, B extends Comparable<B & Cloneable { 
}                             |

HTML lists wrongly wrapped

With "Indent HTML tags" enabled, the first line of HTML lists entries could be wrongly wrapped (line wrapping occured though a chunk would have fit into the first line).

/********************************************************************    |
 * <ul                                                                  |
 *   <lixxxxx: xxx xxxx (xxxxxxx xxxxxxx) xx xxx xxxxx xxxxx xxxxxxx    |
 *     x xxxxxxxx</li                                                   |
 * </ul                                                                 |
 */                                                                      |

was wrongly formatted as (depending on your settings)

/********************************************************************    |
 * <ul                                                                  |
 *   <lixxxxx: xxx xxxx (xxxxxxx xxxxxxx) xx xxx xxxxx xxxxx xxxxxxx    |
 *     x xxxxxxxx</li                                                   |
 * </ul                                                                 |
 */                                                                      |

Now it will be printed (depending on your settings)

/********************************************************************    |
 * <ul                                                                  |
 *   <lixxxxx: xxx xxxx (xxxxxxx xxxxxxx) xx xxx xxxxx xxxxx xxxxxxx x  |
 *     xxxxxxxx</li                                                     |
 * </ul                                                                 |
 */                                                                      |

@param tag name wrongly printed for generic types

The parameter names of Javadoc @param tags for generic types were not correctly printed

/**
 * @param <E Type of element stored in a list
 */
public interface List<E extends Collection<E {
}

was wrongly formatted as (depending on your settings)

/**
 * @param  <E  Type of element stored in a list
 */
public interface List<E extends Collection<E {
}

Now it will be printed (depending on your settings)

/**
 * @param  <E  Type of element stored in a list
 */
public interface List<E extends Collection<E {
}

HTML comments printed inline

HTML comments were printed inline.

/**
 *
 * <!-- begin-user-doc --> You can insert your documentation for
 '<em><b>TestReaderBean</b></em>'. <!-- end-user-doc --> *
 <!--  begin-lomboz-definition -->
 <?xml version="1.0" encoding="UTF-8"?>
 <!--  end-lomboz-definition -->
 */

was wrongly formatted as (depending on your settings)

/**
 * <!-- begin-user-doc --> You can insert your documentation for ' <em><b>
 * TestReaderBean</b></em>'. <!-- end-user-doc --> * <!--
 * begin-lomboz-definition --> <?xml version="1.0" encoding="UTF-8"?> <!--
 * end-lomboz-definition -->
 */

Now it will be printed (depending on your settings)

/**
 * <!-- begin-user-doc -->
 * You can insert your documentation for '<em><b>TestReaderBean</b></em>'.
 * <!-- end-user-doc -->
 * <!--  begin-lomboz-definition -->
 * <?xml version="1.0" encoding="UTF-8"?>
 * <!--  end-lomboz-definition -->
 */

What is Jalopy?

Jalopy is a world-class source code formatter for Java. It automates and enforces all aspects of source code layout—to meet a certain coding style without putting any burden on individual developers.

Learn more

Who needs it?

Jalopy is for everyone involved with source code editing. It scales from single developer usage to large scale enterprise deployment and seamlessly integrates with your favorite Java IDE or build tool.

Go and see yourself

I want some!

Concentrate on your problem domain and don’t waste time shuffling characters around. Pricing starts at USD $40 for a single-user license. Buy now using secure online purchase or wire transfer.

What are you waiting for?

Learn the details

Deploy, configure and use the software to best meet your needs. Download the printable user’s guide and learn everything there is to know to put Jalopy’s capabilities to full use.

Download (.pdf - 8.3MB)