Use Advanced Search to search the entire archive.
Re: Remove "generic" multiply/divide operations from Quantity
- From: Werner Keil <
>
- To:
- Subject: Re: Remove "generic" multiply/divide operations from Quantity
- Date: Fri, 17 Oct 2014 05:26:13 +0200
Well believe it or not, a non-wildcard signature like Otavio proposed it
seems to solve another problem in Unit systems;-)
An almost ancient helper method from JSR-275 times (which remained in
JScience and all other implementations) looks like this:
private static <U extends Unit<?>> U addUnit(U unit) {...
Adding a given unit to a set of units.
This notoriously failed with a "Upper type boundary" compile error under SE
8 at least since U20.
Imagine what happened, when I changed it to
private static <U extends Unit<Q>, Q extends Quantity<Q>> U addUnit(U unit)
{...
The problematic line involving POUND_FORCE suddenly was accepted unchanged
from the RI equivalent;-)
Here's what the JDK team says about the use of wildcards:
http://docs.oracle.com/javase/tutorial/java/generics/wildcardGuidelines.html
"Using a wildcard as a return type should be avoided..." ;-)
Werner