Bug 289917 - Unsupported @SupressWarnings("over-ann")
Summary: Unsupported @SupressWarnings("over-ann")
Status: VERIFIED WONTFIX
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.6   Edit
Hardware: PC Windows Vista
: P3 normal (vote)
Target Milestone: 3.6 M3   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-09-18 18:21 EDT by Chris West (Faux) CLA
Modified: 2009-10-27 07:31 EDT (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Chris West (Faux) CLA 2009-09-18 18:21:22 EDT
User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US) AppleWebKit/530.5 (KHTML, like Gecko) Chrome/2.0.172.43 Safari/530.5
Build Identifier: I20090522-1710

Given http://help.eclipse.org/galileo/index.jsp?topic=/org.eclipse.jdt.doc.isv/guide/jdt_api_compile.htm

I would expect:

class Overed {
	void foo() {}
}

class OverAnn extends Overed {
	@SuppressWarnings("over-ann")
	void foo() {}
}

..to not want me to add the @Override annotation (or, more pertinently, not to add the @Override annotation on clean-up).  Currently, it gives 'Unsupported @SuppressWarnings("over-ann")'.

Note that @SuppressWarnings("all") does offer the expected behavior.


Motivating example:

Extending a class in a library.  In one version, it has a method foo(String), in a newer, it has only foo(String, boolean).  With the save-action of add-@Override, saving your class on a machine with one version of the library will cause the code not to compile on machines with the other.  Actual example: FindBugs (oh, the irony).

Reproducible: Always

Steps to Reproduce:
1. Paste above code into any Java project.
2. Observe the warnings.
3. Clean-up: Add @Override and watch at it becomes..
...
	@Override @SuppressWarnings("over-ann")
	void foo() {}
...



java.version=1.6.0_14
java.vendor=Sun Microsystems Inc.
BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=en_GB
Command-line arguments:  -os win32 -ws win32 -arch x86_64
Comment 1 Olivier Thomann CLA 2009-09-20 12:06:58 EDT
over-ann is not one of the token supported fot SupressWarnings annotation.
In general we consider that this is simple enough to fix not to add such token.
Now if you have a test case that deserves to add this token, we might reconsider.

Could you please give more details on the FindBugs library issue?
Comment 2 Stephan Herrmann CLA 2009-09-21 06:47:24 EDT
(In reply to comment #0)

This I don't quite understand:

> Motivating example:
> 
> Extending a class in a library.  In one version, it has a method foo(String),
> in a newer, it has only foo(String, boolean).  With the save-action of
> add-@Override, saving your class on a machine with one version of the library
> will cause the code not to compile on machines with the other. 

So, is your method foo(String) _intended_ to override an existing
method as to leverage dynamic binding? Then it seems, that you need
different versions of your class, too, to reflect the change in the
library.

If, on the contrary, you don't care for dynamic binding, then your
method probably _shouldn't_ override an existing one, so you'd be
better off with a new name for the new method and no overriding at all.

Wanting to override a method from one version of the library and
not wanting to override when compiling against a different version
looks inconsistent to me, and thus I wouldn't suppress the warning
but try to improve the program.

But as Olivier said, seeing the exact real world example might help.
Comment 3 Chris West (Faux) CLA 2009-09-24 05:54:02 EDT
That was a shocking description, I'm sorry. :)


The abstract class / method in question is http://findbugs.sourceforge.net/api/edu/umd/cs/findbugs/ResourceTrackingDetector.html#prescreen(edu.umd.cs.findbugs.ba.ClassContext, org.apache.bcel.classfile.Method, boolean).

In FindBugs 1.3.9 this has the third boolean argument.  In 1.3.8, it does not.

An extension of this class can look something like:

public boolean prescreen(ClassContext classContext, Method method) {
 return prescreen(classContext, method, false);
}

public boolean prescreen(ClassContext classContext, Method method, boolean mightClose) {
 doActualWork();

In 1.3.8, the first version is the @Override (and delegates to the three-argument version), in 1.3.9 the second is the @Override (leaving the two-argument version unreferenced).


Simpler version: Usah wants to be able to implement either Inter1 or Inter2 depending on library version.  Neither foo() nor foo(boolean) can be marked as @Override:

interface Inter1 {
  void foo();
}

interface Inter2 {
  void foo(boolean b);
}

class Usah implements Inter1 {
  /** helper for old version */
  public void foo() {
    foo(true);
  }

  public void foo(boolean b) {
    System.out.println(b);
  }
}


This doesn't involve or require detection of which library version, etc... it feels like clean design to me?
Comment 4 Olivier Thomann CLA 2009-09-29 13:45:07 EDT
I guess you meant:
class Usah implements Inter1, Inter2 {
...

I am not sure this is frequent enough to deserve a new token. As you say, using "all" is a workaround.

Kent, any thoughts on this ?
Comment 5 Kent Johnson CLA 2009-09-29 15:43:57 EDT
I also don't see this as a 'common' enough case to add the additional token when  @SuppressWarnings("all")  can be used & is local to just the affected methods
Comment 6 Chris West (Faux) CLA 2009-09-29 17:17:08 EDT
Close enough.  Meh, seemed like a silly omission at the time.
Comment 7 Olivier Thomann CLA 2009-09-30 21:22:50 EDT
Closing as WONTFIX.
Comment 8 Jay Arthanareeswaran CLA 2009-10-27 05:56:43 EDT
Verified for 3.6 M3