1

I am getting warning

warning: [unchecked] unchecked call to add(E) as a member of the 
raw type java.util.List
    [javac]      listbox.getChildren().add(listaMenu); 

where listaMenu is declared as

UISelectItems listaMenu = new UISelectItems();

and listbox is declared as

HtmlSelectOneListbox listbox = new HtmlSelectOneListbox();

How can I get rid of this warning message when I compile using ant build tasks?

Thanks

Jacob
  • 14,463
  • 65
  • 207
  • 320

2 Answers2

2

Either get a new version of the Faces API implementation you're using (one that supports generics), or put @SuppressWarnings("unchecked") just before the start of the function (right before where public or private would go).

bdonlan
  • 224,562
  • 31
  • 268
  • 324
  • I have added as `@SuppressWarnings("unchecked") public HtmlSelectOneListbox myMethod() {` however I am still getting warning message when I compile my project. Thanks – Jacob Oct 21 '12 at 12:23
  • It needs to be applied to every function that makes unchecked calls (ie, add it to each function that's generating warnings, and I expect there'll be quite a few of them). Some IDEs (such as eclipse) may have an option somewhere to auto-add ('quick fix') the suppress warnings annotation. – bdonlan Oct 21 '12 at 12:24
1

Add an annotation to suppress the warning if the JSF API forces the use of unchecked casting:

@SuppressWarnings(value = "unchecked")

Similar to the answer(s) given here: Java [unchecked] unchecked case warning

Community
  • 1
  • 1
Drew MacInnis
  • 8,267
  • 1
  • 22
  • 18