aspose file tools
The moose likes Java in General and the fly likes generics compiler warning Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "generics compiler warning" Watch "generics compiler warning" New topic
Author

generics compiler warning

Dan Murphy
Ranch Hand

Joined: Mar 29, 2005
Posts: 126
Hi,



The line marked WARNING generates the following compiler warning:
"Type safety: The cast from Object to List<Object> is actually checking against the erased type List"

I've tried changing ( List<Object> ) to just (List), but then I get the warning:
"Type safety: The expression of type List needs unchecked conversion to conform to Collection<? extends Object>"

How can I write this method without generating any compiler warnings?

Cheers,
DM

[ September 13, 2007: Message edited by: Dan Murphy ]
[ September 13, 2007: Message edited by: Dan Murphy ]

SCJP, SCJD, SCWCD
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18670
Try:

returnList.addAll((List<?>) object);


"I'm not back." - Bill Harding, Twister
Dan Murphy
Ranch Hand

Joined: Mar 29, 2005
Posts: 126
perfect, thanks!
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: generics compiler warning
 
Similar Threads
JDK 1.5 Type Safety warning
getting system time on remote machine
Vector.add() compiler warning
Type Casting Generics
generics - map of lists