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...
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:
Code :
Map<String, Object> runTaskMap = new HashMap<String, Object>();
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);
Re: Warning when I do a build
Quote:
Originally Posted by
mad_hatter
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