On Wed, 14 May 2025 17:53:48 GMT, Markus KARG <d...@openjdk.org> wrote:

>> The code should use the three-arg read() call in order to limit self-calls, 
>> in order to avoid the fragile base class problem. At some point we might 
>> want to add implSpec tags to specify this. See my previous comments relate 
>> to this topic: 
>> 
>> https://github.com/openjdk/jdk/pull/24728#issuecomment-2848332415
>
> I know that comment already, but IMHO we can simply use `@implSpec` to 
> unambiguously make clear that this method invokes `read(char[])` to allow 
> optimized implementations, and it *might* in turn invoke 
> `read(char[],int,int)`, but this is *not guaranteed*. A class is only fragile 
> as long as we do not *document* what it will do.

I doubt a subclass could make an optimization to the one-arg read() that it 
couldn't also make with the three-arg read(). Since the subclass is required to 
implement the three-arg read(), there's no benefit in specifying that this 
method call the one-arg read() instead of the three-arg read().

However, requiring this implementation to call the one-arg read() method is 
detrimental, because it precludes future optimizations that we might want to 
make to this method, which might want to use the more flexible three-arg read() 
method.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/24728#discussion_r2089856314

Reply via email to