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 256425 - unnecessary test for null following ignored exception
Summary: unnecessary test for null following ignored exception
Status: RESOLVED FIXED
Alias: None
Product: java
Classification: Unclassified
Component: Hints (show other bugs)
Version: 8.1
Hardware: PC Linux
: P3 normal (vote)
Assignee: Svata Dedic
URL:
Keywords:
Depends on:
Blocks: 249320
  Show dependency tree
 
Reported: 2015-11-06 22:11 UTC by josephcz
Modified: 2015-11-13 12:30 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description josephcz 2015-11-06 22:11:13 UTC
The following code yields an "unnecessary test for null" hint for the code following a try/catch that ignores an exception.


  public static Class<?> foo (String s) {
    if (s == null) {
      try {
        return Class.forName("does.not.exist");
      }
      catch (ClassNotFoundException e) {
        // ignore
      }
    }

    if (s != null) {    // unnecessary test for null appears here
      return Object.class;
    }
    return String.class;
  }
Comment 1 Svata Dedic 2015-11-13 12:30:46 UTC
Fixed in the experimental impl; wait for the umbrella issue to close.