INRIA/spoon

add support for Java 16

Closed this issue · 11 comments

What’s coming in Java 16?
https://www.infoworld.com/article/3569150/jdk-16-whats-coming-in-java-16.html#tk.rss_java

https://openjdk.java.net/projects/jdk/16/ as the official link, if somebody wants to read all jeps. From my understanding in December after rampdown phase 1 the feature list is more or less final and we only have to wait for jdt. I would expect records and instanceOf to reach the release state, and a preview for pattern matching (for more about pattern matching you can look at old languages like haskell)

Going through the Java 16 specs, one of the possible changes, I identified is JEP 392: Packaging Tool.

jpackage tool is moved from jdk.incubator.jpackage to jdk.jpackage

Having a quick look at the release notes, it seems like there are only 2 new stable features and 1 new preview feature that require extensions in Spoon. IMO preview features are not worth supporting, though.

Stable features

  • Records (JEP 395)
    • We need a new CtRecord interface to model it
    • Note: This is pure syntactical sugar, it just generates a class with some stuff (e.g. getters for fields, an equals method, a toString, and some other stuff). Pretty much built-in Lombok.
  • instanceof pattern matching (JEP 394)
    • Allows an optional variable to cast to the checked type (if check is successful)
    • E.g. obj instanceof String s instantiates s to (String) obj iff obj is in fact a String
    • May require a new CtInstanceOf interface that subtypes CtBinaryOperator to make sense

Preview features

  • Sealed types (preview 2, JEP 397)
    • Classes and interfaces can restrict how they can be subtyped with the sealed modifier
    • IMO not worth supporting until stable

Can you give an estimation when java 16 support will be available? It would be really great to have this.

Can you give an estimation when java 16 support will be available? It would be really great to have this.

@jakobbraun Support for type patterns is essentially done in #4020, we just hit a minor snag on finalizing. It should be available in the next beta release this weekend, I think.

The other big thing is records, and for that I can't really say. No one has yet taken it upon themselves to implement that, so I can't give an ETA on it.

Note that sealed classes are slated to be stabilized in Java 17 (JEP-409)

#4020 has added instanceof pattern matching, next step to close this issue is record support.

I've created #4132 to discuss records.

Now that @MartinWitt's great #4134 is merged, it seems we can close this one.

WDYT?

The last needed step is updating the GitHub page, then all is done.