You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This corresponds to the Bug 516289 on the old Bugzilla, which still occurs on newer versions
It seems that the org.eclipse.jdt.core.compiler.problem.fatalOptionalError=enabled causes the compiler to ignore statement scope @SuppressWarnings annotations.
This still happens today, tested on the following versions:
$ java -jar ecj-4.28.jar -properties bad.prefs Test.java && java Test
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
Enum is a raw type. References to generic type Enum<E> should be parameterized
at Test.main(Test.java:4)
Expected Behavior
The program compiles without warnings or errors and runs to completion while printing null.
Workarounds
This does not happen if the annotation appears on the method instead of the statement, so moving such annotation up to the method scope would work.
Disabling fatalOptionalError
Additional Context
$ java -version
openjdk version "20.0.2" 2023-07-18
OpenJDK Runtime Environment (build 20.0.2+9-Ubuntu-0ubuntu123.04)
OpenJDK 64-Bit Server VM (build 20.0.2+9-Ubuntu-0ubuntu123.04, mixed mode, sharing)
I have been playing around and digging into the code and I don't see what fatalOptionalError is actually supposed to be doing. From my understanding, problems set to "error" in the properties file are treated as optional errors (and in addition as fatal if fatalOptionalError is set) (CompilerOptions#getSeverity).
Excerpt from the documentation of fatalOptionalError in JavaCore.java:
When disabled, optional errors are only considered as warnings, still carrying an error indication to make them more severe. Note that by default, optional errors are not fatal. Non-optional errors are always fatal.
I understand this as meaning that fatalOptionalError=disabled (the default) causes the compilation to succeed even if these optional errors occur and to print a non-fatal error.
In practice, I have not found situation where this happens, if such an error occurs, the compilation fails as well (take for instance the code above without the SuppressWarnings annotation).
The text was updated successfully, but these errors were encountered:
This corresponds to the Bug 516289 on the old Bugzilla, which still occurs on newer versions
This still happens today, tested on the following versions:
bad.prefs
:Test.java
:Expected Behavior
The program compiles without warnings or errors and runs to completion while printing
null
.Workarounds
fatalOptionalError
Additional Context
I have been playing around and digging into the code and I don't see what
fatalOptionalError
is actually supposed to be doing. From my understanding, problems set to "error" in the properties file are treated as optional errors (and in addition as fatal iffatalOptionalError
is set) (CompilerOptions#getSeverity
).Excerpt from the documentation of
fatalOptionalError
inJavaCore.java
:I understand this as meaning that
fatalOptionalError=disabled
(the default) causes the compilation to succeed even if these optional errors occur and to print a non-fatal error.In practice, I have not found situation where this happens, if such an error occurs, the compilation fails as well (take for instance the code above without the
SuppressWarnings
annotation).The text was updated successfully, but these errors were encountered: