Search code examples
javalinuxantdos2unix

Dos2unix on Java files


Are there any impacts or repercussions if the dos2unix command is run on Java source files, right before they are compiled? The Java files would be downloaded from a CVS repository in Linux and then compiled to a jar by an Ant script. Thanks.


Solution

  • No need to even test this (theoretically): in the Java languages, line breaks bare no semantical meaning. Therefore there presence is irrelevant (to the compiler that is).

    So a human reader mind find it very unpleasant to look at source code that has zero newlines, or a newline in just any place where they are legit - for the compiler, as said: it doesn't matter.

    Therefore tools like dos2unix are not supposed to make any changes to source code that could make a "semantical" difference.

    And of course: the real answer is: don't spend your time worrying about line breaks. Invest it into moving your the whole system from 1999 to 2018 (by getting replacing say CVS with git, and Ant with maven/gradle for example).