Bug 81890 - [5.0] 3.1M4 spurious type-safety compiler warning
Summary: [5.0] 3.1M4 spurious type-safety compiler warning
Status: RESOLVED DUPLICATE of bug 79687
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.1 M5   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-12-23 22:43 EST by mike andrews CLA
Modified: 2005-01-11 11:01 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 mike andrews CLA 2004-12-23 22:43:53 EST
given the following two classes:

package test.a;

public class TestB {

}

package test.a;

import java.util.concurrent.Callable;
import java.util.concurrent.CompletionService;
import java.util.concurrent.Future;

public class TestA {

    private CompletionService<TestB> cs;

    public Future<TestB> submitTask(String command) {
        return cs.submit(new Callable<TestB>() {
            public TestB call() throws Exception {  // LINE IN QUESTION
                return new TestB();
            }
        });
    }
}

i get a compiler warning: "Type safety: The return type TestB of the method
call() of type new Callable<TestB>(){} needs unchecked conversion to conform to
the return type V of inherited method" in TestA.java

this doesn't seem correct, since i can use a non-anonymous class instead (for
the line in question), with no compiler warning.
Comment 1 mike andrews CLA 2004-12-23 22:57:42 EST
hmmmm.... still get the error without anonymous class now... but the following
standalone class completely demonstrates the problem: indicated line generates
compiler warning "Type safety: The return type String of the method call() of
type Test needs unchecked conversion to conform to the return type V of
inherited method":


package test.a;

import java.util.concurrent.Callable;

class Test implements Callable<String> {

    public String call() throws Exception { // THIS LINE GENERATES WARNING
        return new String("");
    }

}
Comment 2 Frederic Fusier CLA 2004-12-24 03:36:05 EST

*** This bug has been marked as a duplicate of 79687 ***