netbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Niklas Matthies (JIRA)" <j...@apache.org>
Subject [jira] [Created] (NETBEANS-34) "Too broad 'catch' clause" hint doesn't properly support generic 'throws' declarations
Date Sun, 09 Jul 2017 23:05:02 GMT
Niklas Matthies created NETBEANS-34:
---------------------------------------

             Summary: "Too broad 'catch' clause" hint doesn't properly support generic 'throws'
declarations
                 Key: NETBEANS-34
                 URL: https://issues.apache.org/jira/browse/NETBEANS-34
             Project: NetBeans
          Issue Type: Bug
          Components: java - Hints
    Affects Versions: 8.2
            Reporter: Niklas Matthies


Example:
{code:java}
    class Example
    {
        <T extends Throwable> void foo() throws T { }

        void bar() throws CertificateException { }

        void example()
        {
            try {
                this.<GeneralSecurityException> foo();
                bar();
            }
            catch (GeneralSecurityException ex) {
                // ignore
            }
        }
    }
{code}
NetBeans shows the following hint: "The catch(java.security.GeneralSecurityException) is too
broad, the actually caught exception is java.security.cert.CertificateException". Which is
incorrect, because the call to foo() throws a GeneralSecurityException.

Furthermore, when adding a second catch clause specifically for CertificateException (before
the existing catch clause), the hint on the existing catch clause becomes: "The catch(java.security.GeneralSecurityException)
is too broad, it catches the following exception types: null".




--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Mime
View raw message