Abstract class with fields implementing ValueObject
John Rose
john.r.rose at oracle.com
Wed Feb 9 23:02:53 UTC 2022
That could be one of very many edge conditions in the JVMS that are not diagnosed directly by a validation, but that will eventually cause an error when the broken classfile is further used.
I don’t think there needs to be a special rule for this. We don’t try to comprehensively diagnose all “impossible-to-use” classfiles.
On 9 Feb 2022, at 13:50, Frederic Parain wrote:
> There's a weird case that seems to be allowed by the Value Objects JVMS draft:
>
> An abstract class can declare non-static fields, which means it won't
> have the ACC_PERMITS_VALUE flag set, but also declare that it implements
> the ValueObject interface.
>
> The combination looks just wrong, because no class can subclass such class:
> - identity classes are not allowed because of the presence of
> the ValueObject interface
> - value classes are not allowed because of the absence of
> ACC_PERMITS_VALUE
>
> I've looked for a rule that would prohibit such combination in the
> JVMS draft but couldn't find one.
>
> Did I miss something?
>
> Fred
More information about the valhalla-spec-observers
mailing list