Bug 515328 - Invalid Unnecessary @SuppressWarnings("unchecked") report inside function
Summary: Invalid Unnecessary @SuppressWarnings("unchecked") report inside function
Status: NEW
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 4.6   Edit
Hardware: PC Linux
: P3 normal with 1 vote (vote)
Target Milestone: ---   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords:
Depends on:
Blocks:
 
Reported: 2017-04-16 16:49 EDT by Ivo Steinmann CLA
Modified: 2023-01-01 15:11 EST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ivo Steinmann CLA 2017-04-16 16:49:48 EDT
The following code reports Unnecessary @SuppressWarnings("unchecked"), what is wrong. Because when @SuppressWarnings is removed, there is this warning: Type safety: Unchecked cast from List<capture#5-of ?> to List<Object>

	public void test1() {
		List<List<List<?>>> list = new ArrayList<>();
		list.forEach(x -> {
			x.forEach(y -> {
				@SuppressWarnings("unchecked")
				List<Object> l = (List<Object>) y;
				System.out.println(l);
			});
		});
	}


So one get a warning in any case.
Comment 1 Stephan Herrmann CLA 2017-04-16 17:31:35 EDT
Thanks, I can reproduce.

Additional observations: placing the @SW annotation on the method test1() works as expected -> no warning. Apparently, it's the location of a local variable inside a lambda body that isn't analysed correctly. At a closer look the same problem exists for other problems and @SW tokens, too.
Comment 2 Eclipse Genie CLA 2020-10-16 19:33:52 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 3 Eclipse Genie CLA 2023-01-01 15:11:19 EST
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.