Warning about unchecked call

What does it mean?
warning: [unchecked] unchecked call to add(E) as a member of the raw type java.util.Vector properties.add(prop);
and how can I avoid this warning? what shall i check?

If you use -Xlint, it will tell you the line number.
Basically, though, you are compiling in j2se 1.5.0, but not specifying the type for the Vector. That is, you are using it in it's pre 1.5.0, raw mode, and it cannot do any compile time type checking for you.
Say you were using your vector to store Integers. You would declare it as Vector<Integer> myIntegerVector = new Vector<Integer>();and the warning would go away. Now the compiler can do compile time type checking, and let you know when you are using that vector with a type other than Integer, which might not be safe.
� {�                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

Similar Messages

  • JDK 6: Generics: List.add() question - keep getting unchecked call warning.

    JDK 6
    Generics
    private TreeNode transactionTreeData;
    transactionTreeData.getChildren().add(moduleData);1. transactionTreeData is a TreeNode.
    2. the method getChildren() returns a java.util.List
    3. the method add() is from the Collection interface.
    I keep returning the warning message:
    "unchecked call to add(E) as a member of the raw type java.util.List"
    I understand what this means, but I am having problems rewriting these lines correctly to remove the warning.
    I've tried:
    private TreeNode transactionTreeData;
    List<TreeNode> treeList = transactionTreeData.getChildren();
    treeList.add(moduleData);But I keep returning the same warning message. I guess what is throwing me off is how to I properly add the generic statements when the List is return from a method (getChilden in this example)?
    Thanks,
    --Todd                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    This is actually JSF - MyFaces Tomahawk to be exact, my mistake for not adding that in my original thread.
    I am dealing with the compiled class:
    package org.apache.myfaces.custom.tree2;
    public interface TreeNode extends java.io.Serializable {  
         java.util.List getChildren();
    }TreeNode.getChildren return a raw List as you can see, no doubt...
    Thanks,
    --Todd                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Warning: [unchecked] unchecked call to getMethod when updating to JDK 1.6

    I'm received the following compilation warnings after I switched to Java 6 from Java 5:
    warning: [unchecked] unchecked call to getMethod(java.lang.String, java.lang.Class<?>...> as a member of the raw type java.lang.Class
    removeChangeListener = myParent.getMethod("removeChangeListener",
    changeListenerParameterTypes);
    The code is this class is instantiated by many classes. The class instantiating this class is passed through a constructor.
    Here is a partial code snippet of the class, constructor and method where the warning occurs:
    public class DumpDisplay extends javax.swing.JFrame implements javax.swing.event.ChangeListener
    private Class changeListenerParameterTypes[] = new Class[2];
    public DumpDisplay(Object mvc)
    Class myParent = mvc.getClass();
    public void removeListeners()
    Method removeChangeListener = null;
    changeListenerParameterTypes[0] = ChangeListener.class;
    changeListenerParameterTypes[1] = Integer.TYPE;
    // Get the removeChangeListener method from the MVC class
    try
    removeChangeListener = myParent.getMethod("removeChangeListener",
    changeListenerParameterTypes);
    catch (NoSuchMethodException e)
    System.out.println(" DumpDisplay class addChangeListener method: "+e);
    This compilation warning does not appear in JDK 1.5. Any assistance is greatly appreciated.

    Class myParent = mvc.getClass();Class<?> myParent = mvc.getClass();

  • Warning about low disk space on drive E

    Hi,
    I'm running Windows 7 on a HP Pavilion Elite HPE. My main drive i s C and there is also D (Factory image) and then the HP(E: ) one which is giving the warning about low disk space. When I look at what there is in drive E there is a folder called "my name"-PC with a lot of "Backup Set" folders/files in it, and then there is a folder called WindowsImageBackup and subfolder "my name"-PC.
    I know I have to clean out these folders but I ma very insecure as to what I can delete.
    I'd be very thankful if you could give me some advice in this matter!
    This question was solved.
    View Solution.

    File History in Windows 7 is an extensive image backup of your drive which will steadily increase over time and needs to be cleared and suggest that you turn the feature off.  It is not very efficient.
    If you wish to delete this  Windows Image Backup file, you should disable  the automatic backup feature of Windows.
    Click on Start button > Control Panel > System and Maintenance> Backup and Restore.
    In the left pane, click on "Turn Off Schedule".
    From there you can delete the backup files on your E drive.
    I also suggest as an alternative, use Macrium Reflect Free every so often as it is more efficient and reliable.  It will make a complete image back up of your entire hard drive to an external hard drive.  Don't forget to create a rescue disk.
    Go to this site and do a Custom Install:
    http://www.macrium.com/reflectfree.aspx
    I personally use the Professional Edition which gives me more flexibility and features.
    Please mark my post as SOLVED if it has resolved your problem. It helps others with similar situations.

  • Unchecked call to to add(E) ....... HELP

    Hi, i was doing a project in eclipse, and everything was fine (compiled and running). However, I ran into this problem when I try to compile the same code in DOS command line. Is there any ways that I can fix this problem so the same code that runs in Eclipse can compile in DOS also?
    a glimpse of the code is below:
    ArrayList best_move  = new ArrayList();
    for ( ..r... )
       for( ..c.... )
           Move  move = new Move( r, c);
           if( move is valid )
                then
                    best_move.add(move);warning: [unchecked] unchecked call to add(E) as a
    member of
    the raw type java.util.ArrayList
    best_move.add((Move) move);Appreciate your help.

    try the following
    ArrayList<class name> best_move  = new ArrayList<class name>();
    for ( ..r... )
       for( ..c.... )
           Move  move = new Move( r, c);
           if( move is valid )
                then
                    best_move.add((class name)move);in above "class name" is the class of the object which u wanna store in the collection e.g java.lang.Integer or java.lang.Float etc.
    this will not give any warnings in jdk1.5 and will help u out.

  • Unchecked call to TreeSet

    So, I'm trying to do something which I thought was fairly simple.
    I have a very simple record class who's only members are two strings and then there are the usual set/get methods. Let us call it class Foo.
    Now, I want to have a set of Foo's which keeps ordering based on first member, second member (e.g., like lastname, firstname). So, I build FooComparator which implements compare and equals. I then create my set class like this:
    public class FooSet extends TreeSet {
            public FooSet() {
            super(new FooComparator());
    }and I get:
    FooSet.java:23: warning: [unchecked] unchecked call to TreeSet(java.util.Comparator<? super E>) as a member of the raw type java.util.TreeSet
    super(new FooComparator());
    FooComparator looks like this:
    public class FooComparator implements Comparator, Serializable {  
            public FooComparator() {
            super();
        //impl of compare() and equals()
    }My two questions are:
    1) Is this warning ignorable?
    2) If not, what is the correct fix?
    Thanks, everyone.
    Best,
    Glenn

    The warning isn't a biggie... I'm pretty sure it's because you're not using generics. So lets say your your record class is called FooRecord. If you changed your code around to this, it should be fine.
    public class FooSet extends TreeSet<FooRecord> {
            public FooSet() {
                super(new FooComparator());
    }There might be a cleaner way to implement this (I'm not too clear on generics) but I'm pretty sure that'll do the trick. Once you get into generics they're awesome and make things a hell of a lot easier.
    -Thomas

  • Unchecked Call to addElement(E)

    I'm trying to store AudioClip objects in a vector. It compiles with a warning:
    AudioHolder.java:19: warning: [unchecked] unchecked call to addElement(E) as a member of the raw type java.util.Vector
              soundVector.addElement(temp);
    Temp is an AudioClip, but even when I make it something simple like an int or a String, it still throws up the same warning. At runtime, the line of code comes up with a nullpointer error. Can someone help me figure out how to fix this?

    The unchecked warning is just that: a warning, which you can safely ignore. All it's saying is that you could have taken advantage of the greater type-safety provided by jdk1.5 generics, for example:  Vector<AudioClip> soundVector = new Vector<AudioClip>();
      AudioClip temp = getAudioClip(); // or whatever
      soundVector.addElement(temp);  // no warningThe NullPointerException is not related to the unchecked warning. You probably tried to call a method or access a field on a null reference.

  • "unchecked call to put(K, V)..."

    Hi, I was till recently using this passage -
    public static final Hashtable map = new Hashtable();
    static {
    map.put(TextAttribute.FONT, new Font("Serif", Font.PLAIN, 14));
    to enable me to pass map into an AttributedString constructor.
    On upgrading to j2se 1.5, I now get this warning from javac: "unchecked call to put(K, V) as a member of the raw type java.util.Hashtable"
    Can anyone explain to me what this means and what to do? (Can't find any of these words in the API).
    Thanks
    Tom

    try here:
    http://java.sun.com/j2se/1.5.0/docs/guide/language/generics.html
    In Java 1.5 you can type what goes into the collection to stay away from runtime casting errors.

  • Audio warning about security on computer.....

    I am getting frequent loud audio warning about security on my computer.  The message plays continuously until I turn it off.  it tells me to go to (I think this is it,but I threw the paper away with the exact address) but there is no web address like that.  Is it a hoax and can I block it if so?  Is it real and do I need to do something?  Call from NOTIFICATION® - URGENT ONLINE NOTICE, duration 01:45 is what shows on the log.
    Thank you, Tovarishtina

    please visit the thread below for instructions and suggestions on how to deal with such unwanted and suspicious activities;
    How to Handle Suspicious Calls, Messages and Contact Requests (Scam/Spam)
    CONTACT SKYPE CUSTOMER SERVICE   |  HOW TO RECORD SKYPE VIDEO CALLS  | HOW TO HANDLE SUPICIOUS CALLS AND MESSAGES   |  WINDOWS PROBLEMS TROUBLESHOOTING   |  SKYPE DOWNLOAD LINKS  
    MORE TIPS, TRICKS AND UPDATES AT
    skypefordummies.blogspot.com

  • Removing unchecked call warnings

    I have moved from 1.4.2 to 1.5.0 today, and now I'm trying to solve all the unchecked call warnings that I had in the code, but I have one that I don't know how to avoid it.
    I need a matrix of nxn dimensions where every element is an Integer. I was creating this matrix in a recursive way, with a recursion deep of n. For example, if n=3, I had finally a Vector<Vector<Vector<Vector<Integer> > > >. As n is configurable by the user, I can't determine the data types that i must declare in the recursive calls that I use to manage the matrix.
    There is a class to implement my "matrix" in a simplest way?
    If not, there is a way to remove the warnings in the recursive calls?
    If not, I suppose that I must keep the warnings...
    Jorge

    Well, my use of the matrix is not mathematical but to represent the "real world".
    I'm working in the project previous to the University graduation, and I'm implementing a communication protocol among different computers.
    Those computers are linked in n dimensions (I have let configurable the dimensions because I think that flexibility is important for things like this).
    If n=1, the computers are linked like this:
    A - B - C -D - E -F - G - H - J
    If I have n = 2 the computers are linked like this:
    A - B - C
    | \ | / |
    D - E - F
    | / | \ |
    G - H - J
    (Well, in the post preview this last configuration looks very bad because some spaces are trim: The "E" computer is linked to all the rest of computers)
    If I have n = 3 the computers are linked in a cube shape, if I have n = 4 in an hipercube, and so on.
    That's why I need a multidimensional matrix to represent my network.
    I have a class that encapsulates the access to all the linked neighbours of a computer, and internally it stores these neighbours as a Vector of Vector's. of Vector's...(n times)
    For example, to create all the neighbour objects, I must write code like this:
    private Vector neighbours; // I don't know what I must write inside <> next to Vector declaration
    neighbours = new Vector(LINKS_IN_DIMENSION); // Again, the warning complains the lack of <>, but I don't know what goes inside
    initializeDimensionVector(1, neighbours);
    // In the method declaration, I need again the <> specification but is not possible
    private void initializeDimensionVector(int dimension, Vector vecDimension)
         vecDimension.setSize(LINKS_IN_DIMENSION);
         if ( NET_DIMENSIONS == dimension )
              for ( int i = 0; i < LINKS_IN_DIMENSION; ++i )
              vecDimension.setElementAt(new NeighbourDirectlyConnected(), i);
              return;
         for ( int i = 0; i < LINKS_IN_DIMENSION; ++i )
              // And finally here, for the new recursive call, the unspecified Vector declaration appears again
              vecDimension.setElementAt(new Vector(LINKS_IN_DIMENSION), i);
              initializeDimensionVector(dimension + 1, (Vector)vecDimension.elementAt(i));
    }The number of dimensions n is represented by NET_DIMENSIONS.
    The other constant (LINKS_IN_DIMENSION) tells how many different indexes we have per dimension.
    Hope this sample code explains a little bit what I'm trying to do.
    I can close my eyes and forget the warnings, but I come from the C++ world and experience tells that warnings musn't be ignored.
    Regards and thanks for your help.
    Jorge.

  • What is this? -- unchecked call to put(K,V)

    unchecked call to put(K,V) as a member of the raw type java.util.HashMap
    m.put( args[0], new Double( args[1]));
    I have code that stores a string and a double value in a map like this:
    String args[];
    m.put( args[0], new Double( args[1]));
    but I get this message when compiling with the Xlint option in javac. Why is this happening?

    Yes. I got the same compile warning when I compile with jdk1.5[jdk-1_5_0_03-windows-i586-p.exe]
    This:
    Map map=new HashMap();
    map.put("abc","def");Will get the warning like "unchecked ....."
    ====
    This:
    Map<Object,Object> map=new HashMap<Object,Object>();
    map.put("abc","def");Will compile OK.
    ====
    Is the compiler's responsible to set the default type to Object?

  • Warn About Changes and page flow

    Hi, in dev guide, it is said:
    For any single page, or first page in a navigation flow where the retainAM URL parameter value is set to Y (and the pages share the same root UI application module) as you navigate between each page, set the Warn About Changes property to True on the pageLayout region.
    in other word, if pages in page flow are in the same AM, after changing am in the first page, anytime leave the following page to click the home link(oracle branding), the WarnAboutChanges msg should be alerted?
    But,
    Now I have two pages, using the same AM, set the two pages' property "Warn About Changes" to true.
    And I want to implement this: after inputing some words, and click a sunmitButton forward to pageB(add retainAM = Y in setForwardURL in code), then in pageB don't do anything, but click home link, WarnAboutChanges message does not alert.
    Could anyone help to explain this?
    And how to implement the page flow warnAboutChanges?
    And how root application module to set if different pages in different AMs?
    PreThanks to you very much!

    But,
    Now I have two pages, using the same AM, set the two pages' property "Warn About Changes" to true.
    And I want to implement this: after inputing some words, and click a sunmitButton forward to pageB(add retainAM = Y in setForwardURL in code), then in pageB don't do anything, but click home link, WarnAboutChanges message does not alert.
    Could anyone help to explain this?
    I asked u previously also read dev guide properly, here it what dev guide say:
    "By default, the Warn About Changes property is set to True for each of the items in this list except for the
    OASubmitButtonBean whose default value is False (a ccording to the UI guidelines, the "Warn About
    Changes" check should be performed for all submit button instances except for Cancel, Apply and Submit
    buttons). If you want to explicitly enable the check for a submit button, set this property to True. Note that can
    also set it programmatically by calling OASubmitButtonBean.setWarnAboutChanges(pageContext,
    Boolean.TRUE) in processRequest()."
    I hope this answers ur question.
    And how to implement the page flow warnAboutChanges?
    Read "Save Model ('Warn About Changes')" in dev guide :).And how root application module to set if different pages in different AMs?
    You can nest differnt AMs in on AM in AM wizard.--Mukul                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Unchecked Call to addElement(E)(resultset with vector)

    Please i am trying to retreive a number of rows with two columns and am trying to add it into a vector object and ots been giving me this error message.
    Unchecked call to addElement(E)
    my code will appear below
    import java.io.*;
    import java.sql.*;
    import com.ecom.util.*;
    import java.util.Vector;
    public class ProdCategory implements Serializable
         Vector catid=new Vector();
         Vector catname=new Vector();
         EcomConnection econ;
         Connection con=null;
         ResultSet rs=null;
         Statement stat = null;
    /*The following method is used to retrieve the values of category Id and category name from CategoryDet table */
         public String getselect()
              try
                   System.out.println("Getting IN");
                   econ = new EcomConnection();
                   con=econ.getConnection();
                   stat=con.createStatement();
                   System.out.println("Connected...");
                   String query="select Ctgry_Id,Ctgry_Name from CategoryDet";
                   System.out.println("Executing Query");
                   rs=stat.executeQuery(query);
                   System.out.println("Executing result set");
                   while(rs.next())
                        catid.addElement(rs.getString(1));
                        catname.addElement(rs.getString(2));
                   System.out.println(" ");
                   rs.close();
                   stat.close();
                   econ.releaseConnection();
                   System.out.println("Connection Closed");
                   return " ";
              catch(SQLException sqlex)
                   System.out.println("There is some problem in SQL Execution..." + sqlex);
                   return "There is some problem in SQL Execution..." + sqlex;
              catch(Exception ex)
                   System.out.println("There is some other problem " + ex);
                   return "There is some other problem ..." + ex;
         /*The following method is used to get the value of catid variable*/
         public Vector getcatid()
              return catid;

    i mearnt to say warning not errors i tried to typecast
    as in: Vector<string> catid=new Vector();
    Vetor<String> catname=new Vector();
    its stop giving me a warning but didnt work at run-time..it was saying nullpointer exception i need assitance

  • Unchecked call to add element

    I get the following warning:
    warning: [unchecked] unchecked call to addElement(E) as a member of the raw type java.util.Vector
    from the line:
    ((Vector)results.get( "ALL" )).addElement( new Result( date, home, hg, ag, away ) ) ;I have had no problems fixing this warning with simple lines like:
    private Hashtable<String,Object> results = new Hashtable<String,Object>() ;but as you can see it is a bit more tricky.
    The compiler highlights:
    ( new Result( date, home, hg, ag, away ) ) ;as the warning. The Result Object takes parameters <String,String,Integer,Integer,String> if that helps.
    Can anyone suggest how to fix this warning please?

    Are all values in your hastable vectors of results, or will that only be true when the key is "ALL". If they all contain Vectors you can rewrite the code as follows
    private Hashtable<String, Vector<Result>> results = new Hashtable<String, Vector<Result>>();
    results.put("ALL", new Vector<Result>());
    results.get("ALL").addElement(new Result (date, home, hg, ag, away));Or if you want to keep your code more flexible change Vector to it's interface List. That will reduce the amount of work you have to do if you decide you don't want to use Vectors any more and use ArrayLists.
    private Hashtable<String, List<Result>> results = new Hashtable<String, List<Result>>();
    results.put("ALL", new Vector<Result>());
    results.get("ALL").add(new Result (date, home, hg, ag, away));Of course none of this will work if your map contains values other than Vectors of results.

  • Can I stop Windows 7 from warning about security on every linked PDF?

    I am working on a project for which I have created one central document (an index) and 120 linked documents. Each document, on every page, has links to the next alphabetical document and back to the central index. This project will be distributed on disc to people with unknown computer platforms.
    I am a Mac user, and this works well on my iMac using Adobe Reader. It also works on my ancient Windows XP machine. A tech friend has looked the project over, and he says that on Windows 7 (used by more than half of computer users), every time a document links to a new document, Windows 7 throws up a warning about PDF security hazards. With a large number of documents to open, this could be tiresome.
    Is there a way to stop Windows 7 from warning about security on every linked PDF?
    This tech person recommends joining all the PDFs into one file (around 50 MB by his estimate), which would require relinking every current link.
    Acrobat offers to do the same with its Portfolio, but I'm not fond of the graphic styles offered, and I worry that one large file might be a challenge for older machines.
    Any suggestions?

    Can you get a screen shot of this error message or at least the exact wording? I suspect the error message is being displayed by Reader/Acrobat and not Windows.

Maybe you are looking for