• Post Reply Bookmark Topic Watch Topic
  • New Topic

Java 1.5 unchecked calls  RSS feed

 
Tim Cao
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I am migrating some of my code to Java 1.5, and I have some warnings of unchecked calls on the use of java.util.Vector, as follows

<pre>
warning: [unchecked] unchecked call to add(E) as a member of the raw type java.util.Vector
ruleList.add(newRule);
</pre>

Honestly, I have absolutely no idea what this means, is it true that a vector is supposed to be array that you can add your objects to and retrieve them later, whatever the objects are.

As the code still compiles and works, I dont really have a problem with these warnings. However, it'll be great if someone tell me what it means, and what is "right" way to work with these calls.

TIA,

Tim.
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
With JDK 5 "generics" you can declare collections to contain only certain types. To make this go away you could code:

That's pretty cool as now the compiler will only let you add Rule objects to the vector and you won't have to cast them when you pull them back out.

But it might be a huge change to your application. So you could also look up the compiler flag to check for 1.4 syntax instead of 1.5 syntax.

See if that helps!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!