Use Advanced Search to search the entire archive.
Re: Email proposal to the core-libs-dev@openjdk.java.net
- From: Werner Keil <
>
- To: "
" <
>
- Subject: Re: Email proposal to the
- Date: Thu, 30 Oct 2014 16:27:12 +0100
Btw. since a Major painpoint of Otavio seems to be the cast, note JSR 354
has probably the same number of explicit casts in ist JEP proposal (hence
in the code) like
if(Money.class==amt.getClass()){
Money m = (Money)amt;
}
or
public <T extends MonetaryAmount> T apply(T amount){
// cast should be safe for implementations that adhere to this spec
return (T)amount.divide(divisor);
}
The latter matches exactly what we do for asType(), see
public final <T extends Quantity<T>> AbstractQuantity<T> asType(Class<T>
type) throws ClassCastException { this.getUnit().asType(type); //
Raises ClassCastException if dimension mismatches. return (
AbstractQuantity<T>) this; }
Ideally where that is not yet the case, we shall clearly emphasise in the
spec what asType() does and what it can't do.
Note, JavaMoney doesn't even have the extra challenge of multi-quantity
calculations, since the only calculation it does is with what JScience
calls Quantity<Money>.
Yet especially to support multiple numeric precision levels, etc. it has to
rely on casts, as well[?]
As soon as this JEP is filed, it will of course immediately raise Attention
of the corest Core-JDK Team, so maybe as in other cases (my VOTE just
before) we should look at what's done here and where it makes sense in our
slightly more complex (multi-dimensional/multi-quantity) situation, try do
it in a similar way.
Werner
On Thu, Oct 30, 2014 at 12:16 PM, Martin Desruisseaux <
>
wrote:
>
I was meaning "the old proposition is illegal" (the one with Quantity<R>
>
return type), not the Quantity<?> return type. I fully support
>
Quantity<?> return type, and believe that it is actually the only one
>
possible for our semantic.
>
>
Martin
>
>
>
>
Le 30/10/14 20:06, Werner Keil a écrit :
>
> Well, reprase it please, as mentioned, there are also strategic JSRs
>
> like CDI doing it as our "prior work" does and especially Unit also
>
> does right now.
>
>
>
> Check out these examples:
>
>
>
http://www.programcreek.com/java-api-examples/index.php?api=javax.enterprise.inject.spi.InjectionPoint
>
>
>
> Is full of cases like
>
> Bean<?>bean=point.getBean();
>
> if(bean !=null){
>
> startup=bean.getBeanClass().getAnnotation(ContextName.class);
>
> }
>
>
>
>
Attachment:
347.gif
Description: GIF image