[prev in list] [next in list] [prev in thread] [next in thread]
List: openjdk-openjfx-dev
Subject: Re: RFR: JDK-8298528: Clean up raw type warnings in base in bindings and collections packages
From: Nir Lisker <nlisker () openjdk ! org>
Date: 2022-12-30 21:23:57
Message-ID: -m4AJZ-2Uw6vNMNV9AwQTMCxamAom5Qklvr5zERmboo=.d87bffe9-e604-4896-82b1-a1edeec75ab2 () github ! com
[Download RAW message or body]
On Mon, 26 Dec 2022 14:32:52 GMT, John Hendrikx <jhendrikx@openjdk.org> wrote:
> > modules/javafx.base/src/main/java/javafx/beans/binding/ListExpression.java line \
> > 238:
> > > 236: public Iterator<E> iterator() {
> > > 237: final ObservableList<E> list = get();
> > > 238: return (list == null)? ListExpression.<E>emptyList().iterator() : \
> > > list.iterator();
> >
> > You're using three slightly different ways of referring to the empty list:
> > * `ListExpression.<E>emptyList()`
> > * `emptyList()`
> > * `EMPTY_LIST`
> >
> > What do you think about using the first option in all cases?
>
> I'm fine with that; the first two are equivalent, but in some cases I need to add \
> the type witness to avoid a warning and you can only do that by adding the class \
> name as well (ie. `<E>emptyList()` is not allowed, but \
> `ListExpression.<E>emptyList()` is.
Why not use `FXCollections.<E>emptyObservableList()` directly? If it's too long, a \
convenvenience method can be used:
private static <E> ObservableList<E> emptyList() {
return FXCollections.<E>emptyObservableList();
}
No need to hold the instance here again in a way that makes it lose its type and do \
the same cast (and supress the warning) that `FXCollections` already does.
Same with the other collections.
-------------
PR: https://git.openjdk.org/jfx/pull/972
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic