wenwenlin / jsr-305

Automatically exported from code.google.com/p/jsr-305
0 stars 0 forks source link

Need an annotation for access widening #12

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Accidental method access widening is a big problem.  Often the consequence 
is that the API is cluttered with additional (and unnecessary) public 
methods, but in some cases widening could lead to unexpected 
interactions.  JCompoent.paintComponent method is frequently overridden 
and widened to no useful effect.  Such an annotation would provide the 
user with a clear warning that he has done something unexpected.

Conversely, there is the case where we expect that the access is widened 
(to public).  The ever-problematic Object.clone is such a method.  Users 
should be warned if they override Object.clone, but do not widen access to 
the method.

I am proposing the addition of two annotations:
AccessWideningProhibited
AccessWideningRequired

Theorectically, we could also include the middle ground, but that seems 
overwrought to me:
AccessWideningPermitted

Thanks,

Karl Schaefer

Original issue reported on code.google.com by karlgsch...@gmail.com on 4 Feb 2009 at 2:27