Cleaning up Control codebase - How to deal with StyleableProperty cast
Tom Schindl
tom.schindl at bestsolution.at
Wed Apr 30 13:32:57 UTC 2014
Hi,
According to Eclipse Compiler people we probably found a bug in javac.
They cited the following paragraph from the spec:
> "A cast from a type S to a parameterized type (§4.5) T is unchecked
> unless at least one of the following is true:
> * S <: T
> * All of the type arguments (§4.5.1) of T are unbounded wildcards
> * T <: S and S has no subtype X other than T where the type arguments
> of X are not contained in the type arguments of T."
Tom
On 29.04.14 00:00, Jonathan Giles wrote:
> IntelliJ says the following:
>
> =========================
> Unchecked cast: 'javafx.beans.property.BooleanProperty' to
> 'javafx.css.StyleableProperty<java.lang.Boolean>'
>
> *JDK 5.0 only.*
> Signals places where an unchecked warning is issued by the compiler, for
> example:
>
> |void f(HashMap map) {
> map.put("key", "value");
> }
> |=========================
>
> Perhaps the 'JDK 5.0 only' is significant? I honestly don't know....
>
> -- Jonathan
>
> On 29/04/2014 9:57 a.m., Tom Schindl wrote:
>> Hi,
>>
>> Interesting is that only the Eclipse Java Compiler shows a warning.
>> javac is fine with original code.
>>
>> Let me see what the Eclipse compiler guys have to say about that!
>>
>> Tom
>>
>> On 28.04.14 23:33, Tom Schindl wrote:
>>> Hi,
>>>
>>> I've been cleaning up the warnings inside the controls code base and one
>>> of the warnings left (beside many generic problems in the *View-classes)
>>> is the casting from *Property to *StyleableProperty.
>>>
>>>> final StyleableProperty<Boolean> prop =
>>>> (StyleableProperty<Boolean>)focusTraversableProperty();
>>> now I think I found a way to get away with out an unchecked cast warning
>>> by writing
>>>
>>>> final StyleableProperty<Boolean> prop =
>>>> (StyleableProperty<Boolean>)(WritableValue<Boolean>)focusTraversableProperty();
>>>>
>>> Anyone having a better idea?
>>>
>>> Tom
>>>
>
More information about the openjfx-dev
mailing list