javaeclipsedebuggingstatic-analysis

How to set compiler options so that it rejects this program that it cannot statically ensure the correctness?


I have the following Java program that Eclipse gives a red cross on its left, yet the program compiled well in Eclipse!

Apparently, Eclipse thinks that 'y' may not be initialized so it rejects the program a priori, but the compiler seems more tolerant.

My question is, how to set the compiler option of Eclipse so that it rejects this program?enter image description here


Solution

  • Check your Java Compiier "Errors/Warnings" preferences, specifically at the bottom where it says to treat errors as if they were fatal.

    enter image description here