Use Advanced Search to search the entire archive.
Re: Concrete Generics
- From: Werner Keil <
>
- To:
- Subject: Re: Concrete Generics
- Date: Sat, 18 Oct 2014 12:50:21 +0200
It was however absolutely necessary to fix SystemOfMeasurement
implementations using precisely the signature mentioned (or proposed
earlier by Otavio in a different place;-)
Java SE 8 will not accept a Unit<?> wildcard to add to the underlying Set
as it still did before.
Java does not support "reified" generic types as say C# does. And using the
same CLR, I trust Andrew Kennedy's F# implementation also does. That is
among the reasons, why he told me when 275 was stopped, Java had
limitations to that.
Reified types are also on the plate for Valhalla, but may not come before
Java 10, same as Value types.
Sources I consulted argue, Quantity<?> or Unit<?> effectively breaks
reification and is therefore to be avoided;-)
The reason why the ReflectionDemo showed Lenght, then Q seems unrelated,
and Otavio's suggestion won't allow us to preserve the concrete quantity
subtype as of now. It was coincidence, BaseUnit wasn't final, so the code
subclassed it, that's where aside from passing the class yourself you could
see the type via Reflection.
Neal Gafter who among Josh Bloch (and a few others, you also hear "Scala"
Odersky's name) had to do with generics followed him to Google, but now
works at Microsoft!;-)
Same as e.g. Erich Gamma.
It's probably not JEP101, but Oracle and OpenJDK gradually tries new stuff,
see 8u20. We might be forced to change the signature some day, but unless
it's a fatal showstopper for large users like Eclipse IoT, if they are
happy to cast in their code we could live with it so far. If Java 9 or 10
forced a drastic change, we'd require a MR or new version of the JSR.
Ideally deprecating if another signature worked side by side, or see what
Otavio suggested, if the code no longer compiled with <?> in that place,
with a backward-compatible substitute.
Werner
Am 18.10.2014 12:20 schrieb "Martin Desruisseaux" <
>:
>
>
Le 18/10/14 01:22, Werner Keil a écrit :
>
>
I won't push that change for now, but just to let you know, what worked
>
for Quantity also works the same way with Unit, e.g.
>
>
<R extends Unit<S>, S extends Quantity<S>, T extends Quantity<T>>
>
Unit<S> multiply(Unit<T> that);
>
instead of
>
Unit<?> multiply(Unit<?> that);
>
>
>
Sight... It is unacceptable for the same reason that Quantity.multiply.
>
>
Martin
>
>