Compile warning

Hi,
I'm getting the following warning :
warning: [unchecked] unchecked cast
found : java.lang.Object
required: java.util.HashMap<java.lang.String,java.lang.Object>[]
HashMap<String,Object>[] contacts = (HashMap<String,Object>[]) Array.newInstance(temp.getClass(),found); //new HashMap<String,Object>[found];
^
Regarding the line :
HashMap<String,Object>[] contacts = (HashMap<String,Object>[]) Array.newInstance(temp.getClass(),found);
where temp is defined :
HashMap<String,Object> temp = new HashMap<String,Object>();
I don't know what to do about it.
Any help would be appreciated,
Dana.

What are you trying to do with that line? I may not have read it closely enough, but it looks wrong to me.
Are there any signs of error when your program runs and this line is executed?

Similar Messages

  • Can java provide a follow/depend/attatch compiling warning?

    I wrote a class called Query.It connect to database and return ResultSet.So user must manually call my method close() to close the ResultSet and Connection, otherwise resource will be avaliable.
    But user maybe forget call the close() method.If codes are released,problem will occur.
    For this reason I want java provides a compile warning if a important method is not called.
    e.g. Codes maybe like this:
    /**Start**/
    class Query(){
    ResultSet getResultSet(DataSource ds){
    //Codes get resultset
    return ResultSet;
    void close() follow getResultSet(DataSource){
    //Close databse
    //Note: "follow getResultSet(DataSource)" is my idea.
    class test{
    Query query = new Query();
    RsultSet rst = query.getResultSet();
    //query.close();//#1
    /**End**/
    If user forget writing line #1 (to close Database,etc), java compiler will give a warning:
    The method close() must follow method getResultSet!
    You will get error when running.
    Can java provide this function?
    Thanks!

    to mchan0 :
    I konw you mean I can copy ResultSet to another Object.But if databse is very very large,ResultSet will use large memory.It is not we want.
    e.g. our project database need to store 40,000,000 records.Once load large numbers records,server will crack.
    So I can only use ResultSet.
    If I wrong,please correct me.
    Thanks

  • Compilation warning

    Hi All,
    Can any one suggest me.
    I have compilation warning .
    my code :
    K is String type
    K key;
    key = (K)(key.toString().replace("'", "''"));
    warninig :
    java:22: warning: [unchecked] unchecked cast
    found : java.lang.String
    required: K
    key = (K)(key.toString().replace("'", "''"));
    Please hekp me
    Thanks in advance

    Here is my code
    public class DataMap<K, V> extends HashMap<K,V>
         public V put(K key, V value)
              if(key == null || value == null) return null;
              if(key.getClass() == String.class)
              key = (K)(key.toString().replace("'", "''"));
              if(value.getClass() == String.class)
              value = (V)(value.toString().replace("'", "''"));
              return super.put(key, value);
    }

  • [svn] 3050: Removed compile warning with JDK1.5

    Revision: 3050
    Author: [email protected]
    Date: 2008-08-29 16:48:58 -0700 (Fri, 29 Aug 2008)
    Log Message:
    Removed compile warning with JDK1.5
    Modified Paths:
    blazeds/trunk/modules/core/src/java/flex/messaging/io/BeanProxy.java

    Did you try this:
    http://forum.java.sun.com/thread.jsp?thread=434718&forum=60&message=1964421

  • Compile warning level

    Dear all,
    Can VC++ trigger compile warning msg when hitting the following conditions related to MFC:
    CString _str;
    if (_str = L"abc") //<--- (should be ==)
    if we use some basic type like int or string(STL) to define for the above conditions, VC compiler can trigger warning msg(warning C4706: assignment within conditional expression) under level 4 warning, but not for MFC CString.
    Thanks and regards,
    Wallace Chan
    P.S: We're using VC++ 2003

    Can VC++ trigger compile warning msg when hitting the following conditions related to MFC:
    It would appear not.
    CString _str;
    if (_str = L"abc") //<--- (should be ==)
    if we use some basic type like int or string(STL) to define for the above conditions, VC compiler can trigger warning msg(warning C4706: assignment within conditional expression) under level 4 warning, but not for MFC CString.
    It's interesting that std::string gives rise to an error in this
    situation (I get a C2451 error with VS2015 CTP), so it'd be neat if
    CString did similar.
    Can you file a bug/suggestion for this on MS connect
    https://connect.microsoft.com/visualStudio/. Post a link back here to
    your report so anyone who sees this can easily find it and vote for
    it.
    Dave

  • Turn off CSS compile warning

    Hi all,
    How do I turn off the compiler warning about unused CSS
    styles. I need the solution for both locally compiled SWF and those
    compiled in Flex Data Services. flex-config.xml doesn´t have
    the node option.
    Thanks
    David

    Thanks Brent for your quick response. That works well with
    the compile locally option. I found the solution if you are
    compiling with FDS.
    Its in the docs under:
    Building and Deploying Flex 2 Applications > Building Flex
    Applications > Flex 2 SDK and Flex Data Services Configuration
    > Flex Data Services configuration
    You can change the flex-webtier-config.xml file and turn the
    production setting on, or use the queryString parameter
    (showAllWarnings=false) if you are just testing.
    Cheers
    David

  • Vector compilation warning

    I have very basic program for learnings vectors but keep getting an warning during compilation. The program works fine but just compilation warning comes as below.
    Can soneone please advise what this might be and how to fix it.
    import java.util.*;
    public class vect2
    Vector list;
    String[] codes = {"aa","bb","cc","dd","ee","ff","gg"};
    public vect2() throws Exception
    list = new Vector();
    System.out.print(" Loading built in codes");
    int ch = System.in.read();
    for (int i=0; i < codes.length; i++)
         addCode(codes);
    System.out.println(" ..................done");
    System.out.println(" ");
    System.out.println(" ");
    System.out.println(" Enter to display all codes ");
    int ch2 = System.in.read();
    for (Iterator ite = list.iterator(); ite.hasNext();)
    String output = (String) ite.next();
    System.out.print(output+" ");
    private void addCode(String code)
    if(!list.contains(code))
    list.add(code);
    public static void main(String[] args) throws Exception
    vect2 var1 = new vect2();
    System.out.println(" ");
    System.out.println(" ");
    compilation error
    Note: vect2.java uses unchecked or unsafe operations.
    Note: Recompile with -Xlint: unchecked for details.
    javac -Xlint vect2.java
    vect2.java:35: warning: [unchecked] unchecked call to add(E) as a member of the raw type java.util.Vector
    list.add(code);
    1 warning

    Double post.
    http://forum.java.sun.com/thread.jspa?threadID=781067
    ~

  • Compiler warning: Source folder "server" does not exist and will be ignored

    Hi,
    i am using NWDS 7.0 SP16. I have a development component type "J2EE Sever Library", which uses a java component. Everything works fine, except during the build i get a warning "Warning: Source folder "server" does not exist and will be ignored.".
    Then i created the folder named "server" manually, but the build finished again with warning, now saying:
    "Warning: Source folder "server" exists but is empty and will be ignored."
    I created a dummy-file in the directory "server" and now the compilation is fine, no warnings.
    I like to get my build free of any warnings, so what's wrong here? I found no documentation to create the folder/file manually.
    Any help is appreciated.
    Regards,
    Thomas

    Hi Raman,
    I am also getting the same error . i moved my srm transports from DEV to QA and replicated the datasources into BI . and then i moved the BW transports from dev to QA.
    when i check the datasource it is pointing to D60 instead of Q60 . when i check the transformations getting the same error :
    source system dosen't exist.
    can you please let me know how you resolved this issue. your reply will be  highly appreciated.
    Regards,
    Sri

  • I'm getting a compiler warning with generics in J2SDK1.5.0

    javac -source 1.5 -target 1.5 -Xlint:unchecked Test.java
    Test.java:72: warning: unchecked cast to type TYPE mValues = (TYPE[])new Object[aInitialSize];
    My code is below, and ideas why this warning appears, is it a bug in my code or is the compiler faulty?
    (crosspost warning, I posted the same question on www.javalobby.org, no need for flaming...)
    static class Array
         private TYPE [] mValues;
         public Array(int aInitialSize)
              mValues = (TYPE[])new Object[aInitialSize];
         public void set(int aIndex, TYPE aValue)
              mValues[aIndex] = aValue;
         public TYPE get(int aIndex)
              return mValues[aIndex];
    Sincerely,
    Patrik Olsson

    I asked Sun about this and they replayed:
    No, because it is not typesafe. Consider the code
    class A<T> {
    T[] f() { return (T[])new Object[10]; }
    This will cause a class cast exception in its caller, even if the caller has no
    cast:
    A<Integer> ai = new A<Integer>();
    Integer[] a = ai.f(); // BOOM!
    Don't use arrays. Use collections.

  • Compiler warning PLW-05003 parameter at IN and COPY may have side effects

    For the following Procedure:
    create or replace
    PROCEDURE lob_replace
    p_lob IN OUT NOCOPY CLOB,
    p_what IN VARCHAR2,
    p_with IN VARCHAR2 )
    AS
    n NUMBER;
    BEGIN
    dbms_output.put_line('p_what = ' || p_what);
    dbms_output.put_line('p_with = ' || p_with);
    n := dbms_lob.instr( p_lob, p_what );
    dbms_output.put_line('n = ' || n);
    IF ( NVL(n,0) &gt; 0 ) THEN
    dbms_lob.copy( p_lob, p_lob, dbms_lob.getlength(p_lob), n+LENGTH(p_with), n+LENGTH(p_what) );
    dbms_lob.write( p_lob, LENGTH(p_with), n, p_with );
    IF ( LENGTH(p_what) &gt; LENGTH(p_with) ) THEN
    dbms_lob.trim( p_lob, dbms_lob.getlength(p_lob)-(LENGTH(p_what)-LENGTH(p_with)) );
    END IF;
    END IF;
    END;
    When I compile this, I receive the following warning "Warning(15,5): PLW-05003: same actual parameter(P_LOB and P_LOB) at IN and NOCOPY may have side effect"
    Line 15, column 5 is:
    dbms_lob.copy( p_lob, p_lob, dbms_lob.getlength(p_lob), n+LENGTH(p_with), n+LENGTH(p_what) );
    I'm reading about the NOCOPY Compiler hint at
    http://download-west.oracle.com/docs/cd/B10501_01/appdev.920/a96624/08_subs.htm#12813 but I'm not for sure what exactly the issue is here?
    The syntax for dbms_lob.copy is:
    DBMS_LOB.COPY (
    dest_lob IN OUT NOCOPY BLOB,
    src_lob IN BLOB,
    amount IN INTEGER,
    dest_offset IN INTEGER := 1,
    src_offset IN INTEGER := 1);
    Do I need to copy the p_lob to another variable, not sure what do here?

    Hi,
    Is this really a stand alone procedure, or is it in fact part of a package?
    That warning usually comes when parameter is declared with NOCOPY in specification but without in body. Or vice versa.
    Could this be the case?
    Regards
    Peter

  • Compiler warning with Collections.sort() method

    Hi,
    I am sorting a Vector that contains CardTiles objects. CardTiles is a class that extends JButton and implements Comparable. The code works fine but i get the following warning after compilation.
    Note: DeckOfCards.java uses unchecked or unsafe operations.
    Note: Recompile with -Xlint:unchecked for details.
    After compiling with -Xlint, i get the following warning;
    DeckOfCards.java:173: warning: [unchecked] unchecked method invocation: <T>sort(java.util.List<T>) in java.util.Collections is applied to (java.util.Vector<CardTiles>)
    Collections.sort(handTwo);
    ^
    What could be the problem? Is Collections.sort() only intended for Collections of type List?
    Many thanks!

    Hi Jverd, my handTwo Vector was declared as follows;
    Vector<CardTiles> handTwo = new Vector<CardTiles>();
    The CardTiles Source code is as follows;
    import javax.swing.*;
    import java.util.*;
    public class CardTiles extends JButton implements Comparable{
         static String typeOfSort = "face";
         public static final long serialVersionUID = 24362462L;
         int i=1;
         public ImageIcon myIcon;
         public Card myCard;
         public CardTiles(ImageIcon i, Card c){
              super(i);
              myIcon = i;
              myCard = c;
         public int compareTo(Object o){
              CardTiles compare = (CardTiles)o;
              if(typeOfSort.equals("face")){
                   Integer ref1 = new Integer(this.myCard.getFaceValue());
                   Integer ref2 = new Integer(compare.myCard.getFaceValue());
                   return ref1.compareTo(ref2);
              }else{
                   if(this.myCard.getFaceValue() > 9 || compare.myCard.getFaceValue() >9){
                        if(this.myCard.getFaceValue() > 9 && compare.myCard.getFaceValue() >9){
                             String ref1 = this.myCard.getSuit().substring(0,(this.myCard.getSuit().length()-1));
                             String ref2 = compare.myCard.getSuit().substring(0,(compare.myCard.getSuit().length()-1));
                             return ref1.compareTo(ref2);
                        }else{
                             if(this.myCard.getFaceValue() > 9 || compare.myCard.getFaceValue() >9){
                                  String ref1 = this.myCard.getSuit().substring(0,(this.myCard.getSuit().length()-1));
                                  String ref2 = compare.myCard.getSuit() + Integer.toString(compare.myCard.getFaceValue());
                                  return ref1.compareTo(ref2);
                             }else{
                                  String ref1 = this.myCard.getSuit() + Integer.toString(this.myCard.getFaceValue());
                                  String ref2 = compare.myCard.getSuit().substring(0,(compare.myCard.getSuit().length()-1));
                                  return ref1.compareTo(ref2);
                   }else{
                        String ref1 = this.myCard.getSuit() + Integer.toString(this.myCard.getFaceValue());
                        String ref2 = compare.myCard.getSuit() + Integer.toString(compare.myCard.getFaceValue());
                        return ref1.compareTo(ref2);
         public String toString(){
              return ( myCard.toString() + " with fileName " + myIcon.toString());
    }What could be wrong?
    Many thanks!

  • Getconf returns compiler flags that the compiler warns about

    I have Workshop 12u1 installed on my Solaris 10u8 machine (x86_64). I'm up to date with patches as of a couple weeks ago.
    I'm well aware that the Workshop suite has deprecated flags like -xarch=generic64, -xarch=amd64a, etc.
    However, when I run "getconf" on my Solaris 10 system, some of the conf settings still return those older flags that the compiler now warns about. That causes a lot of warning chatter when building certain applications (e.g. perl 5.10.1) that are smart enough to use "getconf" to try determine what flags to use in certain situations. Using getconf to find the right flags is even mentioned in the standards(5) page, but following its advice results in deprecation warnings from the compiler. Not good.
    If you run the following code you'll see what I mean:
    for f in `man getconf | egrep 'XBS'`; do echo "Checking $f"; getconf "$f"; doneIs this something that I (as a sysadmin for the system) should be able to configure, or is it something that would need to be patched to fix? The man pages for getconf, sysconf, and confstr aren't clear where the values are actually coming from.
    So, how should this be fixed?
    Thanks,
    Tim

    Enchanter wrote:
    Since I'm running regular old Solaris 10, rather than OpenSolaris, I'm skeptical how much help the OpenSolaris developers are truly going to be. I can certainly give it a go, but even if they fix it in OpenSolaris, it might be a very long time before that fix filters into Solaris.Actually, it goes the other way. New features and modification go into the internal Solaris development workspace before they migrate to Open Solaris. The Solaris Express and final releases and Open Solaris releases come from the same source base. Whether a feature or update goes into a Solaris 10 patch depends partly on demand, especially demand from customers with service contracts.
    I'm also a little puzzled about the "backwards compatibility" thinking of the compiler developers. In some areas (e.g. C++ and the standard library), what's shipped with the compiler is years and years behind what's current, apparently in the name of "backward compatibility". Yet where compiler flags are concerned, the developers seem to be much more cavalier about deprecating things and making changes that break backward compatibility.We try very hard not to break code or makefiles. Sun (and now Oracle) makes its money from enterprise users. Their code bases last for a long time, and changes are expensive. Changing a line in a makefile or source code file can mean having to re-certify the application.
    The change from -xarch to -m specifying the memory model was more abrupt than we would have liked, and in hindsight, was probably not handled very well. We were running into combinatorial explosion of -xarch sub-options due to the increasing number of architectures that the compiler supports. Some option combinations quietly resulted in behavior that you didn't expect. (For example, the combination "*-fast -xarch=v9*"did not give the same result as "*-xarch=v9 -fast*".) Separating memory model from the other considerations made the options easier and more reliable to use.
    Don't get me wrong -- I'm all for forward progress with the tool-chain -- I think that the C++ standard library and the defaults should all be brought up to what's current in the industry. Sun Studio 12 update 1 has direct support for Apache stdcxx (if installed in a standard location) in addition to libCstd and STLport. The Apache library will be in the next Open Solaris. When it will be available in a Solaris 10 update has not yet been decided.
    I also think adding support for -m32/-m64 was a good move. It just seems to me that if the developers are going to deprecate a large number of flags that the compiler accepts, they should also make certain that the rest of the operating system can handle that change. To me, that means that they need to work with the developers of getconf/confstr() to make certain it knows how to check the compiler version before it emits a particular flag.Only a few options have been deprecated. It's just that they are probably the ones you used most. :-(
    More than one compiler version can be installed on a system, and compilers can be installed anywhere. Programmers in medium to large shops typically run compilers installed on a remote server, although they might have other compilers installed locally. If getconf had to guess what compiler you were using, it would often guess wrong. If you have suggestions on how to match up getconf behavior with the compiler you want to use, please post them in an Open Solaris forum.

  • Mysql python snow leopard, won't compile - warning: "HAVE_WCSCOLL" redefine

    I am trying to crack open python for web development.
    step one ... get some db connectivity going. MySQL, Postgres (i don't really care) i have both installed and working within another php project.
    when trying to build and install the MySQL driver (mySQL-python-1.2.3
    i am getting the following errors
    building '_mysql' extension
    creating build/temp.macosx-10.6-universal-2.6
    gcc-4.2 -fno-strict-aliasing -fno-common -dynamic -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -pipe -Dversion_info=(1,2,3,'final',0) -D_version_=1.2.3 -I/usr/local/mysql/include -I/System/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6 -c _mysql.c -o build/temp.macosx-10.6-universal-2.6/_mysql.o -g -Os -arch x86_64 -fno-common -DP1003_1BVISIBLE -DSIGNALWITH_VIOCLOSE -DSIGNALSDONT_BREAKREAD -DIGNORESIGHUPSIGQUIT -DDONTDECLARE_CXA_PUREVIRTUAL
    In file included from _mysql.c:36:
    /usr/local/mysql/include/my_config.h:1053:1: warning: "HAVE_WCSCOLL" redefined
    In file included from /System/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6/Pyth on.h:8,
    from pymemcompat.h:10,
    from _mysql.c:29:
    /System/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6/pycon fig.h:803:1: warning: this is the location of the previous definition
    gcc-4.2 -Wl,-F. -bundle -undefined dynamic_lookup build/temp.macosx-10.6-universal-2.6/_mysql.o -L/usr/local/mysql/lib -lmysqlclient_r -lz -lm -lmygcc -o build/lib.macosx-10.6-universal-2.6/_mysql.so -arch x86_64
    10.6.4, python 2.65, most recent developer tools installed
    system was originally set up with 10.5 and upgraded to 10.6
    i have looked a hundred post on this issue and coming up dry.

    Post to the Unix or developer forums under OS X Technologies.

  • Compiler Warning: Recompile with -Xlint

    Note: C:\Documents and Settings\*\My Documents\InfixConvertor.java uses unchecked or unsafe operations.
    Note: Recompile with -Xlint:unchecked for details.
    Making a Infix to Postfix program. Doing some research, I understand that it does not need to be fixed, but I really wanna get rid of this. heres the code.
       import java.io.*;
       import java.util.*;
        public class InfixConvertor
       // initialize operator Stack
          private static Stack operatorS = new Stack();
           public static void main(String args[]) throws IOException
             String infix;
             Scanner in = new Scanner(System.in);
             System.out.println ("Enter a valid infix expression: ");
             infix = in.nextLine();
             System.out.println ("The Postfix expression is : " + IntoPostfix(infix));
       // method converts infix expression to postfix notation
           private static String IntoPostfix(String infix)
             StringTokenizer tokenizer = new StringTokenizer(infix);
          // divides the input into tokens for input
             String symbol, postfix = "";
             while (tokenizer.hasMoreTokens())
             // while there is input to be read
                symbol = tokenizer.nextToken();
             // if it's a number, add it to the string
                if (Character.isDigit(symbol.charAt(0)))
                   postfix = postfix + " " + (Integer.parseInt(symbol));
                else if (symbol.equals("("))
                // push "("
                   char operator = '(';
                   operatorS.push(operator);
                else if (symbol.equals(")"))
                // push everything back to "("
                   while (((Character)operatorS.peek()) != '(')
                      postfix = postfix + " " + operatorS.pop();
                   operatorS.pop();
                else
                // print operatorS occurring before it that have greater precedence
                   while (!operatorS.empty() && !(operatorS.peek()).equals("(")
                   && prec(symbol.charAt(0)) <= prec((Character)operatorS.peek()))
                      postfix = postfix + " " + operatorS.pop();
                   char operator = symbol.charAt(0);
                   operatorS.push(operator);
             while (!operatorS.empty())
                postfix = postfix + " " + operatorS.pop();
             return postfix;
       // method compares operators to establish precedence
           private static int prec(char x)
             if (x == '+' || x == '-')
                return 1;
             if (x == '*' || x == '/')
                return 2;
             return 0;
       }Please help me out. Thanks
    Julian

    You use "-Xlint:unchecked" as one of your command-line options. So instead of
    javac Thingy.javayou do this instead:
    javac -Xlint:unchecked Thingy.javaOf course if you already have several command-line options when you do your compiling, then you just need one more.

  • Tag Library Compile Warning

    Why does the weblogic jsp compiler wine about this standard tag library
              descriptor DTD?
              <?xml version="1.0" encoding="ISO-8859-1" ?>
              <!DOCTYPE taglib PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library
              1.1//EN"
              "http://java.sun.com/j2ee/dtds/web-jsptaglibrary_1_1.dtd">
              Have yet to see a TLD that does not use precisely this string and yet
              weblogic whines constantly about it.
              

    I figured it out. Under the Configuration/TagLibraries,
    create a CrossTagAttr folder and stick a .vtm file in it. In the
    .vtm file, use the <crosstag_attributes> tag and its
    children. See Configuration/TagLibraries/CrossTagAttr/Spry/Spry.vtm
    for an example.

Maybe you are looking for