Off topic: named parameters
Mike Hearn
mike at plan99.net
Tue Apr 21 10:59:34 UTC 2015
I don't know about JEP submission process, but you'd first have to solve
the problem that when Java added serialization of parameter names to class
files in Java 8, the OpenJDK devs explicitly decided *not* to expose them
for the JDK itself, on the grounds that they didn't want parameter names to
become part of the API. That's why you have to pass -parameters to javac to
get the new feature.
Adding named parameters to the Java language is probably a fair bit of
work. You'd need to build consensus for it on the relevant mailing lists
and with the relevant people first, before even getting to the JEP stage I
guess. An easier path: figure out how to get parameter names as part of the
JDK API and then work with the JetBrains Kotlin team. Kotlin is a very very
Java compatible JVM language, and it already supports named parameters by
default so they don't have the same hangups about the API compatibility
aspect. The Kotlin compiler routinely uses annotation data from Java
classes already so that's not a big leap either.
I suspect what it will take to get the JDK folks happy with exporting
parameter names by default is the ability to overload methods that differ
only by parameter names, so if you have a method with bad names then you
can add an overload with good names. However this would require a (much
smaller) change to the Java language, changes to javac, changes to how the
JVM does method linkage (possibly?) and so on.
Another possible plan of attack would be to calculate API diffs over time
and measure how often parameter names are actually changed. My guess is
"not often". If you can prove that they're worried about a relatively
uncommon problem then perhaps the JDK maintainers can be convinced to make
parameter names a part of the API, perhaps after an API cleanup pass to
find obviously bogus names and fix them.
Alternatively, given that Java is open source, you can of course go ahead
and make your own version of the JRE that exports this data by default.
Then you accept the possibility of upstream breaking your code and just
swallow it.
On Tue, Apr 21, 2015 at 9:52 AM, Tom Eugelink <tbee at tbee.org> wrote:
> Totally off topic, I apologise, but the subscribers to this list are the
> type of people who may have the experience I seek.
>
> I've been trying to pitch the concept of named parameters for Java 9, but
> somehow my JEP is never picked up. I emailed it in twice. Has anyone ever
> successfully handed in a JEP?
> https://tbeernot.wordpress.com/2013/09/29/the-java-9-named-parameter-pitch/
>
> Tom
>
More information about the openjfx-dev
mailing list