Changes to signatures?

Brian Goetz brian.goetz at oracle.com
Mon Oct 27 13:48:59 UTC 2014


> Does anyone know whether Generic Signatures will be updated for JDK 10,
> or will they stay as-is?

Things that are currently expressible will retain their current 
expression.  There may be new forms of expression added, such as

    class Foo<any T> { ... }
    class Foo<ref T> { ... } // existing declarations of Foo<T>
                             // become shorthand for this

At the use site, likely no changes.

> Also, one thing that's unclear to me is whether a method like (sorry, I
> don't speak Java):
>
> T[] arrayOf<any T>(int length) { ... }

That's

<any T> T[] arrayOf(int length) { ... }

Here, Object comes out in the return type because all array types are 
objects, including int[]).  According to the Value Mantra, which is 
"What Would int Do", arrays of values would also be objects.  So this is 
(likely) unchanged.

Again, because of the desire to allow compatible evolution, changing the 
erased return type would mean that any-fying an existing generic method 
would be binary-incompatible, so unless there's a good enough reason 
here to be willing to take the hit of generating bridges, this is 
unlikely to change.

> will still emit "Object" as a return type in the signature. I remember
> that arrays not having a useful common supertype except Object was a
> pretty ugly thing in the past. Any changes here?
>
> Thanks and bye,
>
> Simon


More information about the valhalla-dev mailing list