Results 1 to 16 of 16
  1. #1
    pronetin is offline Member
    Join Date
    May 2010
    Posts
    6
    Rep Power
    0

    Default unchecked or unsafe operations-Recompile with -Xlint

    Hi,

    I wrote a program. when i Build and clean it using Netbeans, shows this message:
    Java Code:
    init:
    deps-clean:
    Deleting directory /home/pronetin/New/build
    Deleting directory /home/pronetin/New/dist
    clean:
    init:
    deps-jar:
    Created dir: /home/pronetin/New/build/classes
    Compiling 16 source files to /home/pronetin/New/build/classes
    [COLOR="Red"]Note: Some input files use unchecked or unsafe operations.
    Note: Recompile with -Xlint:unchecked for details.[/COLOR]
    compile:
    Created dir: /home/pronetin/New/dist
    Building jar: /home/pronetin/New/dist/prjsrc.jar
    Not copying the libraries.
    To run this application from the command line without Ant, try:
    java -jar "/home/pronetin/New/dist/prjsrc.jar"
    jar:
    BUILD SUCCESSFUL (total time: 2 seconds)
    Is red lines is important messages? If yes, what should i do to not show this lines?

  2. #2
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    9

    Default

    Well, why don't you try doing what it says and add the "-Xlint:unchecked" option to your compilation command? See the NetBeans documentation for details on how to do that.

  3. #3
    pronetin is offline Member
    Join Date
    May 2010
    Posts
    6
    Rep Power
    0

    Wink

    I add -Xlint option and see 2 warning that related to initialization two Vector class object that i do not specified its type.

    comment:
    for adding -Xlint to compilation command in netbeans, follow:
    Run->set project configuration->Build section->compiling section->Additional compiling options field.

  4. #4
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    Quote Originally Posted by pronetin View Post
    I add -Xlint option and see 2 warning that related to initialization two Vector class object that i do not specified its type.
    If you are working on NetBeans it gives you a suggestion.

  5. #5
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    9

    Default

    So, have you now added a type to the declaration?

    Or at least added a SuppressWarnings annotation (if a single specific type is not appropriate)?

  6. #6
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    Quote Originally Posted by masijade View Post
    Or at least added a SuppressWarnings annotation (if a single specific type is not appropriate)?
    NetBeans actually suggest this on the editor notifications.

  7. #7
    pronetin is offline Member
    Join Date
    May 2010
    Posts
    6
    Rep Power
    0

    Default

    So, have you now added a type to the declaration?

    Or at least added a SuppressWarnings annotation (if a single specific type is not appropriate)?
    I add type explicitly:
    Vector<MyClass> vector = new Vector<MyClass>(initSizeInt);

    If you are working on NetBeans it gives you a suggestion.
    well, netbeans suggest -Xlint option as an example of compile option there.

  8. #8
    falven is offline Member
    Join Date
    May 2010
    Posts
    6
    Rep Power
    0

    Default

    That is just a warning message, you can disregard it.
    the reason that shows up is because you are using old objects/classes that will be eliminated on a future version of Java.

  9. #9
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,404
    Rep Power
    20

    Default

    Quote Originally Posted by falven View Post
    That is just a warning message, you can disregard it.
    Yes, you can disregard it, but far better to correct your code and gain the compile-time type safety that generics offers.

    Quote Originally Posted by falven View Post
    the reason that shows up is because you are using old objects/classes that will be eliminated on a future version of Java.
    Absolute rubbish.

    db

  10. #10
    falven is offline Member
    Join Date
    May 2010
    Posts
    6
    Rep Power
    0

    Default

    It's not rubbish. Do some reading.
    This usually happens when for example:
    you declared an object as ArrayList list = new ArrayList();
    and in this object you forgot to put your generics <>.
    Before generics were brought into Java in Java 5, developers
    created many ArrayList objects each supporting a different object/primitive
    types. So therefor, it's a warning because the program would still run,
    but instead of using the newer ArrayList<E> his program will use the
    old ArrayList, which is going to be removed in a future release.
    the reason they have not removed it yet is because they don't want to
    break people's programs.
    Again, before you make unsupported and gross accusations I suggest you read up.
    -Falven

  11. #11
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    9

    Default

    It is the "deprecated" warning where things might, eventually, get deleted. And even then, it is so rare that something actually gets deleted (I don't believe its actually ever happened, yet), that it's not really worth worrying about that. Deprecated methods will, however, eventually begin producing useless results (look at what happened when they changed the event model) so it behooves people to pay attention to those warnings.

    The "unchecked" warnings, however, have nothing, and I mean absolutely nothing, to do with that.

  12. #12
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,651
    Blog Entries
    7
    Rep Power
    21

    Default

    Quote Originally Posted by masijade View Post
    The "unchecked" warnings, however, have nothing, and I mean absolutely nothing, to do with that.
    I confess that I use those raw types sometimes: I have a map with a String key and the value is either the String name of a class or an object of that class. Those objects are 'cachable' and the map serves both as a symbol table and as the cache. I like how it works that way and haven't found a better, cleaner solution for it (yet?) I think the <?> notation or <Object> is feeble here, and it looks silly ;-)

    kind regards,

    Jos

  13. #13
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    Quote Originally Posted by pronetin View Post
    well, netbeans suggest -Xlint option as an example of compile option there.
    I'm referring to the editor. On left of the panel you should see that notification for what you've to do. Isn't it?

  14. #14
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    Quote Originally Posted by Darryl.Burke View Post
    Yes, you can disregard it, but far better to correct your code and gain the compile-time type safety that generics offers.
    I agreed with you. I think we should the most effective way in coding anytime with programming. Each millisecond is valued.

  15. #15
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Quote Originally Posted by falven View Post
    It's not rubbish. Do some reading.
    ......
    Again, before you make unsupported and gross accusations I suggest you read up.
    -Falven
    Sorry, Darryl's right on this one. As he stated, generics give the code compile-time type checking, but in no way are they required and in no way will not using them break the code for future versions of Java.

  16. #16
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    Quote Originally Posted by Fubarable View Post
    but in no way are they required and in no way will not using them break the code for future versions of Java.
    If some could be a drawback to use Java by developers.

Similar Threads

  1. Unchecked or unsafe operations warning
    By sky in forum New To Java
    Replies: 3
    Last Post: 12-06-2009, 03:41 AM
  2. Do I have to recompile everything?
    By wntdaliv in forum New To Java
    Replies: 1
    Last Post: 01-24-2009, 03:35 AM
  3. Xlint in build.xml not working
    By sunjavaboy in forum Eclipse
    Replies: 0
    Last Post: 06-23-2008, 01:35 AM
  4. Replies: 22
    Last Post: 05-08-2008, 12:00 PM
  5. Uses unchecked or unsafe operations message
    By Robbinz in forum New To Java
    Replies: 2
    Last Post: 12-06-2007, 10:56 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •