Planned features of a classfile context object
Brian Goetz
brian.goetz at oracle.com
Fri May 19 16:41:08 UTC 2023
A few more words on this suggestion. As of Java 21, we have integrated
treatment of enums and sealed types in switch, so you can freely mix:
sealed interface Option { }
enum FooOption implements Option { FOO_YES, FOO_NO; }
record BarOption(int maxBars) implements Option { }
so that options representing "constants" could be handled as enums
rather than records, and options representing data holders (e.g.,
attribute mappers) are records, and the two can be mixed.
The use site can do:
ClassfileContext cc = CC.of(FooOption.FOO_YES, new BarOption(7))
and a switch over Option can mix enums and record patterns.
It is probably worth considering recasting some boolean-holder options
as enums.
On 5/19/2023 11:40 AM, Adam Sotona wrote:
>
> enum ProcessDebugOptions implements Option {
> DROP_DEBUG, DROP_DEBUG_ON_READ, DROP_DEBUG_ON_WRITE;
> }
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/classfile-api-dev/attachments/20230519/1aba3d23/attachment.htm>
More information about the classfile-api-dev
mailing list