RFR: 8325851: Hide PassFailJFrame.Builder constructor
Phil Race
prr at openjdk.org
Mon Mar 11 22:52:14 UTC 2024
On Mon, 11 Mar 2024 22:25:40 GMT, Alexey Ivanov <aivanov at openjdk.org> wrote:
>> test/jdk/java/awt/regtesthelpers/PassFailJFrame.java line 1070:
>>
>>> 1068: }
>>> 1069:
>>> 1070: public Builder title(String title) {
>>
>> So what about this one ? Are too many tests using it ?
>
> What about them? All the methods in `Builder` return `Builder`, that's perfectly fine.
>
> The goal of this PR is to make impossible to write
>
>
> new PassFailJFrame.Builder();
>
>
> which is replaced with
>
>
> PassFailJFrame.builder();
>
>
> In the former case, the test explicitly depends on the fact that the builder pattern implementation is in the `PassFailJFrame.Builder` class.
>
> In the latter case, I can change the `builder()` method to return another class. As long as that other class has the same set of methods, like `instructions` and title`, which return the same object, nothing breaks. Encapsulation.
>
> With this change, all the existing tests continue to run. Those tests which failed to compile because of a breaking API change are updated in this PR.
Never mind. I wasn't reading it properly.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/18206#discussion_r1520513514
More information about the client-libs-dev
mailing list