Reputation: 7422
What kind of java.lang.Error can be thrown during compile time ?
I know one error: ClassFormatError
. What are the others error?
I'm writing an application that acts as a server. The server can compile a java program. During compilation I don't want to bring it down with any error, ensuring compilation. I have taken the necessarry steps that can prevent a compilation error.
I'm not sure with java.lang.Error, I can catch Throwable object and prevent it, but I need to know what are the error objects that can be thrown during compile time.
Upvotes: 1
Views: 167
Reputation: 533780
Errors thrown at compilation time (in the javac
) occur when the compiler has an internal error. You can provide valid java code and the compiler can die. A common error I see is OutOfMemoryError when I compile a large code base but my IDE hasn't given the compiler enough memory (the default in my IDE is 128 MB)
ClassFormatError can occur when the compile tries to load a compiled class file which is corrupt.
You don't need to know all the error thrown, you can just catch Throwable. They should only be the result of very unusual event which are likely to be unrecoverable. All you can do is log the error and prevent the thread from dying.
Upvotes: 4