[Skip to content]

Changes

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

Wrong alignment of method declaration parameter

With "Align Method declaration params" enabled, parameters were not always correctly aligned.

public abstract void setXY(String X, |
                           int    Y);|

was wrongly formatted as

public abstract void setXY(String X, |
                           int Y);   |

Now it will be printed (depending on your settings)

public abstract void setXY(String X, |
                           int    Y);|

Wrong alignment for assigment expressions

With "Align variable assignments" enabled, mixed variable declarations and assignment expressions lead to wrong alignment of variable expressions.

int labelR_x = Math_min(iconR.x, textR.x);                              |
labelR_with = Math_max(iconR.x + iconR.width, textRrr.x) - labelR_x;    |
labelR_y = Math_min(iconR.y, textR.y);                                  |
int labelR_width = Math_max(iconR.x + iconR.width, textRrr.x) - labelR_x;
int labelR_y = Math_min(iconR.y, textR.y);                              |
labelR_heightxx = Math_max(iconR.y + iconR.height, textR.y + textR.height);
labelR_with = Math_max(iconR.x + iconR.width, textRrr.x) - labelR_x;    |
int labelR_x = Math_min(iconR.x, textR.x);                              |
labelR_heightxx = Math_max(iconR.y + iconR.height, textR.y + textR.height);
int lab = Math_min(iconR.x, textR.x);                                   |
int_labelR_x = Math_min(iconR.x, textR.x);                              |
labelR_heightxx = Math_max(iconR.y + iconR.height, textR.y + textR.height);

was wrongly formatted as

int labelR_x = Math_min(iconR.x, textR.x);                              |
labelR_with     = Math_max(iconR.x + iconR.width, textRrr.x) - labelR_x;|
labelR_y        = Math_min(iconR.y, textR.y);                           |
                                                                        |
int labelR_width = Math_max(iconR.x + iconR.width, textRrr.x) -         |
    labelR_x;                                                           |
int labelR_y     = Math_min(iconR.y, textR.y);                          |
labelR_heightxx = Math_max(iconR.y + iconR.height,                      |
        textR.y + textR.height);                                        |
labelR_with     = Math_max(iconR.x + iconR.width, textRrr.x) - labelR_x;|
                                                                        |
int labelR_x = Math_min(iconR.x, textR.x);                              |
labelR_heightxx = Math_max(iconR.y + iconR.height,                      |
        textR.y + textR.height);                                        |
                                                                        |
int lab = Math_min(iconR.x, textR.x);                                   |
labelR_heightxx = Math_max(iconR.y + iconR.height,                      |
        textR.y + textR.height);                                        |

Now it does (depending on your settings)

int labelR_x = Math_min(iconR.x, textR.x);                              |
labelR_with = Math_max(iconR.x + iconR.width, textRrr.x) - labelR_x;    |
labelR_y    = Math_min(iconR.y, textR.y);                               |
                                                                        |
int labelR_width = Math_max(iconR.x + iconR.width, textRrr.x) -         |
    labelR_x;                                                           |
int labelR_y     = Math_min(iconR.y, textR.y);                          |
labelR_heightxx = Math_max(iconR.y + iconR.height,                      |
        textR.y + textR.height);                                        |
labelR_with     = Math_max(iconR.x + iconR.width, textRrr.x) - labelR_x;|
                                                                        |
int labelR_x = Math_min(iconR.x, textR.x);                              |
labelR_heightxx = Math_max(iconR.y + iconR.height,                      |
        textR.y + textR.height);                                        |
                                                                        |
int lab = Math_min(iconR.x, textR.x);                                   |
labelR_heightxx = Math_max(iconR.y + iconR.height,                      |
        textR.y + textR.height);                                        |

Array type declaration wrongly aligned

When the "Align Variable assignments" option was enabled, array type variable declarations were wrongly aligned when the array brackets were specified after the identifier.

byte theMD5DigestByteArray[] = null;
char theCharacter            = 'x';

was wrongly formatted as

byte[] theMD5DigestByteArray = null;
char theCharacter          = 'x';

Now it does (depending on your settings)

byte[] theMD5DigestByteArray = null;
char theCharacter            = 'x';

Spurious line break in Javadoc comments

A spurious line break could occur after Javadoc standalone tags, when the description started with an unbreakable chunk that did not fit into the maximal line length.

/**                                              |
 * TODO: Description                             |
 *                                               |
 * @see de.esoco.test.ComponentFactory#create(Class, Container)
 */                                              |

was wrongly printed as

