Bug 78810 - [1.5] [Generics] Erroneous problem detection with cast.
Summary: [1.5] [Generics] Erroneous problem detection with cast.
Status: RESOLVED DUPLICATE of bug 78591
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows 2000
: P3 normal with 1 vote (vote)
Target Milestone: 3.1 M5   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-11-16 23:46 EST by R Lenard CLA
Modified: 2005-01-06 06:38 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description R Lenard CLA 2004-11-16 23:46:55 EST
For this code.
% cat Test.java
public abstract class Test
{
    public abstract Object getProperty(final Object src, final String name);
    
    public <T> T getTheProperty(final Object src, final String name)
    {
        final T val = (T) getProperty(src, name); // this gives erroneous cast 
warning
        return val;
    }
}
<<<
The marked line gives.
Severity	Description	Resource	In Folder	Location
	Creation Time
1	Unnecessary cast from Object to T	Test.java		line 78
	November 17, 2004 3:26:30 PM


Now clearly the cast is required here - because the type is unknown.
Comment 1 Philipe Mulet CLA 2005-01-05 09:27:10 EST
Same issue as bug 78591, different symptoms.
Added GenericTypeTest#test444

*** This bug has been marked as a duplicate of 78591 ***
Comment 2 Philipe Mulet CLA 2005-01-05 09:32:50 EST
Note: If unchecked/unsafe type operation warnings are enabled, you will now get
a warning when casting to a type parameter:

Type safety: The cast from Object to T is actually checking against the erased
type Object
Comment 3 Philipe Mulet CLA 2005-01-06 06:38:21 EST
Test is actually: test445.