RFR: 8264666: Reuse Math.multiplyExact/addExact in the LCMSImageLayout class

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

RFR: 8264666: Reuse Math.multiplyExact/addExact in the LCMSImageLayout class

Sergey Bylokhov-2
- The hand-crafted methods for addition and multiplication are replaced by the "Math" versions.
- Cleanup: the usage of do/while(false) is removed

-------------

Commit messages:
 - delete "do{...} while (false);"
 - safeXX -> xxExact

Changes: https://git.openjdk.java.net/jdk/pull/3333/files
 Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=3333&range=00
  Issue: https://bugs.openjdk.java.net/browse/JDK-8264666
  Stats: 110 lines in 1 file changed: 5 ins; 36 del; 69 mod
  Patch: https://git.openjdk.java.net/jdk/pull/3333.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/3333/head:pull/3333

PR: https://git.openjdk.java.net/jdk/pull/3333
Reply | Threaded
Open this post in threaded view
|

Re: RFR: 8264666: Reuse Math.multiplyExact/addExact in the LCMSImageLayout class

Sergey Bylokhov-2
On Fri, 2 Apr 2021 23:02:50 GMT, Sergey Bylokhov <[hidden email]> wrote:

> - The hand-crafted methods for addition and multiplication are replaced by the "Math" versions.
> - Cleanup: the usage of do/while(false) is removed

The nice PR number: 3333!

src/java.desktop/share/classes/sun/java2d/cmm/lcms/LCMSImageLayout.java line 241:

> 239:                         l.imageAtOnce = true;
> 240:                     }
> 241:                 } while (false);

Any idea why the "do/while(false)" was used here?

-------------

PR: https://git.openjdk.java.net/jdk/pull/3333
Reply | Threaded
Open this post in threaded view
|

Re: RFR: 8264666: Reuse Math.multiplyExact/addExact in the LCMSImageLayout class

Phil Race
On Fri, 2 Apr 2021 23:06:43 GMT, Sergey Bylokhov <[hidden email]> wrote:

>> - The hand-crafted methods for addition and multiplication are replaced by the "Math" versions.
>> - Cleanup: the usage of do/while(false) is removed
>
> The nice PR number: 3333!

I don't understand the exception handling here. multiplyExact and addExact will throw a runtime exception - ArithmeticException. And I don't see where it is caught. The change for ImageLayoutException to extend ArithmeticException doesn't seem like it can help here. Where is the ArithmeticException being turned into ImageLayoutException ?

-------------

PR: https://git.openjdk.java.net/jdk/pull/3333
Reply | Threaded
Open this post in threaded view
|

Re: RFR: 8264666: Reuse Math.multiplyExact/addExact in the LCMSImageLayout class

Alexander Zvegintsev-2
In reply to this post by Sergey Bylokhov-2
On Sun, 4 Apr 2021 07:58:44 GMT, Sergey Bylokhov <[hidden email]> wrote:

>> - The hand-crafted methods for addition and multiplication are replaced by the "Math" versions.
>> - Cleanup: the usage of do/while(false) is removed
>
> src/java.desktop/share/classes/sun/java2d/cmm/lcms/LCMSImageLayout.java line 241:
>
>> 239:                         l.imageAtOnce = true;
>> 240:                     }
>> 241:                 } while (false);
>
> Any idea why the "do/while(false)" was used here?

Probably it is just a way to highlight and improve readability of a block of code, but simply `{}` would be enough in this case.

-------------

PR: https://git.openjdk.java.net/jdk/pull/3333
Reply | Threaded
Open this post in threaded view
|

Re: RFR: 8264666: Reuse Math.multiplyExact/addExact in the LCMSImageLayout class

Sergey Bylokhov-2
In reply to this post by Phil Race
On Wed, 7 Apr 2021 20:14:06 GMT, Phil Race <[hidden email]> wrote:

> I don't understand the exception handling here. multiplyExact and addExact will throw a runtime exception - ArithmeticException. And I don't see where it is caught. The change for ImageLayoutException to extend ArithmeticException doesn't seem like it can help here. Where is the ArithmeticException being turned into ImageLayoutException ?

O_o for some reason... missed that.

-------------

PR: https://git.openjdk.java.net/jdk/pull/3333