Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 76749 - Unnecessary cast not detected
Summary: Unnecessary cast not detected
Status: RESOLVED WONTFIX
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.0.1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-10-21 10:39 EDT by zugasti CLA
Modified: 2004-10-21 12:20 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 zugasti CLA 2004-10-21 10:39:29 EDT
2 unnecessaries casts are not detected in the following method :

private List test() {
    List l = new ArrayList();
    l.add("aaa");
    Object o = ((ArrayList)l).get(0);
    return (ArrayList)l;	
}
Comment 1 Philipe Mulet CLA 2004-10-21 12:20:04 EDT
This cast is not unnecessary in the sense it is altering the generated classfile.
With cast, you invoke: ArrayList#get(...), without it you invoke: List#get(...).

Thus it is not equivalent, and the compiler tolerates it.