Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are "unavoidable generic type problems" in Eclipse for Java?

Eclipse can be configured to "ignore unavoidable generic type problems" when setting the preferences for the Java Compiler in the "Errors/Warnings" panel.

What are such "unavoidable" generic type problems in Java? Is it safe to ignore these? When do they arise?

like image 895
scravy Avatar asked Mar 18 '12 22:03

scravy


2 Answers

From the documentation of the feature:

When enabled, the compiler will issue an error or a warning even when it detects a generic type problem that could not have been avoided by the programmer. As an example, a type may be forced to use raw types in its method signatures and return types because the methods it overrides from a super type are declared to use raw types in the first place.

So, for example:

class Test {
    public void method(ArrayList list) {
    }
}

class TestSub extends Test {

    @Override
    public void method(ArrayList list) {
    //                 ^^^^^^^^^
    //     Complain on use of raw type or not?

        System.out.println("Overridden");
    }
}
like image 139
aioobe Avatar answered Nov 14 '22 23:11

aioobe


From the Eclipse help page:

When enabled, the compiler will issue an error or a warning even when it detects a generic type problem that could not have been avoided by the programmer. As an example, a type may be forced to use raw types in its method signatures and return types because the methods it overrides from a super type are declared to use raw types in the first place.

like image 40
Ted Hopp Avatar answered Nov 15 '22 00:11

Ted Hopp