[OpenJDK 2D-Dev] RFR: JDK-8263362: Avoid division by 0 in java/awt/font/TextJustifier.java justify

Prasanta Sadhukhan psadhukhan at openjdk.java.net
Wed May 5 12:59:53 UTC 2021


On Tue, 4 May 2021 15:00:29 GMT, Matthias Baesken <mbaesken at openjdk.org> wrote:

>> I meant that since we are dividing by weight and absorbweight 
>> ` weightedDelta = delta / weight;`
>> and
>>  weightedAbsorb = (delta - gslimit) / absorbweight;
>> where both weight and absorbweight uses += gi.weight values so if one is checking for >0 
>> then to be consistent, in my opinion, 
>> other one should be same or absorbweight also probably should check !=0.
>
> should we then better check  for 
>  if (weight > 0) 
> instead of
>  if (weight != 0) 
> like it is done for absorbweight ?
> (If you think consistency is important here)

I guess since it was mentioned before that nothing prevents the value from being -ve,
I guess better will be to use != 0 check for absorbweight too?

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

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


More information about the 2d-dev mailing list