/**                                              |
 * TODO: Description                             |
 *                                               |
 * @see                                          |
 *      de.esoco.test.ComponentFactory#create(Class,
 *      Container)                               |
 */                                              |

Now it does (depending on your settings)

/**                                              |
 * TODO: Description                             |
 *                                               |
 * @see de.esoco.test.ComponentFactory#create(Class,
 *      Container)                               |
 */                                              |

Header blank lines wrongly printed

A positive "Blank lines after headers" option was not correctly enforced when "Keep blank lines" was enabled and existing blank lines after the header present: the existing blank lines were added to the desired number of blank lines up to the number of blank lines to keep.

// Copyright 1998-2000, Foo, Inc. All Rights Reserved.
// Confidential and Proprietary Information of Foo, Inc.
// Protected by or for use under one or more of the following patents:
// U.S. Patent Nos. X,XXX,XXX. Other Patents Pending.
¶
¶
package com.foobar;

was wrongly formatted as

// Copyright 1998-2000, Foo, Inc. All Rights Reserved.
// Confidential and Proprietary Information of Foo, Inc.
// Protected by or for use under one or more of the following patents:
// U.S. Patent Nos. X,XXX,XXX. Other Patents Pending.
¶
¶
¶
package com.foobar;

when two blank lines should be forced after headers and up to one blank line be kept. Now it does

// Copyright 1998-2000, Foo, Inc. All Rights Reserved.
// Confidential and Proprietary Information of Foo, Inc.
// Protected by or for use under one or more of the following patents:
// U.S. Patent Nos. X,XXX,XXX. Other Patents Pending.
¶
¶
package com.foobar;

Wrong alignment for variable identifiers

With "Align variable identifiers" and "Determine chunks by blank lines" enabled, but "Determine chunks by comments" disabled, variable identifiers were wrongly aligned when originally no blank lines appeared between successive declarations, but blank lines were only inserted because of comments between the declarations.

int    d;
// comment
float  a;
Object x;

was wrongly printed as

int    d;

// comment
float  a;
Object x;

Now it does

int d;

// comment
float  a;
Object x;

No header blank lines printed

No blank lines were printed around headers, when the "Override header" option was disabled.

// Copyright 1998-2000, Foo, Inc. All Rights Reserved.
// Confidential and Proprietary Information of Foo, Inc.
// Protected by or for use under one or more of the following patents:
// U.S. Patent Nos. X,XXX,XXX. Other Patents Pending.
package com.foobar;

was wrongly formatted as

// Copyright 1998-2000, Foo, Inc. All Rights Reserved.
// Confidential and Proprietary Information of Foo, Inc.
// Protected by or for use under one or more of the following patents:
// U.S. Patent Nos. X,XXX,XXX. Other Patents Pending.
package com.foobar;

when two blank lines should be forced before and after the header. Now it does

¶
¶
// Copyright 1998-2000, Foo, Inc. All Rights Reserved.
// Confidential and Proprietary Information of Foo, Inc.
// Protected by or for use under one or more of the following patents:
// U.S. Patent Nos. X,XXX,XXX. Other Patents Pending.
¶
¶
package com.foobar;

Wrong tab insertion

With the "Use tabs in comments" option enabled, hard tabs could be wrongly inserted for blank spaces.

»   »// class will always be referenced through it

was wrongly formatted as

»   »// class will always be»referenced through it

Now it will be printed

»   »// class will always be referenced through it

Nested expressions could lead to wrong wrapping

Nested expressions could lead to wrong wrapping and exceed the maximal line length when Sun brace style was used.

if (!(dataLineInfo.isFormatSupported(localFormats[i])))|{
    ...                                                | 
}                                                      |

was wrongly printed as

if (!(dataLineInfo.isFormatSupported(localFormats[i])))|{
    ...                                                | 
}                                                      |

Now it does (depending on your settings)

if (!(dataLineInfo.isFormatSupported(                  |
                localFormats[i])))|{                   |
    ...                                                | 
}                                                      |

Wrong wrapping for array initializers

Array initializers could exceed the maximal line length in a boundary case.

                                                                    |
public final Class[] STANDARD_INPUT_TYPE = {                        |
        ImageInputStream.class                                      |
    };                                                              |

was wrongly printed as

                                                                    |
public final Class[] STANDARD_INPUT_TYPE = { ImageInputStream.class };
                                                                    |

