Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: Warning when I do a build

  1. #1
    Junior Member
    Join Date
    Mar 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Warning when I do a build

    There isn't anything wrong with my code, but I do have this annoying warning that pops up when I do a code. I know that it has to do with the generic in Java 1.7

    warning: [unchecked] unchecked call to put(K,V) as a member of the raw type Map runTask.getAppContext().put("master", master);
    where K,V are type-variables:
    K extends Object declared in interface Map
    V extends Object declared in interface Map
    1 warning

    Anyone know how to get rid of this?

    I know to get rid of it for ArrayLists you do something like ArrayList<String> columns = new ArrayList<String>();

    Thanks...


  2. #2
    Member
    Join Date
    Feb 2012
    Posts
    58
    Thanks
    0
    Thanked 3 Times in 3 Posts

    Default Re: Warning when I do a build

    You got the warning because you didn't declare a parameterized map. So change the declaration of the map to the parameterized version, for example:

    Map<String, Object> runTaskMap = new HashMap<String, Object>();

  3. #3
    Junior Member
    Join Date
    Mar 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Warning when I do a build

    My runTask isn't a hashmap though is it? I guess that's my confusion.

    I declare it here:
    IRunAndRenderTask runTask = engine.createRunAndRenderTask(reportDesign);

    Then call it here:
    runTask.getAppContext().put("master", master);

  4. #4
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,320
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: Warning when I do a build

    Quote Originally Posted by mad_hatter View Post
    My runTask isn't a hashmap though is it?
    No, but based upon the error whatever getAppContext() returns is an implementation of Map. Use the above advice to parametize the Map, if you cannot change the implementation of what getAppContext() returns (for instance it is part of an API that you reference) and need to remove the warning, then you can use the SuppressWarnings annotation to remove the warning

Similar Threads

  1. Warning! Greenhorn alert
    By Montrell79 in forum Member Introductions
    Replies: 2
    Last Post: March 6th, 2012, 03:56 AM
  2. Serializable compiler warning
    By kc120us in forum File I/O & Other I/O Streams
    Replies: 4
    Last Post: September 25th, 2011, 04:12 PM
  3. suppress warning
    By mDennis10 in forum Java Theory & Questions
    Replies: 2
    Last Post: September 10th, 2011, 10:06 AM
  4. Unchecked or Unverified Warning
    By saxophonemaster in forum What's Wrong With My Code?
    Replies: 1
    Last Post: April 2nd, 2011, 08:59 PM