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.
We should be able to suppress this warning. My use-case: 1. The database returns a non-null department object. The department has a foreign key: companyId. I know the company is non-null because I am using REPEATABLE_READ transaction isolation level so if the department exists, the company must exist as well. 2. I look up the company in the database and try to dereference its fields. 3. I assert(company!=null) just in case but Netbeans ignores this. 4. Netbeans complains "null pointer dereference" Expected behavior: 1. assert() should count as a null pointer check 2. Ability to suppress the null pointer dereference warning using @SupressWarnings
Integrated into 'main-golden', will be available in build *201211280002* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress) Changeset: http://hg.netbeans.org/main-golden/rev/1f813511384a User: Jan Lahoda <jlahoda@netbeans.org> Log: #222795: support for assert.
Thank for the testcase - added a @SuppressWarnings key and support for assert.
Reopening because assert() no longer suppresses this hint as of: Product Version: NetBeans IDE Dev (Build 201301120001) Java: 1.7.0_11; Java HotSpot(TM) 64-Bit Server VM 23.6-b04 Runtime: Java(TM) SE Runtime Environment 1.7.0_11-b21 System: Windows 7 version 6.1 running on amd64; Cp1252; en_CA (nb) User directory: C:\Users\Gili\AppData\Roaming\NetBeans\dev Cache directory: C:\Users\Gili\AppData\Local\NetBeans\Cache\dev Here is my code: public class Test extends GuiceServletContextListener { @Nullable private Injector injector; @Override protected Injector getInjector() { assert (this.injector == null): injector; this.injector = Guice.createInjector(new JerseyModule()); return injector; } @Override public void contextInitialized(ServletContextEvent servletContextEvent) { assert (injector != null); String test = injector.getInstance(String.class); super.contextInitialized(servletContextEvent); } } In the line "String test = ..." injector is flagged as dereferencing null.
I filed a separate bug #224988 for that to simplify adding the fix into a patch release (or to the 7.3 itself if approved).