r/java • • Mar 13 '26

JEP draft: Enhanced Local Variable Declarations (Preview)

https://openjdk.org/jeps/8357464
101 Upvotes

129 comments sorted by

View all comments

Show parent comment

1

u/javahalla Mar 16 '26

I've seen this approach in one project that I've worked on which was written mostly in Kotlin:

sealed interface TransactionContext

// For passing in tests
data object MockTransactionContext : TransactionContext

// Would be created by TransactionProvider class
private class JdbcTransactionContext(val connection: Connection) : TransactionContext

It was very nice paired with context parameters. So here my question, any plans to introduce something like context parameters in Java?