Bug 109401 - [compiler] Implementation a deprecated method
Summary: [compiler] Implementation a deprecated method
Status: NEW
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows XP
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-09-13 10:47 EDT by Per Lauge Holst CLA
Modified: 2005-09-15 14:51 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Per Lauge Holst CLA 2005-09-13 10:47:30 EDT
I'm a bit puzzled why an implementation of a deprecated method (of a
non-deprecated inteface) isn't flagged as deprecated - it isn't flagged by javac
either, until another method actually uses the deprecated method. I would
consider an implementation a use, but then Sun may not agree.

Anyway, I'd really like the editor to update the method, e.g. with a
strikethrough (default behaviour) or some other marker, lightbulb/warning.


Build id: I20050627-1435
Comment 1 Dirk Baeumer CLA 2005-09-13 18:03:33 EDT
I am not sure if I understand your request. Can you please provide an example.
Comment 2 Per Lauge Holst CLA 2005-09-14 04:16:20 EDT
Here's a short example:
2 java files: StuffDoer and DoStuff (Stupid names but this IS an example)

public interface StuffDoer {

    /**
     * Does stuff 
     *@deprecated this method is discouraged due to ... use manipulate(Object)
instead 
     */
    void doStuff();
    
    /**
     * manipulate a given object
     * @param target
     */
    void manipulate(Object target);
}

public class DoStuff implements StuffDoer {

    /* (non-Javadoc)
     * @see StuffDoer#doStuff()
     */
    public void doStuff() {
        System.out.println("doing stuff");
    }

    /* (non-Javadoc)
     * @see StuffDoer#manipulate(java.lang.Object)
     */
    public void manipulate(Object target) {
        System.out.println("manipulating "+target);
    }
}

When the StuffDoer.doStuff() method is deprecated I'd really appreciate knowing
this has happened when I'm tampering with the DoStuff class.

The example is really too small. It should encompass more developers, someone
modifying the interface, someone else modifying the class, and a third actually
using the modified interface (he'll know the method is deprecated due to a
compile warning). 

If you're not aware, that someone has deprecated the method you're implementing
or perhaps the programmer using the interface wonders why you've deprecated his
favorite method, when in truth you're unaware that the interface responsible
programmer did it - but not why.

Then again, it might just be me, but I really don't see why an interface doesn't
propagate method annotations in that way.

If you make a 3rd file: Work.java
public class Work {

    public static void main(String[] args) {
        StuffDoer sf = new DoStuff(); // reference is interface
        DoStuff ds = new DoStuff();   // reference is specific class
        
        sf.doStuff(); // this is deprecated
        ds.doStuff(); // this should be deprecated
    }
}

you'll see that sf.doStuff() is deprecated because the interface method is
deprecated. Using the specific class - which is frowned upon - circumvents this
real warning. In my mind, the method with that specific signature in a class
implementing an interface should inherit that specific annotation.

You'd really like people implementing java.lang.Runnable to quit implementing
stop() or at least let them know one way or another that it's deprecated.

HTH.
Comment 3 Dirk Baeumer CLA 2005-09-14 19:10:29 EDT
Moving to JDT/Core.