RFR: 8262891: Compiler implementation for Pattern Matching for switch (Preview) [v4]

Rémi Forax forax at openjdk.java.net
Wed May 26 20:24:06 UTC 2021


On Tue, 25 May 2021 16:14:56 GMT, Jan Lahoda <jlahoda at openjdk.org> wrote:

> I'd like to note this is a preview feature - we can change the desugaring. At the same time, I don't think this does not work with sub-patterns (those can be easily desugared to guards, I think).

Yes, but in that case the classcheck du to a sub-pattern matching will be either an instanceof or some other invokedynamic.
Having several indy will bloat the code and if we use instanceof, why not using instanceof all along the way.

> Regarding efficiency, it may be a balance between classfile overhead (which will be higher if we need to desugar every guard to a separate method), and the possibility to tweak the matching at runtime.

I fear more the 2 bytes length bytecode limit of a method than the constant pool length limit mostly because people are already using a bunch of lambdas to simulate pattern matching.

-------------

PR: https://git.openjdk.java.net/jdk/pull/3863



More information about the build-dev mailing list