Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / February 2006

Tip: Looking for answers? Try searching our database.

1.5 vs Vector -> warnings about unparameterized usage?

Thread view: 
David N. Welton - 02 Feb 2006 23:12 GMT
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,
Signature

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

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

Ian Pilcher - 02 Feb 2006 23:53 GMT
> 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

Signature

========================================================================
Ian Pilcher                                        i.pilcher@comcast.net
========================================================================

Roedy Green - 03 Feb 2006 11:46 GMT
On Fri, 03 Feb 2006 00:12:54 +0100, "David N. Welton"
<davidw@dedasys.com> wrote, quoted or indirectly quoted someone who
said :

>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?
see http://mindprod.com/jgloss/generics.html

Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.

David N. Welton - 04 Feb 2006 09:22 GMT
> On Fri, 03 Feb 2006 00:12:54 +0100, "David N. Welton"
> <davidw@dedasys.com> wrote, quoted or indirectly quoted someone who
[quoted text clipped - 4 lines]
>>
>>Can someone point me at the docs explaining this?

>  see http://mindprod.com/jgloss/generics.html

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,
Signature

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

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

Roedy Green - 04 Feb 2006 11:08 GMT
On Sat, 04 Feb 2006 10:22:06 +0100, "David N. Welton"
<davidw@dedasys.com> wrote, quoted or indirectly quoted someone who
said :

>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?

set source 1.4 target 1.4 and the warnings will go away.  You can use
annotations to suppress them in 1.5. They don't take long to fix once
you have the hang of it.

See http://mindprod.com/jgloss/annotations.html
Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.

David N. Welton - 04 Feb 2006 13:26 GMT
> On Sat, 04 Feb 2006 10:22:06 +0100, "David N. Welton"
> <davidw@dedasys.com> wrote, quoted or indirectly quoted someone who
[quoted text clipped - 6 lines]
> annotations to suppress them in 1.5. They don't take long to fix once
> you have the hang of it.

> See http://mindprod.com/jgloss/annotations.html

Cool, thanks.  Since this code has to compile for J2ME as well as J2SE,
the compiler switch is definitely the way to go.

Signature

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

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



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.