Bug 335045 - [compiler] Should the compiler report deprecation from within the same compilation unit ?
Summary: [compiler] Should the compiler report deprecation from within the same compil...
Status: VERIFIED WONTFIX
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.7   Edit
Hardware: PC Windows 7
: P3 minor (vote)
Target Milestone: 3.7 M7   Edit
Assignee: Srikanth Sankaran CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-01-21 14:08 EST by Olivier Thomann CLA
Modified: 2011-04-25 06:20 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Olivier Thomann CLA 2011-01-21 14:08:12 EST
Fup of bug 334978.

javac doesn't report deprecation warnings for:
import java.util.ArrayList;
import java.util.List;

public class DeprecatedTest {
    private final List<Object> instances;

    public DeprecatedTest(){
        instances = new ArrayList<Object>();
        instances.add(new Depr());
        instances.add(new Depr1());
        instances.add(new Depr2());
        instances.add(new Depr3());        
    }    

    @Deprecated
    public class Depr{}
    @Deprecated
    public class Depr1{}
    @Deprecated
    public class Depr2{}
    @Deprecated
    public class Depr3{}    
}

but does for:
import java.util.ArrayList;
import java.util.List;

public class DeprecatedTest {
    private final List<Object> instances;

    public DeprecatedTest(){
        instances = new ArrayList<Object>();
        instances.add(new Depr());
        instances.add(new Depr1());
        instances.add(new Depr2());
        instances.add(new Depr3());        
    }    
}
@Deprecated
class Depr{}
@Deprecated
class Depr1{}
@Deprecated
class Depr2{}
@Deprecated
class Depr3{}

where all types are defined in the same unit.
The Eclipse compiler only reports deprecation if the deprecated types come from a different compilation unit.
Comment 1 Olivier Thomann CLA 2011-01-21 14:08:37 EST
Srikanth, please let me know what you think.
Comment 2 Srikanth Sankaran CLA 2011-03-18 22:56:23 EDT
(In reply to comment #1)
> Srikanth, please let me know what you think.

Unless there is strong sentiment otherwise, I am inclined to leave
the current behavior as it is.

When the compilation units are different, the potential for provenance
of the the client code and service providing code differing is there
and as such the warning is useful to communicate intent and avoid "out of
sight out of mind" situations.

When things are in the same compilation unit, the authorship/ownership
is the same and fixing the uses of about to deprecated code can be taken
atomically with the act of deprecation itself.
Comment 3 Srikanth Sankaran CLA 2011-03-23 00:16:11 EDT
Closing as WONT_FIX.
Comment 4 Ayushman Jain CLA 2011-04-25 06:20:01 EDT
Verified for 3.7M7