This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 179805

Summary: Do not use NbBundle.getBundle(getClass())
Product: apisupport Reporter: Jesse Glick <jglick>
Component: TemplatesAssignee: _ tboudreau <tboudreau>
Status: RESOLVED FIXED    
Severity: normal    
Priority: P2    
Version: 6.x   
Hardware: All   
OS: All   
Issue Type: DEFECT Exception Reporter:
Bug Depends on: 164597    
Bug Blocks: 116449    

Description Jesse Glick 2010-01-22 15:55:37 UTC
Tim Boudreau wrote:
> stat - StatusDisplayer.getDefault().setStatusText(NbBundle.getMessage(getClass(), "KEY")) - where KEY is a parameter

This is a well-known antipattern; such code will break if called from a subclass in a different package! Please fix the abbreviation to use TheTopLevelContainingClass.class instead.
Comment 1 Jesse Glick 2010-01-22 16:00:59 UTC
Same for the Logger-related abbreviations.

Better to delete these abbreviations until they can be done correctly, than have people start creating bugs that may not be caught for years.
Comment 2 _ tboudreau 2010-01-22 16:58:54 UTC
See bug 164597 - there is currently no way to get a hint for the current class name in a code template.

I will probably try to develop a patch to enable this in the next day or so, since I don't think it will be touched otherwise.
Comment 3 _ tboudreau 2010-01-22 23:48:19 UTC
Fixed in main/ 9ab6fe4a3c92 along with patch to java.editor to enable referencing containing class from code templates
Comment 4 Quality Engineering 2010-01-24 08:47:07 UTC
Integrated into 'main-golden', will be available in build *201001240200* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/9ab6fe4a3c92
User: Tim Boudreau <tboudreau@netbeans.org>
Log: #164597 and #179805 - ability to reference containing class in code templates, fix apisupport.project code templates (NbBundle, Logger) not to use getClass().