Expand what permit can specify in Sealed Classes

Tagir Valeev amaembo at gmail.com
Thu Nov 12 03:55:52 UTC 2020


Hello!

On Thu, Nov 12, 2020 at 5:22 AM Remi Forax <forax at univ-mlv.fr> wrote:
> It's something the VM has to be aware of, it can not be only enforced by the compiler analysis otherwise it will not play well with separate compilation,
> so it's quite far away from the current solution we have.
> I'm not saying it's not possible, but that the cost is similar to redoing the work we have done.

Of course, this should be a VM-level feature.

> For me, you are hunting around the fact that refactoring a class to an interface is not a backward compatible change,
> We have discussed several times to change the JVM spec to allow to heal the rift between invokevirtual and invokeinterface (and their corresponding constant pool constants),
> by example, by allowing invokevirtual to call interface method too.

This breaks not only binary compatibility but also source
compatibility which also important. You have to replace 'extends' with
'implements' at very least, and the library author cannot suggest a
gradual migration path to the clients via deprecation, etc. After
updating to the new library version, all the clients must update all
the sources at once. Also, it might be quite difficult to get rid of
the state, so changing a base class to the interface is not always an
option.

> > plugins) were changed to implement this interface. Probably it would
> > be cleaner were LookupElement an interface but what's done is done.
>
> yes,

Of course, it's easy to say that your code is badly designed and you
should redo everything from the scratch to solve all your problems.
However, Java was always supporting backward compatibility, and that's
why it's quite successful language.

> For this one, it's a marker interface, and since Java 5 we have annotations that can be used to check a property of a class at runtime.
> Conceptually, an annotation is like an empty interface that is not part of the type lattice.

Note that you cannot restrict an annotation to be applied to
inheritors of specific class only. This is also a desired feature.
Though this could be solved separately.

With best regards,
Tagir Valeev.


More information about the amber-dev mailing list