Bug 516289 - fatalOptionalError causes SuppressWarnings on statements to be ignored
Summary: fatalOptionalError causes SuppressWarnings on statements to be ignored
Status: NEW
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 4.6   Edit
Hardware: PC All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords:
Depends on:
Blocks:
 
Reported: 2017-05-07 18:53 EDT by Doug Simon CLA
Modified: 2023-08-11 05:57 EDT (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Doug Simon CLA 2017-05-07 18:53:18 EDT
It seems that the org.eclipse.jdt.core.compiler.problem.fatalOptionalError=enabled causes the compiler to ignore statement scope @SuppressWarnings annotations.

> cat bad.prefs
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.fatalOptionalError=enabled
org.eclipse.jdt.core.compiler.problem.rawTypeReference=error
org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=enabled
org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
org.eclipse.jdt.core.compiler.source=1.8
> cat Test.java
public class Test {
    public static void main(String[] args) {
        @SuppressWarnings("rawtypes")
        Class<? extends Enum> enumClass = null;
        System.out.println(enumClass);
    }
}
> java -jar ecj-4.6.3.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)
> sed 's:fatalOptionalError=enabled:fatalOptionalError=disabled:g' <bad.prefs >good.prefs
> java -jar ecj-4.6.3.jar -properties good.prefs Test.java && java Test
null
Comment 1 Jay Arthanareeswaran CLA 2017-05-09 02:03:08 EDT
I can't reproduce with latest 4.7 build - I20170508-2000. Note, I had only the preferences you had specified. So not sure if there are any other factors involved.

Doug, can you try the build I mentioned?
Comment 2 Doug Simon CLA 2017-05-09 04:53:48 EDT
I can still reproduce with ecj-4.7M6.jar and ecj-I20170508-2000.jar:

> java -version
java version "1.8.0_121"
Java(TM) SE Runtime Environment (build 1.8.0_121-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode)
> java -jar ~/Downloads/ecj-4.7M6.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)
> java -jar ~/Downloads/ecj-I20170508-2000.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)
Comment 3 Eclipse Genie CLA 2019-09-24 16:31:50 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.
Comment 4 Stephan Herrmann CLA 2019-09-24 16:44:06 EDT
I can reproduce.

Not good, suppressOptionalErrors allows to make the error invisible, but fatalOptionalError lets it crash at runtime.

To be consistent, ecj should decide to either
1. disallow suppressing fatal errors, or
2. let @SW suppress optional problems even when configured as fatal

Option 2. is being requested and I second that motion. It implies that only non-suppressed optional problems are fatal, of course.
Comment 5 Jay Arthanareeswaran CLA 2019-09-25 02:08:32 EDT
(In reply to Stephan Herrmann from comment #4)
> 2. let @SW suppress optional problems even when configured as fatal
> 
> Option 2. is being requested and I second that motion. It implies that only
> non-suppressed optional problems are fatal, of course.

+1
Comment 6 Stephan Herrmann CLA 2019-11-17 16:09:13 EST
Bulk move of unassigned bugs to 4.15
Comment 7 Stephan Herrmann CLA 2020-02-27 18:49:19 EST
Bulk move to 4.16
Comment 8 Stephan Herrmann CLA 2020-05-18 18:46:32 EDT
Bulk move of unassigned bugs to 4.17
Comment 9 Eclipse Genie CLA 2022-06-24 17:51:44 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.
Comment 10 Patrick Ziegler CLA 2023-08-11 03:48:21 EDT
Can still reproduce. On these versions:

* ecj-4.28.jar: https://download.eclipse.org/eclipse/downloads/drops4/R-4.28-202306050440/
* ecj-4.29M1.jar: https://download.eclipse.org/eclipse/downloads/drops4/S-4.29M1-202307051800/
* ecj-I20230810-1800.jar: https://download.eclipse.org/eclipse/downloads/drops4/I20230810-1800/

Updated for JDK20:

> cat bad.prefs
org.eclipse.jdt.core.compiler.codegen.targetPlatform=20
org.eclipse.jdt.core.compiler.compliance=20
org.eclipse.jdt.core.compiler.problem.fatalOptionalError=enabled
org.eclipse.jdt.core.compiler.problem.rawTypeReference=error
org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=enabled
org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
org.eclipse.jdt.core.compiler.source=20

> cat Test.java                                                                                                                                                
public class Test {
    public static void main(String[] args) {
        @SuppressWarnings("rawtypes")
        Class<? extends Enum> enumClass = null;
        System.out.println(enumClass);
    }
}

> java -jar ecj-4.28.jar -properties bad.prefs Test.java
_No output_

> 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)

> 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)
Comment 11 Andrey Loskutov CLA 2023-08-11 03:53:20 EDT
(In reply to Patrick Ziegler from comment #10)
> Can still reproduce. 

Project bug tracker moved to https://github.com/eclipse-jdt/eclipse.jdt.core/issues

If you are interested in a fix, please create an issue ticket with latest steps to reproduce / information from this ticket.
Comment 12 Patrick Ziegler CLA 2023-08-11 05:57:24 EDT
Opened an issue on GitHub: https://github.com/eclipse-jdt/eclipse.jdt.core/issues/1282