1.5 vs Vector -> warnings about unparameterized usage?

  • Thread starter David N. Welton
  • Start date
D

David N. Welton

Hi,

Someone is compiling my software with 1.5, and it's giving them warnings
about unparameterized usage of Vector.

Can someone point me at the docs explaining this?

For big, extra bonus points... the real question: this system (Hecl, at
hecl.org, if you wanted to know more) runs both on j2se as well as j2me
systems. I could provide some sort of accessor for the Vectors, however
that means two more methods that are completely useless and add weight
to the program (yeah, yeah, it's just two, but two here, two there... it
adds up).

Thanks,
--
David N. Welton
- http://www.dedasys.com/davidw/

Linux, Open Source Consulting
- http://www.dedasys.com/
 
I

Ian Pilcher

David said:
Someone is compiling my software with 1.5, and it's giving them warnings
about unparameterized usage of Vector.

1.5 wants Vector (and other Collections classes) to be parameterized.

For example, instead of:

Vector v = new Vector();
v.add("Hello World!");
String s = (String)v.get(0);

You now do:

Vector<String> v = new Vector<String>();
v.add("Hello World!");
String s = v.get(0); // no cast required

The thing in the angle brackets is called a type parameter, so Vector is
now a "parameterized class". Old-style code is, indeed, an
unparameterized usage.

These are more commonly referred to as Java Generics.

HTH
 
D

David N. Welton


Ok, thanks. Now, I guess what I need is a way to turn those warnings
off, because this is not 1.5 source code, nor will it be for a while.

If I understand things correctly, it ought to be enough to use the
'source' attribute in Ant, like the example provided in their docs, right?

<javac srcdir="${src}"
destdir="${build}"
classpath="xyz.jar"
debug="on"
source="1.4"

Thanks,
--
David N. Welton
- http://www.dedasys.com/davidw/

Linux, Open Source Consulting
- http://www.dedasys.com/
 
D

David N. Welton

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,269
Latest member
vinaykumar_nevatia23

Latest Threads

Top