Bug 163093 - [1.5][compiler] Don't warn about use of raw types in overriding methods
Summary: [1.5][compiler] Don't warn about use of raw types in overriding methods
Status: CLOSED DUPLICATE of bug 322817
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.3   Edit
Hardware: PC Windows 2000
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 164472
  Show dependency tree
 
Reported: 2006-11-01 12:00 EST by John Arthorne CLA
Modified: 2010-10-18 11:52 EDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description John Arthorne CLA 2006-11-01 12:00:29 EST
Build: I20061031

Say there is an interface that uses a raw type, such as IAdaptable:

public Object getAdapter(Class clazz);

And say there is a class that implements this interface, and is compiled with Java 5. A warning is generated about the usage of raw type Class.

I think classes that implement IAdaptable and declare this method should not be warned about using a raw type, because they are forced to do so by the declaration in the super type.  I.e., they are being warned about something they don't have the power to fix.

See discussion in bug 149805.
Comment 1 Markus Keller CLA 2006-11-01 14:09:01 EST
Removing the warning just in signatures of overridden methods may be difficult to explain to the user.

E.g. if clazz is assigned to a local variable of raw type Class inside the method body, that would still raise a warning. Same with methods called on the parameter, or assignments to a parameterized version of the type, etc.
Comment 2 John Arthorne CLA 2006-11-01 15:02:15 EST
Another option is to have an extra checkbox that says "Check overriding and implementing methods", like you do for "Unnecessary declaration of thrown checked exception" and "Parameter is never read"
Comment 3 Mik Kersten CLA 2006-11-01 17:16:10 EST
I wonder if the implementing signature falls out of what the programmer would consider "usage of raw type", since the implementing signature is not something the programmer controls.  It either comes from a superclass they control, or a library that they don't.  If so something like the following could work, but it sure is tricky to phrase clearly.  If not I like John's suggestion, but the check box label would need to make it clear that the body will be checked, and that only the signature will be ignored.

Generic Types
    Usage of raw type														[Warning]
	Method signatures implementing/overriding raw type		[Ignore]
Comment 4 Philipe Mulet CLA 2008-11-04 08:42:27 EST
Indeed, since this is not allowed:

interface Adaptable {
	public Object getAdapter(Class clazz);	
}

public class X implements Adaptable {
	@Override
	public Object getAdapter(Class<?> clazz) {
		return null;
	}
}


Comment 5 Philipe Mulet CLA 2008-11-04 08:52:53 EST
However, you can write instead:

interface Adaptable {
	public Object getAdapter(Class clazz);	
}

public class X implements Adaptable {
	@Override
	public Object getAdapter(@SuppressWarnings("unchecked") Class clazz) {
		return null;
	}
}
Comment 6 Philipe Mulet CLA 2008-11-04 08:57:52 EST
Added AnnotationTest#test264
Added MethodVerifyTest#test179
Comment 7 Markus Keller CLA 2010-10-18 11:52:50 EDT

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