Search |
||
Did I Miss Generic Array Creation?Posted by dwalend on January 7, 2005 at 5:07 AM PST
While sweeping up sawdust before the latest release of JDigraph, I used -Xlint to spot remaining places where I have some things to clean up. I have just a handful to go. I'm having the most trouble with creating Arrays in collection-like classes. JDigraph is a generic efficient directed graph representation, so these arrays are everywhere. I've taken examples from FibHeap.java.
results in a waring from lint.
The first thing I tried didn't compile:
results in
I tried dynamically creating the array using java.lang.reflect.Array:
which gives me the warning from lint again.
I've tried doing other things, especially to the HeapMember.class argument, but haven't found a solution that compiles with no warnings. Is there some bit of API I missed? Is there a good reason not to create arrays of generics? Or should I report a RFE to Sun asking them to add generic parameters to Array.newInstance()? Thanks, Dave »
Related Topics >>
J2SE Comments
Comments are listed in date ascending order (oldest first)
|
||
|
|