Unreachable catch classes
David Holmes
David.Holmes at oracle.com
Wed Apr 27 08:40:11 UTC 2011
Maurizio Cimadamore said the following on 04/27/11 18:35:
> On 27/04/11 09:18, David Holmes wrote:
>> What I suggested on coin-dev ( which has finally turned up now that
>> someone has unblocked the openjdk mail pipes ;-) ) is that instead of
>> doing an analysis of the expected thrown types, to simply warn for the
>> more common mistake of catching a superclass before a subclass.
>
> So, you are saying that the JDK 7 compiler should stop generating
> additional warnings, and start behaving as usual (we always had errors
> when catching supertype after subtype, and such).
In that case I guess that is what I am suggesting.
Is there a @SuppressWarnings setting for these warnings?
David
> Maurizio
>>
>> David
>>
>>> Maurizio
>>>>
>>>> Cheers,
>>>> David
>>>>
>>>> Joe Darcy said the following on 04/27/11 11:53:
>>>>> Hello.
>>>>>
>>>>> FYI, javac in JDK 7 does a more precise analysis than before on
>>>>> what catch blocks can actually be reached and warnings are issued
>>>>> for unreachable catch blocks. I've extracted those warnings from a
>>>>> recent full JDK build in case anyone wants to update the code in
>>>>> question.
>>>>>
>>>>> -Joe
>>>>>
>>>>> ../../../../../../src/share/classes/com/sun/corba/se/impl/protocol/BootstrapServerRequestDispatcher.java:124:
>>>>> warning: unreachable catch clause
>>>>> } catch (java.lang.Exception ex) {
>>>>> ^
>>>>> thrown type RuntimeException has already been caught
>>>>>
>>>>> ../../../../../../src/share/classes/com/sun/corba/se/impl/protocol/BootstrapServerRequestDispatcher.java:124:
>>>>> warning: unreachable catch clause
>>>>> } catch (java.lang.Exception ex) {
>>>>> ^
>>>>> thrown type RuntimeException has already been caught
>>>>>
>>>>> ../../../src/share/classes/java/util/concurrent/ThreadPoolExecutor.java:1115:
>>>>> warning: unreachable catch clause
>>>>> } catch (Throwable x) {
>>>>> ^
>>>>> thrown types RuntimeException,Error have already been caught
>>>>> ../../../src/share/classes/java/net/DatagramSocket.java:183:
>>>>> warning: unreachable catch clause
>>>>> } catch(IOException e) {
>>>>> ^
>>>>> thrown type SocketException has already been caught
>>>>> Note: Some input files use or override a deprecated API.
>>>>> Note: Recompile with -Xlint:deprecation for details.
>>>>> Note: Some input files use unchecked or unsafe operations.
>>>>> Note: Recompile with -Xlint:unchecked for details.
>>>>> 2 warnings
>>>>>
>>>>> ../../../src/share/classes/java/security/cert/X509CertSelector.java:2217:
>>>>> warning: unreachable catch clause
>>>>> } catch (CertificateException e3) {
>>>>> ^
>>>>> thrown types
>>>>> CertificateNotYetValidException,CertificateExpiredException have
>>>>> already been caught
>>>>>
>>>>> ../../../src/share/classes/javax/management/modelmbean/RequiredModelMBean.java:1220:
>>>>> warning: unreachable catch clause
>>>>> } catch (Exception e) {
>>>>> ^
>>>>> thrown types
>>>>> InvocationTargetException,IllegalAccessException,RuntimeException
>>>>> have already been caught
>>>>> 1 warning
>>>>>
>>>>> ../../../../src/share/classes/sun/security/rsa/RSASignature.java:205:
>>>>> warning: unreachable catch clause
>>>>> } catch (GeneralSecurityException e) {
>>>>> ^
>>>>> thrown type BadPaddingException has already been caught
>>>>>
>>>>>
>>>
>
More information about the core-libs-dev
mailing list