[vector] RFR -- removing Shape as type parameter
Brian Goetz
brian.goetz at oracle.com
Wed Nov 28 16:54:41 UTC 2018
The below patch (tests pass) removes the Shape type argument from Vector
and subtypes.
http://cr.openjdk.java.net/~briangoetz/panama/noShape.patch
The use of Shape as a generic type parameter is clever, in that it does
a good job of providing compile-time type safety (preventing us from
mixing vectors of the wrong species), but I think we might be pushing it
too hard here, and I think it can be profitably removed. It is rare to
be mixing vectors who have the same element type but different shapes;
when we do, these can (and must) be caught by runtime checks (regardless
of whether we’re using static type checking to minimize the risk of
mixing vectors of incompatible sizes, we still have to check that things
match in the implementations (as the user could be using erased types.)
The Shape parameter bubbles out into the user code, for relatively
little benefit. I don't think it carries its weight.
Removing the Shape parameter also lets us undo another distortion, which
is making the Shape constants into separate classes. Now they can be a
regular enum. (Similarly, this also clears the way for some downstream
improvements to the API.)
(The patch is large as it includes the changes to the generated files
and tests, but all changes were made to the underlying templates.
Here's a smaller patch, which only contains changes to the source
templates and non-templated source files, in case that's easier to review.)
http://cr.openjdk.java.net/~briangoetz/panama/noShapeSourceTemplatesOnly.patch
More information about the panama-dev
mailing list