Sealed classes and interfaces

16 views
Skip to first unread message

tod...@googlemail.com

unread,
Feb 7, 2023, 2:22:57 AM2/7/23
to jOOQ User Group
Hi Lukas,
sometimes I take a look into the source code of JOOQ in order to understand this or that. I stumbled upon your usages of sealed classes and interfaces. It would be nice, if you can on a broader base e.g. on a blog post, explain your approach to use that language feature, your experience with it and pros and cons.

Thanks in advance
Dominik

Lukas Eder

unread,
Feb 7, 2023, 2:27:54 AM2/7/23
to jooq...@googlegroups.com
Hi Dominik,

Thanks for your message. I might write such a post, indeed, once things stabilise. Right now, sealed types are used experimentally. Compilers (both javac and ejc) don't seem to be fully ready yet. There are a few edge case compiler bugs that are hard to isolate and report, which is why the codebase hasn't been fully sealed yet.

Also, while the new QOM API surely should be sealed (look for "seal" in https://github.com/jOOQ/jOOQ/issues/13640), I'm not sure yet if the DSL API should be sealed as well. It would probably help prevent folks from tampering with custom implementations of the DSL interfaces, which are unlikely to work as expected without hacks. But it's hard to foresee if sealing is really possible. One very limiting factor is the fact that the permitted implementation (currently in org.jooq.impl, and package private) must be visible to the sealed type (currently in org.jooq), so perhaps, sealing the DSL isn't really possible without breaking compatibility.

Anyway, as I said, a blog post right now would be premature, before these decisions stabilise. But then, it would certainly be interesting.

I hope this helps,
Lukas

--
You received this message because you are subscribed to the Google Groups "jOOQ User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jooq-user+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jooq-user/7bc4d619-0cde-4866-8f75-26d7001eeab9n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages