Skip to main content

Re: Email proposal to the core-libs-dev@openjdk.java.net

  • From: Martin Desruisseaux < >
  • To:
  • Subject: Re: Email proposal to the
  • Date: Tue, 21 Oct 2014 22:08:25 +0900
  • Organization: Geomatys

Hello Werner

Le 21/10/14 21:52, Werner Keil a écrit :
> On Tue, Oct 21, 2014 at 2:34 PM, Martin Desruisseaux
> <
> <mailto: >>
>  wrote:
>
>     In your example a ClassCastException can happen here (choose the
>     alternative you prefer):
>
>         Length r = (Length) speed.multiply(time);
>         Length r = speed.multiply(time).cast(Length.class);
>
>
> This is highly discouraged as it won't work unless you also implement
> Length in a dedicated class like LengthAmount,...
The safe alternative that you mention is the second one above. I just
made a typo and accidentally called the method "cast" instead of "asType".

On you issue about the cast to (Length), I may be guessing your concern.
You said that it won't work because Unit<Q> instance do not have an
associated Class<Q> property, is that right? If, given a Unit<Q> object,
we could get the Class<Q> of the Quantity interface, then nothing would
prevent us from instantiating a Length, either directly as a
plain-old-object or through java.lang.reflect.Proxy. Do I'm
understanding your concern right?

    Martin



Re: Email proposal to the

(continued)

Re: Email proposal to the

Werner Keil 10/20/2014

Re: Email proposal to the

Martin Desruisseaux 10/21/2014

Re: Email proposal to the

Martin Desruisseaux 10/21/2014

Re: Email proposal to the

Werner Keil 10/21/2014

Re: Email proposal to the

Martin Desruisseaux 10/21/2014

Re: Email proposal to the

Werner Keil 10/21/2014

Re: Email proposal to the

Otávio Gonçalves de Santana 10/21/2014

Re: Email proposal to the

Werner Keil 10/21/2014

Re: Email proposal to the

Martin Desruisseaux 10/21/2014

Re: Email proposal to the

Werner Keil 10/21/2014

Re: Email proposal to the

Martin Desruisseaux 10/21/2014

Re: Email proposal to the

Werner Keil 10/21/2014

Re: Email proposal to the

Werner Keil 10/21/2014

Re: Email proposal to the

Otávio Gonçalves de Santana 10/28/2014

Re: Email proposal to the

Werner Keil 10/28/2014

Re: Email proposal to the

Martin Desruisseaux 10/29/2014

Re: Email proposal to the

Werner Keil 10/29/2014

Re: Email proposal to the

Otávio Gonçalves de Santana 10/30/2014

Re: Email proposal to the

Werner Keil 10/30/2014

Re: Email proposal to the

Martin Desruisseaux 10/30/2014

Re: Email proposal to the

Werner Keil 10/30/2014
 
 
Close
loading
Please Confirm
Close