Using an interface is less effective than making the constructor private
and the class final though.

Ismael

On Mon, Mar 24, 2025, 9:12 PM Chia-Ping Tsai <chia7...@gmail.com> wrote:

> hi All,
>
> > Matthias J. Sax <mj...@apache.org> 於 2025年3月5日 凌晨4:20 寫道:
> >
> > To me, the main thing is really, that currently user can call `new` what
> makes it easy to do thing wrong. If we change it to an interface, users
> cannot call `new`, and if the interface says "do not implement me", it
> should hopefully trigger the right response.
>
> It seems we want to obstruct users from creating the object - that means
> we need to disable users to new/extend it. If I understand it correctly,
> using the interface is a suitable way. Maybe we can have introduce a new
> annotation to explicitly remind users not to implement the interface. If we
> are in Java 17, the annotation can be replaced by sealed keyword.
>
> Best,
> Chia-Ping
>
>
>

Reply via email to