consider the following class:
public class PPCompileErrorAfterReorderingConstants
{
private static final String MAGIC_RAR = "Rar!";
private static final int MAGIC_RAR_LENGTH = 4;
private static final int MAGIC_ZIP_LENGTH = 2;
private static final int MAGIC_MAX_LENGTH = Math.max(MAGIC_RAR_LENGTH, MAGIC_ZIP_LENGTH);
}
using the attached pretty.settings and JavaStyle 2.9.19 ant task, this turns into:
public class PPCompileErrorAfterReorderingConstants
{
private static final int MAGIC_MAX_LENGTH = Math.max(MAGIC_RAR_LENGTH, MAGIC_ZIP_LENGTH);
private static final String MAGIC_RAR = "Rar!";
private static final int MAGIC_RAR_LENGTH = 4;
private static final int MAGIC_ZIP_LENGTH = 2;
}
this breaks the code and causes a compile error: "cannot reference a field before it is defined".
note that pretty.settings contains "sort.6=Alphabetical()", which might be part of the problem.
interestingly, if you remove the (unused) MAGIC_RAR, the pretty printer seems to recognize the dependancy, and does not sort MAGIC_MAX_LENGTH.
the above example is a stripped down version of the code you can find at http://cvs.sourceforge.net/viewcvs.py/jomic/jomic/source/net/sf/jomic/tools/FileArchive.java?rev=1.12&view=markup
an obvious workaround is to rename MAGIC_MAX_LENGTH to for example MAGIC_ZZZ_MAX_LENGTH so that it is sorted at the end anyway.
pretty.settings to reproduce bug