Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » "Type Safety" Warnings in Problems View
"Type Safety" Warnings in Problems View [message #59661] Fri, 29 April 2005 17:32 Go to next message
Eclipse UserFriend
Originally posted by: marc.esher.cablespeed.com

Greetings. In the "Problems" view, Eclipse keeps flagging HashMaps and
ArrayLists for type safety. Take the following code (BeanListHandler and
runner.query are from apache DBUtils):

1. ResultSetHandler h = new BeanListHandler(FileBean.class);
2. ArrayList <FileBean> ar_FileBeans;

3. ar_FileBeans = (ArrayList)runner.query(cn,qry_FilesOnServers,h);


Eclipse is flagging line 3 with the message "Type Safety: The Expression
of raw type ArrayList is converted to ArrayList<FileBean>. References to
generic type ArrayList<E> should be parameterized".

I'm just starting to tinker with generics.

So...how should i revise this code such that Eclipse is happy?

Thanks for input.
Re: "Type Safety" Warnings in Problems View [message #60404 is a reply to message #59661] Mon, 02 May 2005 08:23 Go to previous message
Tom Hofmann is currently offline Tom HofmannFriend
Messages: 770
Registered: July 2009
Senior Member
Marc wrote:
> Greetings. In the "Problems" view, Eclipse keeps flagging HashMaps and
> ArrayLists for type safety. Take the following code (BeanListHandler and
> runner.query are from apache DBUtils):
>
> 1. ResultSetHandler h = new BeanListHandler(FileBean.class);
> 2. ArrayList <FileBean> ar_FileBeans;
>
> 3. ar_FileBeans = (ArrayList)runner.query(cn,qry_FilesOnServers,h);
>
>
> Eclipse is flagging line 3 with the message "Type Safety: The Expression
> of raw type ArrayList is converted to ArrayList<FileBean>. References to
> generic type ArrayList<E> should be parameterized".
>
> I'm just starting to tinker with generics.
>
> So...how should i revise this code such that Eclipse is happy?

You have to make the cast generic as well instead of using a raw cast:

3. ar_FileBeans =
(ArrayList<FileBean>)runner.query(cn,qry_FilesOnServers,h);

-tom
Previous Topic:Trouble starting Eclipse on Linux
Next Topic:Q: Typing in Eclipse
Goto Forum:
  


Current Time: Wed Apr 24 15:41:58 GMT 2024

Powered by FUDForum. Page generated in 0.08553 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top