Re: Proposal on getting warning free (controls) packages
On 20/03/2014 20:57, 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: ((StyleablePropertyNode)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. If you are willing to expend another line of code, you could first assign graphicProperty to a variable: StylablePropertyNode property = (StyleablePropertyNode)graphicProperty(); property.applyStyle(origin, null); You can then apply the unchecked annotation to the assignment only, so future unchecked warnings in the same method will still be noticed. --John 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
Proposal on getting warning free (controls) packages
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: ((StyleablePropertyNode)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
Re: Proposal on getting warning free (controls) packages
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: ((StyleablePropertyNode)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
Re: Proposal on getting warning free (controls) packages
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 StyleablePropertyNode, 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 ObjectPropertyNode graphic; to private StyleableObjectPropertyNode graphic; and referencing 'graphic' instead of graphicProperty()... or adding a that does the instantiation of graphic private StyleableObjectPropertyNode _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: ((StyleablePropertyNode)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