RFR: implementation for JEP 334: JVM Constants API
jbvernee
jbvernee at xs4all.nl
Mon May 28 00:52:25 UTC 2018
Hello (again),
Sorry for keeping this going, but I keep thinking of new things a few
hours later (there goes my Sunday :/).
I'm wondering if the return type of `Constable::describeConstable` is
actually correct. Right now it's `Optional<? extends ConstantDesc<?
super T>>`, but why are you using `ConstantDesc<? super T>`? Since
`ConstantDesc` is a _producer_ of `T` PECS dictates that it should use
co-variance, i.e.: `ConstantDesc<? extends T>`, so that would make
`Optional<? extends ConstantDesc<? extends T>>` the return type. (a
ConstantDesc that resolves to a String can also be viewed as a
ConstantDesc that resolves to an Object)
That way you don't even have the problem I was trying to solve before,
and the return type of `EnumDesc::describeConstable` (and similarly for
`VarHandleDesc`) can be `Optional<DynamicConstantDesc<EnumDesc<E>>>`
which is the exact type that is being returned, which is what is wanted
right?
On that note, you could also change the return type of
`describeConstable` for the box types and String to return an optional
of the type itself (since they're their own descriptor, each implements
`ConstantDesc` of itself). For instance, for `Double` this would change
from `Optional<ConstantDesc<Double>>` to `Optional<Double>`.
Best regards,
Jorn Vernee
More information about the amber-dev
mailing list