Use Advanced Search to search the entire archive.
Re: Email proposal to the core-libs-dev@openjdk.java.net
- From: Martin Desruisseaux <
>
- To:
- Subject: Re: Email proposal to the
- Date: Wed, 29 Oct 2014 10:36:26 +0900
- Organization: Geomatys
Le 29/10/14 07:46, Otávio Gonçalves de Santana a écrit :
>
The problem is you are looking to actual implementation, maybe if we
>
used best strategies with generics it will not happen.
It is not a matter of using better strategy. It is a matter of
mathematics (in the sense of logic or set theories). There is no way a
"better strategy" can make possible something mathematically impossible.
For example there is no way a "better implementation" can solve a system
of 2 equations with 3 unknowns.
In the case of our problem, we don't even need to look at the
implementation. There is no method signature with generic type that
express how R is related to Q and T in a multiply operation. With this
problem unsolved (and impossible to solve in current Java language), we
know in advance that a type-safe parameterized multiply implementation
is impossible.
There is nothing wrong with wildcard, when used properly. Have you seen
this standard Java method?
http://docs.oracle.com/javase/8/docs/api/java/lang/Class.html#getEnclosingClass--
The returns type is Class<?>, not Class<R> or whatever. This is not
because of history, since other methods in the same class returns more
accurate types (e.g. getSuperclass() returns Class<? super T>). They use
wildcard because there is no way to express the relationship between T
and the return value in the current Java language (they would need a
Class<? enclosing T> bounds, which does not exist).
Martin