Skip to main content

Xlint:overrides ?

5 replies [Last post]
olivier_thomann
Offline
Joined: 2005-09-06
Points: 0

Hi,

According to the javac help, this is a new warning. But I could not figure out in what case it reports a warning.
Could you please provide an example?
I tried to find more information from the online documentation, but I could not find overrides in the list of warnings supported by Xlint option.

Thanks.

Best regards,

Olivier

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
mckelvey
Offline
Joined: 2006-09-01
Points: 0

That's not what he's asking. @Override causes an error.

He's asking about the Lint option "overrides".

-Xlint Enable recommended warnings
-Xlint:{all,cast,deprecation,divzero,empty,unchecked,fallthrough,path,serial,f
inally,overrides,-cast,-deprecation,-divzero,-empty,-unchecked,-fallthrough,-pat
h,-serial,-finally,-overrides,none}Enable or disable specific warnings

sjasja
Offline
Joined: 2004-08-15
Points: 0

Use the source, Luke!
[code]
public class t
{
void foo(String... s) { }
}

class t2
extends t
{
void foo(String[] s) { }
}
[/code]

olivier_thomann
Offline
Joined: 2005-09-06
Points: 0

Thank you for this example. Is it restricted to varargs method overriding?

soupdragon
Offline
Joined: 2006-01-07
Points: 0

When you are writing a method intended to override an method in the super class you can use the annotation @Override in front of the method definition.

This is to ensure you've got to signature right, if you get the parameters wrong there's otherwise a risk that the new method will be treated separately and not be called.

olivier_thomann
Offline
Joined: 2005-09-06
Points: 0

Could you please provide an example?
I tried and I either get an error or no warning.

class Y {
public void foo(int i) {}
}
public class X extends Y {
public void foo(double d) {}
}

Nothing.
class Y {
public void foo(int i) {}
}
public class X extends Y {
@Override
public void foo(double d) {}
}

Error.

Thanks.