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 122477 - Use Clazz.class instead of getClass() when retrieving resources
Summary: Use Clazz.class instead of getClass() when retrieving resources
Status: RESOLVED DUPLICATE of bug 158777
Alias: None
Product: guibuilder
Classification: Unclassified
Component: Code (show other bugs)
Version: 5.x
Hardware: All All
: P3 blocker (vote)
Assignee: issues@guibuilder
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-11-21 11:17 UTC by nickdegraeve
Modified: 2012-08-17 16:36 UTC (History)
0 users

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description nickdegraeve 2007-11-21 11:17:26 UTC
The code generated when getting resources is getClass().getResource(..) but it may be unsafe according to FindBugs
(http://findbugs.sourceforge.net/bugDescriptions.html#UI_INHERITANCE_UNSAFE_GETRESOURCE):

"Usage of GetResource may be unsafe if class is extended

Calling this.getClass().getResource(...) could give results other than expected if this class is extended by a class in
another package."
Comment 1 Jana Maleckova 2008-09-05 16:22:49 UTC
could you be more precise ? which module generates this code or where we can find it ?
thanks in advance
Comment 2 Petr Dvorak 2008-10-09 13:36:26 UTC
Without requested information for long time - INVALID. We can't do anything in this case, so please reporter add
requested information and reopen issue. Thanks in advance.
Comment 3 nickdegraeve 2008-10-09 15:11:13 UTC
My apologies for not reacting sooner.

I don't know the exact name of the module but the code is generated when you try to set an icon for a Swing component
using the "Properties" window of the "Design" view.

Example of the code generated when an icon is set for a JButton:

   jButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/javaapplication3/myIcon.gif")));
Comment 4 Peter Pis 2008-11-03 09:55:42 UTC
Reassigning to form for further evaluation.
Comment 5 Tomas Pavek 2012-08-17 16:36:30 UTC

*** This bug has been marked as a duplicate of bug 158777 ***