Diamond and Generic Methods

Ulf Zibis Ulf.Zibis at gmx.de
Thu May 5 08:42:26 PDT 2011


Am 05.05.2011 17:06, schrieb Jesper Öqvist:
> So, after searching the archives and scouring the JSR334 v0.875 draft, I
> have a question about Diamond. While the specification draft does not
> explicitly disallow it, it seems weird that this works (Java7 developer
> preview b139):
>
> class C {
> <T>  void identity(T a) { return a; }

Hm, is it correct, that a void method can return a value ?

-Ulf

>     void m() {
>       identity(new java.util.ArrayList<>());
>     }
> }
>
> Since there is a distinction between raw types and parameterized types
> with inferred type arguments (in the discussion part of the Diamond
> section in JSR334), it would be interesting to know what type is
> instantiated in the above example.
>
> /Jesper
>
>



More information about the coin-dev mailing list