6
warning: [unchecked] unchecked call to setCellValueFactory(Callback<CellDataFeatures<S,T>,ObservableValue<T>>) as a member of the raw type TableColumn column1.setCellValueFactory(new PropertyValueFactory<String, State>("name"));   where S,T are type-variables:
    S extends Object declared in class TableColumn
    T extends Object declared in class TableColumn

code:

column1.setCellValueFactory(new PropertyValueFactory<>("name"));

warning: [unchecked] unchecked call to add(E) as a member of the raw type List
            transitionTable.getColumns().add(column1);
  where E is a type-variable:
    E extends Object declared in interface List

code:

transitionTable.getColumns().add(column1);

warning: [unchecked] unchecked call to setAll(Collection<? extends E>) as a member of the raw type ObservableList
        automatonSelection.getItems().setAll(automatonManager.getMachines());
  where E is a type-variable:
    E extends Object declared in interface ObservableList

code:

automatonSelection.getItems().setAll(automatonManager.getMachines());

automatonSelection is a ComboBox and getMachines() returns a LinkedList of the type Automaton


warning: [unchecked] unchecked call to addListener(ChangeListener<? super T>) as a member of the raw type ObservableValue
        automatonSelection.valueProperty().addListener((ObservableValue observable,
  where T is a type-variable:
    T extends Object declared in interface ObservableValue

code:

automatonSelection.valueProperty().addListener((ObservableValue observable,
            Object oldValue, Object newValue) -> {
        stateChanged();
    });

I tried to fix most of those warnings and managed to do so by adding generics, but I can't see how to fix those other 4 warnings.

khelwood
  • 46,621
  • 12
  • 59
  • 83
Markus Paul
  • 125
  • 1
  • 2
  • 7

1 Answers1

15

Don't declare your TableViews and TableColumns as raw types.

In other words, instead of

TableView personTable ;
TableColumn firstNameColumn ;

use

TableView<Person> personTable ;
TableColumn<Person, String> firstNameColumn ;

etc.

Don't suppress these warnings, they will help you debug problems.

James_D
  • 177,111
  • 13
  • 247
  • 290
  • i declared my columns exactly like this and still get the warning – Markus Paul Jun 25 '15 at 20:52
  • Are you using Java 8? And for `transitionTable.getColumns().add(column1);` you cannot get the warning if `transitionTable` and `column1` are declared like this. – James_D Jun 25 '15 at 20:55
  • i managed to fix those warnings but the last 2 still remain, can you maybe help out? especially the one with the listener – Markus Paul Jun 25 '15 at 22:57
  • Can you show the declaration for `automatonSelection`? You should have `ComboBox automatonSelection ... ;` and `automatonSelection.valueProperty().addListener((ObservableValue observable, Something oldValue, Something newValue) -> ...);` – James_D Jun 26 '15 at 02:09