Proposal on getting warning free (controls) packages

David Grieve david.grieve at oracle.com
Thu Mar 20 20:32:11 UTC 2014


Too bad we can't go back and have WritableValue also extend Styleable...

I'm happy to live with the @SuppressWarnings in this particular context 
since we know that graphicProperty is indeed a StyleableProperty<Node>, 
as is the case where we cast in implementations of the CssMetaData 
getStyleableProperty() method.

The problem you cite could also be solved by changing
     private ObjectProperty<Node> graphic;
to
     private StyleableObjectProperty<Node> graphic;

and referencing 'graphic' instead of graphicProperty()... or adding a 
that does the instantiation of graphic

     private StyleableObjectProperty<Node> _graphicProperty()

and having the public graphicProperty() delegate to _graphicProperty();

I'm not sure what the util method would do if the cast wasn't safe, or 
is it just a try-catch that throws an unchecked exception?

On 3/20/14, 4:03 PM, Jonathan Giles wrote:
> I'll leave it to David to comment on the specifics of these warnings,
> but in general I'm very supportive of improving the quality of the
> controls code. It would be best to file a new jira issue and start
> putting patches up there (although for that to happen you'll need to
> email the patch to me so that I may attach it on your behalf).
>
> Thanks!
>
> -- Jonathan
>
> On 21/03/2014 8:57 a.m., Tom Schindl wrote:
>> Hi,
>>
>> I've just started looking into getting the controls package warning free
>> and/or suppress them in case not fixable.
>>
>> Most of the generic warnings I've come accross in a first pass involve
>> StyleableProperty cast like this:
>>
>> ((StyleableProperty)graphicProperty()).applyStyle(origin, null);
>>
>> In fact above code has 2 warnings:
>> a) unchecked type cast
>> b) usage of raw-type
>>
>> the raw type in this case can be fixed with:
>>
>> ((StyleableProperty<Node>)graphicProperty()).applyStyle(origin, null);
>>
>> leaving us with the unchecked cast so we could add:
>>
>> @SuppressWarnings({ "unchecked" })
>>
>> e.g. on the method but I'm uncertain this is a good idea because it
>> might hide unchecked warnings we have a possibility to fix.
>>
>> So what are other options:
>> a) Create a static helper in Util to make the cast and for us (we could
>>     even add it as a static method in the StyleableProperty-interface)
>>
>> b) provide a private/package-scoped method the public one delegates
>>
>> Both of them work but have different problems where I think b) has the
>> bigger ones like blowing up class-file, modification of the field to be
>> of type StyleableObjectProperty.
>>
>> I'd really like to get the source warning free.
>>
>> Thoughts?
>>
>> Tom



More information about the openjfx-dev mailing list