Now it does (depending on your settings

                                                                    |
public final Class[] STANDARD_INPUT_TYPE = {                        |
        ImageInputStream.class                                      |
    };                                                              |

Wrong wrapping for implements clauses

implements clauses were not correctly wrapped when a fully qualified type was used and could exceed the maximal line length.

private class SecureSet extends AbstractSet                         |
    implements java.io.Serializable {                               |
}                                                                   |

was wrongly printed as

private class SecureSet extends AbstractSet implements java.io.Serializable {
}                                                                   |

Now it does (depending on your settings

private class SecureSet extends AbstractSet                         |
    implements java.io.Serializable {                               |
}                                                                   |

Wrong wrapping assignments with array access expressions

Assigments containing an array access expression could lead to a crossing of the maximal line length.

                                                       |
Component oldMC = currentSelection[currentSelection.length-1].getComponent();
                                                       |

was wrongly printed as

                                                       |
Component oldMC = currentSelection[currentSelection.length -
                            1].getComponent();         |

Now it does (depending on your settings)

                                                       |
Component oldMC =                                      |
    currentSelection[currentSelection.length -1]       |
    .getComponent();                                   |

Wrong wrapping for infix operators enclosed with parentheses

Infix operators that were enclosed with parentheses could lead to a crossing of the maximal line length with Sun brace styling.

if (listeners != null &&                                   |
    listeners.getListenerCount(MyListener.class) > 0) {    |
    ...                                                    |
}                                                          |

was wrongly printed as

if (listeners != null &&                                   |
        (listeners.getListenerCount(MyListener.class) > 0)) {
    ...                                                    |
}                                                          |

Now it does (depending on your settings)

if ((listeners != null) &&                                 |
        (listeners.getListenerCount(MyListener.class) >    |
            0)) {                                          |
    ...                                                    |
}                                                          |

Wrong inner class indentation

With endline indentation enabled, the bodies of inner class declarations were wrongly indented when the inner class was the rhs expression of an assignment

private Listener frameListener = new VetoableChangeListener() {

        /** Tests whether it is safe to close the viewer. */
        public void vetoableChange( PropertyChangeEvent event ) {

            ...
        }
};

was wrongly formatted as

private Listener frameListener = new VetoableChangeListener() {

                                     /** Tests whether it is safe to close the viewer. */
                                     public void vetoableChange( PropertyChangeEvent event ) {

            ...
        }
};

Now it does (depending on your settings)

private Listener frameListener = new VetoableChangeListener() {

        /** Tests whether it is safe to close the viewer. */
        public void vetoableChange( PropertyChangeEvent event ) {

            ...
        }
};

Wrong indentation of array initializers

With "Endline indent" enabled, the left curly brace of array initializers was wrongly indented after assignments when blank lines were present between the assignment and left curly brace.

private static final String[][] TEST =

{
    { "ABC", "Test 1" },
    { "DEF", "Test 2" },
};

was wrongly printed as

private static final String[][] TEST = 
                                       {
    { "ABC", "Test 1" },
    { "DEF", "Test 2" },
};

Now it does (depending on your settings)

private static final String[][] TEST = {
    { "ABC", "Test 1" },
    { "DEF", "Test 2" },
};

Wrong indentation for anonymous inner classes

Return expressions involving anonymous inner classes were wrongly indented with Endline indentation enabled.

return new TestSetup(new TestSuite(testClass)) {
    /**
     * One-time teardown. Take care that the test preferences are
     * deleted afterwards.
     */
    protected void tearDown() throws Exception {
        super.tearDown();
    }
};

was wrongly formatted as

return new TestSetup(new TestSuite(testClass)) {
       /**
     * One-time teardown. Take care that the test preferences are
     * deleted afterwards.
     */
       protected void tearDown() throws Exception {
        super.tearDown();
    }
};

Now it does

return new TestSetup(new TestSuite(testClass)) {
    /*
     * One-time teardown. Take care that the test preferences are
     * deleted afterwards.
     */
    protected void tearDown() throws Exception {
        super.tearDown();
    }
};

XDoclet attributes wrongly printed

/**
 * 
 * @hibernate.bag inverse="true" lazy="true"
 * @hibernate.many-to-one class="api.hibernate.core.IItemsFolderImpl"
 *                        cascade="save-update" column="item_id"
 */

was wrongly printed as

/**
 * 
 * @hibernate.bag inverse = "true" lazy="true"
 * @hibernate.many-to-one class = "api.hibernate.core.IItemsFolderImpl"
 *                        cascade="save-update" column="item_id"
 */

Now it does (depending on your settings)

/**
 * @hibernate.bag
 *            inverse = "true"
 *            lazy    = "true"
 * @hibernate.many-to-one
 *            class   = "api.hibernate.core.IItemsFolderImpl"
 *            cascade = "save-update"
 *            column  = "item_id"
 */

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)