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

Prasanta Sadhukhan psadhukhan at openjdk.java.net
Thu Mar 11 10:16:07 UTC 2021

On Thu, 11 Mar 2021 06:45:05 GMT, Matthias Baesken <mbaesken at openjdk.org> wrote:

>> By that same logic, then shouldn't absorbweight also be checked as != 0 instead of > 0 as that also uses += gi.weight
> Hi, I am not sure about the absorbweight  check; but  currently the calculated value weightedAbsorb is only used when absorbing is true. And  there the > 0 check is present too
> boolean absorbing = hitLimit && absorbweight > 0;

I meant that since we are dividing by weight and absorbweight 
` weightedDelta = delta / weight;`
 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.


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

More information about the 2d-dev mailing list