[OpenJDK 2D-Dev] JDK9: RFR: 8039342: Fix raw and unchecked warnings in sun.awt.*

Jim Graham james.graham at oracle.com
Wed Apr 23 21:30:41 UTC 2014


Perhaps a simpler fix would be to return an empty Curve list there since 
you can't have an enclosed area with fewer than 2 edges (even if it is a 
curve, the segments are already broken up into monotonically 
increasing/decreasing sections so no single curve segment can double 
back on itself and enclose area without being broken up into at least 2 
curve sections).  Since these internal curve lists are considered 
read-only once they are calculated, a static empty curve list would work.

We know that we can only get here with 0 or 2+ edges anyway, so that 
case is simply the "fast empty list handler with a relaxed trigger 
condition", but even if we got here with 1 edge, an empty list is the 
correct result...

			...jim

On 4/7/14 1:46 PM, Henry Jen wrote:
> Hi,
>
> Please review the webrev cleans up raw and unchecked warnings in sun.awt,
>
> http://cr.openjdk.java.net/~henryjen/jdk9/8039342/0/webrev/
>
> The following changes in AreaOp::pruneEdges() is particular worth
> attention, when numedges < 2, two different type are mixed up in the
> past with use of rawtypes; However, I think it could only work if the
> Vector is empty?
>
> Cheers,
> Henry
>
>
>> @@ -193,16 +193,20 @@
>>              }
>>              return 1;
>>          }
>>      };
>>
>> -    private Vector pruneEdges(Vector edges) {
>> +    private Vector<Curve> pruneEdges(Vector<Edge> edges) {
>>          int numedges = edges.size();
>>          if (numedges < 2) {
>> -            return edges;
>> +            Vector<Curve> rt = new Vector<>();
>> +            for (Edge edge: edges) {
>> +                rt.add(edge.getCurve());
>>          }
>> -        Edge[] edgelist = (Edge[]) edges.toArray(new Edge[numedges]);
>> +            return rt;
>> +        }
>> +        Edge[] edgelist = edges.toArray(new Edge[numedges]);
>>          Arrays.sort(edgelist, YXTopComparator);
>>          if (false) {
>>              System.out.println("pruning: ");
>>              for (int i = 0; i < numedges; i++) {
>>                  System.out.println("edgelist["+i+"] = "+edgelist[i]);
>



More information about the 2d-dev mailing list