Accepted answer

this is how the java compiler knows about the compilation error in the class.

public static void main(string[] paramarrayofstring)
    throw new error("unresolved compilation problem: \n\ttype mismatch: cannot convert from long to int.\n");

if you decompile your class file, you can see the above main() method of the class file, which the compiler has generated. this is because of the compiler which eclipse uses (eclipse compiler for java) is not the same as the standard java compiler!


yes, eclipse uses its own special compiler; known as "ecj". from stack overflow question what is the difference between javac and the eclipse compiler?:

one notable difference is that the eclipse compiler lets you run code that didn't actually properly compile. if the block of code with the error is never ran, your program will run fine. otherwise it will throw an exception indicating that you tried to run code that doesn't compile.


eclipse uses the ibm compiler which has an option of creating classes which do not compile, replacing errors with

throw new error();

imho, this is very bad practice and i have seen some very poor quality projects use this. the project didn't compile completely for weeks at a time.

unlike fail fast strategies, which try to minimise the cost of bugs, discovering bugs as late as possible also maximises the cost of fixing them.

this strategy only works if you are writing prototype code quickly, i.e. code you know will never get into production. (it is hard to be sure this will be the case)

Related Query

More Query from same tag