This discussion is archived
2 Replies Latest reply: Apr 5, 2011 1:07 AM by Vijayalayan RSS

Migration from JDK 1.4 to JDK 1.6

Vijayalayan Newbie
Currently Being Moderated
Hi, We are currently migrating our Systems to JDK 1.4 to JDK 6 .. During the compilation of our Existing Source in JDK 6 compilers we are getting the following Common warnings in most of the places.

warning: [unchecked] unchecked call to add(E) as a member of the raw type java.util.Vector
warning: [unchecked] unchecked call to add(E) as a member of the raw type java.util.Collection

As the systems ae perfectly running fine with the existing raw type source code we prefer to ignore these warning messages.

We would like to know the answers for the following queries.


i) What are the impacts for ignoring these messages and proceed with the compilation of existing source..?
ii) As the systems are running fine in JDK 1.4 is it mandatory to resolve this warning to work fine( in the same way as in jdk 1.4 ) in JDK 1.6
iii) If it is not advisable to ignore these messages what are the resolutions for the same?


Thanks in advance.
Vijay.
  • 1. Re: Migration from JDK 1.4 to JDK 1.6
    796440 Guru
    Currently Being Moderated
    Those warnings have no effect on the execution of your code. It will continue to execute as it always has. Those warning are simply telling you that you are not taking advantage of the compile-time type safety offered by generics, introduced in 1.5. The way to fix that would be to start using generics. If that code is not under active development and you don't want to go messing around in code that already works, you can safely ignore them.

    The consequences of ignoring them are:

    1) You now have a lot of clutter in your compiler output, making it harder to spot actual error messages, and harder to isolate those warnings that you do care about.

    2) Even though your code is running fine, it's possible that you've got type errors somewhere (illegal casts, for example) that simply haven't been hit yet, or that are being hit but you're not noticing. Proper application of generics may bring those out at compile time.

    If you want to get rid of the warnings without fully adopting generics, you can use the @SupressWarnings("unchecked") annotation. However, use this with caution, as you're telling the compiler to ignore something that, while syntactically legal, is potentially dangerous.

    http://download.oracle.com/javase/1.5.0/docs/guide/language/generics.html
    http://java.sun.com/j2se/1.5/pdf/generics-tutorial.pdf
    http://www.benmccann.com/dev-blog/suppressing-compile-warnings-with-java-annotations/
    http://www.google.com/search?q=ignore+raw+warning+annotation+java
    http://download.oracle.com/javase/1.5.0/docs/guide/language/annotations.html
  • 2. Re: Migration from JDK 1.4 to JDK 1.6
    Vijayalayan Newbie
    Currently Being Moderated
    Many Thanks for this. The resolution is really helpful..

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points