API REVIEW: RT-23888, Make PopupFeatures and PromptData final

Richard Bair richard.bair at oracle.com
Fri Aug 31 06:47:33 PDT 2012


Making everything non-final would be a disaster. From a security standpoint it is a non-starter. For example, value types should *never* be declared as non-final (for threading, correctness, and security reasons, which are all related). However obviously some things are meant to be, or should be subclassable, and those we can make so.

Richard

On Aug 31, 2012, at 6:22 AM, Randahl Fink Isaksen wrote:

> In your own private projects, adding final to a class is no risk, since you can change it the minute you realise that, after all, you needed to subclass.
> 
> In a general purpose and open source project with thousands of users and many different types of target applications, using final is a huge risk.
> 
> My project has been struggling with the improper use of final classes in JavaFX several times. We are developing a framework based on JavaFX, and being able to extend JavaFX classes is absolutely necessary, in order to add more features.
> 
> Take a look at these issues to see how previous mistakes have affected application and framework development for us (I am sure there are more issues if you do your own search):
> http://javafx-jira.kenai.com/browse/RT-17331
> http://javafx-jira.kenai.com/browse/RT-17078
> 
> To this day both Text and WebView are *still* declared final, and it has cost my project many hours of ugly work-around coding. 
> 
> I sincerely hope that no other classes are made final in this framework. It is an absolute disaster to third party framework development.
> 
> Randahl
> 
> 
> On Aug 31, 2012, at 15:03 , Tom Eugelink <tbee at tbee.org> wrote:
> 
>> All I can say is that I hate final classes. "Not meant" does not mean "no one ever wants to".
>> 
>> What is the gain of making them final and what is the loss of not making them final?
>> 
>> Tom
>> 
>> 
>> 
>> On 2012-08-31 14:59, Peter Zhelezniakov wrote:
>>> Hello,
>>> 
>>> There are two helper classes in javafx.scene.web package: PopupFeatures
>>> and PromptData. They are not meant to be extended by developers, so I
>>> hereby propose making them final, i.e.:
>>> 
>>> public final class PopupFeatures {
>>>    public final boolean hasMenu();
>>>    public final boolean hasStatus();
>>>    public final boolean hasToolbar();
>>>    public final boolean isResizable();
>>> }
>>> 
>>> public final class PromptData {
>>>    public PromptData(String message, String defaultValue);
>>>    public final String getMessage();
>>>    public final String getDefaultValue();
>>> }
>>> 
>>> Thanks!
>> 
> 



More information about the openjfx-dev mailing list