[OpenJDK 2D-Dev] JDK 9 RFR of JDK-8044694: Fix finally lint warnings in sun.print

Joe Darcy joe.darcy at oracle.com
Tue Jun 3 18:42:02 UTC 2014


On 06/03/2014 11:34 AM, Phil Race wrote:
> Both of these came in via an IBM contributed fix :-
> http://mail.openjdk.java.net/pipermail/2d-dev/2011-October/002206.html
> He [it appears] wanted to be very sure the throw was executed but it 
> seems
> like it could just be moved after the finally block which might be better
> than suppressing the warning.

That approach would be fine with me. New webrev uploaded to

     http://cr.openjdk.java.net/~darcy/8044694.1

Patch below.

Thanks,

-Joe

diff -r 6d4b3a9ca33d src/share/classes/sun/print/PSPrinterJob.java
--- a/src/share/classes/sun/print/PSPrinterJob.java    Tue Jun 03 
09:22:59 2014 -0700
+++ b/src/share/classes/sun/print/PSPrinterJob.java    Tue Jun 03 
11:41:38 2014 -0700
@@ -708,8 +708,8 @@
                      }
                  } finally {
                      pw.flush();
-                    throw new IOException(sw.toString());
                  }
+                throw new IOException(sw.toString());
              }
          }

diff -r 6d4b3a9ca33d src/solaris/classes/sun/print/UnixPrintJob.java
--- a/src/solaris/classes/sun/print/UnixPrintJob.java    Tue Jun 03 
09:22:59 2014 -0700
+++ b/src/solaris/classes/sun/print/UnixPrintJob.java    Tue Jun 03 
11:41:38 2014 -0700
@@ -992,8 +992,8 @@
                      }
                  } finally {
                      pw.flush();
-                    throw new IOException(sw.toString());
                  }
+                throw new IOException(sw.toString());
              }
          }


>
> -phil.
>
> On 6/3/2014 10:11 AM, Joe Darcy wrote:
>> Hello,
>>
>> Please review a fix for
>>
>>     JDK-8044694: Fix finally lint warnings in sun.print
>>     http://cr.openjdk.java.net/~darcy/8044694.0/
>>
>> One of javac's lint warnings is for a finally block that cannot 
>> complete normally. The printing code has two instances with a finally 
>> block like
>>
>>                   } finally {
>>                       pw.flush();
>>                       throw new IOException(sw.toString());
>>                   }
>>
>> This cannot complete normally, since an exception is unconditionally 
>> thrown, but it very much seems to be the intended behavior. The fix 
>> is to add @SuppressWarnings("finally") annotations:
>>
>> --- old/src/share/classes/sun/print/PSPrinterJob.java 2014-06-03 
>> 10:07:16.000000000 -0700
>> +++ new/src/share/classes/sun/print/PSPrinterJob.java 2014-06-03 
>> 10:07:16.000000000 -0700
>> @@ -687,6 +687,7 @@
>>
>>      // Inner class to run "privileged" to invoke the system print 
>> command
>>
>> +    @SuppressWarnings("finally") // Exception always thrown in 
>> finally block
>>      private class PrinterSpooler implements 
>> java.security.PrivilegedAction {
>>          PrinterException pex;
>>
>> --- old/src/solaris/classes/sun/print/UnixPrintJob.java 2014-06-03 
>> 10:07:16.000000000 -0700
>> +++ new/src/solaris/classes/sun/print/UnixPrintJob.java 2014-06-03 
>> 10:07:16.000000000 -0700
>> @@ -971,6 +971,7 @@
>>
>>      // Inner class to run "privileged" to invoke the system print 
>> command
>>
>> +    @SuppressWarnings("finally") // Exception always thrown in 
>> finally block
>>      private class PrinterSpooler implements 
>> java.security.PrivilegedAction {
>>          PrintException pex;
>>
>> Thanks,
>>
>> -Joe
>




More information about the 2d-dev mailing list