Bug 549632 - Eclipse reports compiler error although Java class compiles with javac
Summary: Eclipse reports compiler error although Java class compiles with javac
Status: NEW
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 4.12   Edit
Hardware: PC Windows 10
: P3 minor with 1 vote (vote)
Target Milestone: ---   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords:
Depends on:
Blocks:
 
Reported: 2019-07-29 08:34 EDT by Vasil Panushev CLA
Modified: 2023-07-10 09:30 EDT (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 Vasil Panushev CLA 2019-07-29 08:34:09 EDT
Hi

I have following class  declared:

package test;

import java.util.ArrayList;
import java.util.List;


public class Test {	
    public static <T extends Comparable<? super T>> List<T> getList(T clazz) {
        List<String> toReturn = new ArrayList<>();
        return (List<T>) toReturn;
    }
}

When added to an Eclipse project it fails to compile with following error on the "return" statement:

Cannot cast from List<String> to List<T>

There is no quick fix available for the error but the code does not run if launched from Eclipse.

The same code compiles fine with plain javac with some warnings though.

Best regards
Vasil
Comment 1 Eclipse Genie CLA 2021-07-19 00:43:15 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 2 Vikas Chandra CLA 2021-07-19 03:22:59 EDT
Can recreate on : I20210707-1800
Comment 3 Eclipse Genie CLA 2023-07-10 09:30:48 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.