You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@netbeans.apache.org by "Niklas Matthies (JIRA)" <ji...@apache.org> on 2017/07/09 23:06:00 UTC

[jira] [Updated] (NETBEANS-34) "Too broad 'catch' clause" hint doesn't properly support generic 'throws' declarations

     [ https://issues.apache.org/jira/browse/NETBEANS-34?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Niklas Matthies updated NETBEANS-34:
------------------------------------
    Description: 
Example:
{code:java}
import java.security.GeneralSecurityException;
import java.security.cert.CertificateException;

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".


  was:
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".



> "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}
> import java.security.GeneralSecurityException;
> import java.security.cert.CertificateException;
> 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)