Alex Rivera | Logout

Ignoring Compilation errors - Java

Asked 2011-09-28T22:13:52.977
12

I have around 1500 files to compile, in which 15-20 files have compilation errors. These files are not under my control, so I could not do any modification/update/delete. So, i have two questions here.

1) how do i ignore the compilation errors from these 15-20 files and continue to produce the .class file for rest of them. is there any javac commandline option or anything which will ignore the compliation errors and produce the .class files for all other non error files.

2)will the java compiler abort compilation as soon as it sees these errors or will it continue compiling(producing .class files) everything else and at the end then complain about these files with errors.

Edit
Report

2 Answers

4

You cannot ignore compile errors. They will always fail the build.

Your only choices are to talk to whoever controls the files to get them fixed or find a way to otherwise replace them.

If you try to remove them from the build, you will also have to remove any files that use those files. For example

class A {
    B b;
}

If B has a compile error, your build script can skip B.java, but when you hit A.java, it's going to try to compile B anyway, so A has to be removed. This may prove to be a non-trivial task.

answered 2011-09-28T22:16:54.510
-2
  1. Tell the one who broke the code (diplomatically, of course) to fix it ASAP. Others have suggested (see 2nd comment there) to make these occurrences public (within a team/company), which greatly reduces the number of such compilation errors
  2. Comment everything that prevents the code from compiling (supposed that you don't need those parts)

You should not have to deal with not-compiling code, but the one who committed it. If there are more people working on that project, everyone has to deal with that same problem on his local machine (find out why it didn't compile, track down the erroneous classes, exclude/comment those classes if your code does not depend on them, rebuild, etc.) It is much more efficient to have only 1 person to fix the problem, and everyone else just updates his local repository.

answered 2011-09-28T22:30:12.547

Your Answer