Bug 541035 - @SuppressWarnings("unchecked") not working
Summary: @SuppressWarnings("unchecked") not working
Status: NEW
Alias: None
Product: AJDT
Classification: Tools
Component: Core (show other bugs)
Version: 2.2.4   Edit
Hardware: PC Windows 10
: P3 normal with 4 votes (vote)
Target Milestone: ---   Edit
Assignee: AJDT-inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: needinfo
Depends on:
Blocks:
 
Reported: 2018-11-12 06:47 EST by Alireza Fattahi CLA
Modified: 2023-12-18 06:55 EST (History)
8 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Alireza Fattahi CLA 2018-11-12 06:47:26 EST
Updating from Ecipse oxygen 3...
The @SuppressWarnings("unchecked") is not working and i see the warnings. 
Trying to clean and build not worked,I even closed and reopent the project.
The compiler error/warnings is set to default and the project has not any customized settings for error/warnings.
The defult suggestion for quick fix is not working.
I always see the warning.

Regards,


-- Configuration Details --
Product: Eclipse IDE 4.9.0.20180917-1800 (org.eclipse.epp.package.jee.product)Installed Features:
 org.eclipse.jdt 3.15.0.v20180906-0745
Versioning Plugin:
 org.eclipse.platform 4.9.0.v20180906-1121
Comment 1 Jay Arthanareeswaran CLA 2018-11-12 23:49:26 EST
Can you please share an example, preferably in a small isolated testcase. We have tests that cover this feature. So  there's something specific about your code.
Comment 2 Alireza Fattahi CLA 2018-11-14 00:48:58 EST
I found that this happens when I install Aspectj Tool.
I used the last version ajdt-e48-2.2.4.201811011643.zip but same issue.
Comment 3 Stephan Herrmann CLA 2018-11-14 17:55:53 EST
Perhaps AspectJ JDT weaving disturbs JDT somehow?
Comment 4 John Ruud CLA 2018-11-30 15:27:17 EST
We're experiencing the same problem with 2018/09, and only when AJDT is installed:

Version: 4.9.0.20180917-1800
Build id: 20180917-1800

org.aspectj (1.9.2.201811011643) "AspectJ Development Tools"
org.eclipse.ajdt (2.2.4.201811011643) "AspectJ Development Tools"
Comment 5 Andreas Klein CLA 2019-02-17 19:27:49 EST
I can only second or third the behaviour reported by the OP. In any version of Eclipse newer than Oxygen 3a I have tested, the presence of AJDT (2.2.4, full details below), causes @SuppressWarnings annotations to stop working as intended. Meaning the compiler will ignore the annotation and display warning about unchecked conversions, raw types in generics, unused code etc.

AJDT version:

AspectJ Development Tools 2.2.4.201805251550
AspectJ Compiler 1.8.13.201805251550
Equinox Weaving SDK 1.2.0.201805251550
Maven Integration for AJDT (Optional) 0.14.0.201506231302

Works with Eclipse Neon and Oxygen.3a Release (4.7.3a)
Build id: 20180405-1200
OS: Windows 10, v.10.0, x86_64 / win32

Does not work with current final relase versions of Photon or 2018-12
Comment 6 Andreas Klein CLA 2019-02-17 20:13:08 EST
In addition to my previous comment, Photon is also exhibiting the same issue with the to date latest version of AJDT from the https://download.eclipse.org/tools/ajdt/48/dev/update/ update site:

AspectJ Development Tools 2.2.4.201901092148
AspectJ Compiler 1.9.2.201901092148
Equinox Weaving SDK 1.2.0.201901092148
Comment 7 Andrew Clement CLA 2019-02-20 15:38:49 EST
Can you possibly share a project with me that exhibits this problem?  I have this simple class in a Java11 project in Eclipse 4.10 and uncommenting the suppresswarnings will suppress the unchecked problem, as expected.


package bean;
import java.util.Collections;
import java.util.List;

public class Demo {

    public static List getStringList() {
    	return null;
    }

//  @SuppressWarnings("unchecked")
    public static void main(String[]argv) {
	   List<String> list = (List<String>)getStringList();
	   Collections.reverse(list);
    }
}

I've tried with/without jdt weaving on (and can't think why it would interfere, but what else could it be??) and it still works. I tried with/without an AJ project in the workspace, made no difference.
Comment 8 B K CLA 2019-03-29 10:40:48 EDT
(In reply to Andrew Clement from comment #7)

Andrew, I tried your example and can confirm that the warning is suppressed when the main method is annotated.

However, I get the warning when I move the @SuppressWarnings annotation to the local variable while the class is in an AJ project:

public static void main(String[]argv) {
    @SuppressWarnings("unchecked")
    List<String> list = (List<String>)getStringList();
    Collections.reverse(list);
}

The warning is suppressed as expected as long as the project is not an AJ project. Converting the project to an AJ project without touching the code immediately adds the warning.


Eclipse 4.11.0.20190314-1200
org.eclipse.ajdt 2.2.4.2019022121
Comment 9 B K CLA 2019-09-13 05:52:29 EDT
Bug still observed:

Eclipse 4.12.0.v20190605-1801
AJDT 2.2.4.201905102027
Comment 10 Manu M CLA 2020-02-17 02:14:56 EST
Bug still observed:

AspectJ Development Tools	2.2.4.201911072000	
Eclipse Platform	4.13.0.v20190916-1323
Comment 11 Alireza Fattahi CLA 2022-10-26 01:32:33 EDT
Bug still observed:

AspectJ Development Tools	2.2.4.202203241553	
Eclipse Platform	 4.25.0.v20220831-1800
Comment 12 Manu M CLA 2023-12-18 06:55:04 EST
Bug still observed:

AspectJ Development Tools: 2.2.4.202311040357
Eclipse Platform: 4.30.0.v20231201-0512